aboutsummaryrefslogtreecommitdiffstats
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/Setup2
-rw-r--r--Documentation/cpusets.txt76
-rw-r--r--Documentation/feature-removal-schedule.txt34
-rw-r--r--Documentation/filesystems/9p.txt (renamed from Documentation/filesystems/v9fs.txt)21
-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/kbuild/makefiles.txt172
-rw-r--r--Documentation/kbuild/modules.txt98
-rw-r--r--Documentation/kernel-parameters.txt15
-rw-r--r--Documentation/networking/packet_mmap.txt10
-rw-r--r--Documentation/networking/ray_cs.txt2
-rw-r--r--Documentation/nfsroot.txt17
-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--MAINTAINERS53
-rw-r--r--Makefile204
-rw-r--r--arch/arm/Makefile5
-rw-r--r--arch/arm/boot/Makefile5
-rw-r--r--arch/arm/boot/bootp/Makefile5
-rw-r--r--arch/arm/mach-pxa/leds-mainstone.c6
-rw-r--r--arch/arm/mach-s3c2410/cpu.c2
-rw-r--r--arch/arm/mach-sa1100/collie.c30
-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/process.c3
-rw-r--r--arch/frv/kernel/gdb-stub.c2
-rw-r--r--arch/h8300/kernel/process.c4
-rw-r--r--arch/i386/Kconfig2
-rw-r--r--arch/i386/Kconfig.debug4
-rw-r--r--arch/i386/Makefile7
-rw-r--r--arch/i386/Makefile.cpu4
-rw-r--r--arch/i386/boot/edd.S2
-rw-r--r--arch/i386/kernel/apm.c2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/Kconfig24
-rw-r--r--arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c64
-rw-r--r--arch/i386/kernel/cpu/cpufreq/elanfreq.c109
-rw-r--r--arch/i386/kernel/cpu/cpufreq/gx-suspmod.c183
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longhaul.h4
-rw-r--r--arch/i386/kernel/cpu/cpufreq/p4-clockmod.c26
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k6.c16
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k7.c10
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c39
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.h6
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c4
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-lib.c42
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-lib.h20
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-smi.c53
-rw-r--r--arch/i386/kernel/cpu/proc.c2
-rw-r--r--arch/i386/kernel/dmi_scan.c33
-rw-r--r--arch/i386/kernel/microcode.c4
-rw-r--r--arch/i386/kernel/smpboot.c33
-rw-r--r--arch/i386/kernel/vmlinux.lds.S3
-rw-r--r--arch/i386/mach-visws/reboot.c1
-rw-r--r--arch/ia64/Kconfig9
-rw-r--r--arch/ia64/Makefile5
-rw-r--r--arch/ia64/configs/gensparse_defconfig1
-rw-r--r--arch/ia64/configs/sn2_defconfig1
-rw-r--r--arch/ia64/defconfig1
-rw-r--r--arch/ia64/dig/setup.c5
-rw-r--r--arch/ia64/ia32/sys_ia32.c14
-rw-r--r--arch/ia64/kernel/acpi.c35
-rw-r--r--arch/ia64/kernel/ivt.S1
-rw-r--r--arch/ia64/kernel/machvec.c19
-rw-r--r--arch/ia64/kernel/mca.c110
-rw-r--r--arch/ia64/kernel/mca_drv.c22
-rw-r--r--arch/ia64/kernel/mca_drv.h7
-rw-r--r--arch/ia64/kernel/mca_drv_asm.S13
-rw-r--r--arch/ia64/kernel/numa.c2
-rw-r--r--arch/ia64/kernel/patch.c8
-rw-r--r--arch/ia64/kernel/setup.c61
-rw-r--r--arch/ia64/kernel/smpboot.c109
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S60
-rw-r--r--arch/ia64/mm/contig.c8
-rw-r--r--arch/ia64/mm/discontig.c2
-rw-r--r--arch/ia64/mm/hugetlbpage.c7
-rw-r--r--arch/ia64/mm/init.c16
-rw-r--r--arch/ia64/sn/kernel/bte.c2
-rw-r--r--arch/ia64/sn/kernel/io_init.c29
-rw-r--r--arch/ia64/sn/kernel/irq.c21
-rw-r--r--arch/ia64/sn/kernel/tiocx.c10
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_provider.c17
-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/m68k/kernel/process.c2
-rw-r--r--arch/m68knommu/kernel/process.c2
-rw-r--r--arch/mips/kernel/sysirix.c22
-rw-r--r--arch/mips/mm/dma-ip32.c6
-rw-r--r--arch/parisc/kernel/process.c5
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/ppc/8xx_io/cs4218_tdm.c10
-rw-r--r--arch/ppc/Makefile2
-rw-r--r--arch/ppc/boot/Makefile8
-rw-r--r--arch/ppc/boot/openfirmware/Makefile7
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.c2
-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.c4
-rw-r--r--arch/s390/mm/cmm.c6
-rw-r--r--arch/sh/Makefile2
-rw-r--r--arch/sh/kernel/process.c1
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/kernel/irq.c66
-rw-r--r--arch/sparc/kernel/smp.c84
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c4
-rw-r--r--arch/sparc/kernel/sun4d_irq.c2
-rw-r--r--arch/sparc/kernel/sun4d_smp.c8
-rw-r--r--arch/sparc/kernel/sun4m_smp.c181
-rw-r--r--arch/sparc/mm/srmmu.c6
-rw-r--r--arch/sparc64/Kconfig.debug2
-rw-r--r--arch/sparc64/kernel/irq.c2
-rw-r--r--arch/um/Makefile7
-rw-r--r--arch/v850/kernel/process.c2
-rw-r--r--arch/x86_64/Kconfig40
-rw-r--r--arch/x86_64/Makefile6
-rw-r--r--arch/x86_64/defconfig34
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c2
-rw-r--r--arch/x86_64/ia32/sys_ia32.c16
-rw-r--r--arch/x86_64/kernel/aperture.c4
-rw-r--r--arch/x86_64/kernel/apic.c20
-rw-r--r--arch/x86_64/kernel/early_printk.c90
-rw-r--r--arch/x86_64/kernel/entry.S2
-rw-r--r--arch/x86_64/kernel/functionlist1286
-rw-r--r--arch/x86_64/kernel/head.S26
-rw-r--r--arch/x86_64/kernel/io_apic.c10
-rw-r--r--arch/x86_64/kernel/mce.c3
-rw-r--r--arch/x86_64/kernel/mpparse.c19
-rw-r--r--arch/x86_64/kernel/nmi.c1
-rw-r--r--arch/x86_64/kernel/pci-dma.c3
-rw-r--r--arch/x86_64/kernel/pci-gart.c11
-rw-r--r--arch/x86_64/kernel/pmtimer.c3
-rw-r--r--arch/x86_64/kernel/process.c11
-rw-r--r--arch/x86_64/kernel/ptrace.c6
-rw-r--r--arch/x86_64/kernel/setup.c85
-rw-r--r--arch/x86_64/kernel/setup64.c18
-rw-r--r--arch/x86_64/kernel/smp.c6
-rw-r--r--arch/x86_64/kernel/time.c129
-rw-r--r--arch/x86_64/kernel/traps.c21
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S6
-rw-r--r--arch/x86_64/kernel/x8664_ksyms.c4
-rw-r--r--arch/x86_64/lib/thunk.S1
-rw-r--r--arch/x86_64/mm/fault.c79
-rw-r--r--arch/x86_64/mm/init.c36
-rw-r--r--arch/x86_64/mm/k8topology.c2
-rw-r--r--arch/x86_64/mm/numa.c24
-rw-r--r--arch/x86_64/mm/srat.c8
-rw-r--r--arch/x86_64/pci/mmconfig.c18
-rw-r--r--block/elevator.c3
-rw-r--r--drivers/acpi/Kconfig3
-rw-r--r--drivers/acpi/blacklist.c27
-rw-r--r--drivers/acpi/processor_idle.c25
-rw-r--r--drivers/atm/.gitignore5
-rw-r--r--drivers/base/cpu.c9
-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.c3
-rw-r--r--drivers/block/cciss_scsi.c2
-rw-r--r--drivers/block/cpqarray.c3
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/block/nbd.c5
-rw-r--r--drivers/block/paride/comm.c16
-rw-r--r--drivers/block/paride/on26.c2
-rw-r--r--drivers/block/rd.c3
-rw-r--r--drivers/cdrom/cm206.c8
-rw-r--r--drivers/cdrom/sbpcd.c10
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/Makefile87
-rw-r--r--drivers/char/agp/Kconfig4
-rw-r--r--drivers/char/agp/agp.h11
-rw-r--r--drivers/char/agp/ali-agp.c2
-rw-r--r--drivers/char/agp/alpha-agp.c14
-rw-r--r--drivers/char/agp/amd64-agp.c4
-rw-r--r--drivers/char/agp/ati-agp.c10
-rw-r--r--drivers/char/agp/backend.c2
-rw-r--r--drivers/char/agp/efficeon-agp.c16
-rw-r--r--drivers/char/agp/frontend.c2
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/agp/hp-agp.c6
-rw-r--r--drivers/char/agp/i460-agp.c16
-rw-r--r--drivers/char/agp/intel-agp.c45
-rw-r--r--drivers/char/agp/isoch.c20
-rw-r--r--drivers/char/agp/nvidia-agp.c20
-rw-r--r--drivers/char/agp/sgi-agp.c2
-rw-r--r--drivers/char/agp/sis-agp.c8
-rw-r--r--drivers/char/agp/sworks-agp.c15
-rw-r--r--drivers/char/agp/uninorth-agp.c12
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c12
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c4
-rw-r--r--drivers/char/istallion.c8
-rw-r--r--drivers/char/mem.c28
-rw-r--r--drivers/char/mxser.c8
-rw-r--r--drivers/char/pcmcia/synclink_cs.c2
-rw-r--r--drivers/char/ppdev.c3
-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/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.c4
-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/cpufreq/cpufreq.c105
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c86
-rw-r--r--drivers/cpufreq/cpufreq_performance.c2
-rw-r--r--drivers/cpufreq/cpufreq_powersave.c2
-rw-r--r--drivers/cpufreq/cpufreq_stats.c8
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c12
-rw-r--r--drivers/cpufreq/freq_table.c12
-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/hwmon/gl520sm.c2
-rw-r--r--drivers/i2c/chips/rtc8564.c2
-rw-r--r--drivers/ide/ide-disk.c2
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-probe.c9
-rw-r--r--drivers/ide/ide.c2
-rw-r--r--drivers/ieee1394/raw1394.c96
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c61
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h15
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c44
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c6
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c145
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h7
-rw-r--r--drivers/input/serio/hil_mlc.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c1
-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/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/md/bitmap.c4
-rw-r--r--drivers/md/dm-hw-handler.c3
-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.c10
-rw-r--r--drivers/media/video/adv7175.c6
-rw-r--r--drivers/media/video/arv.c54
-rw-r--r--drivers/media/video/bt819.c10
-rw-r--r--drivers/media/video/bt856.c4
-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.c656
-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.c4
-rw-r--r--drivers/media/video/saa7111.c4
-rw-r--r--drivers/media/video/saa7114.c12
-rw-r--r--drivers/media/video/saa7115.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.c4
-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.c20
-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.h2
-rw-r--r--drivers/media/video/zoran_card.c2
-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.c16
-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/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/cassini.c11
-rw-r--r--drivers/net/chelsio/cxgb2.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/lance.c9
-rw-r--r--drivers/net/lasi_82596.c6
-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/sk98lin/skge.c2
-rw-r--r--drivers/net/sky2.h2
-rw-r--r--drivers/net/sun3lance.c2
-rw-r--r--drivers/net/wireless/Kconfig1
-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/parisc/sba_iommu.c10
-rw-r--r--drivers/parisc/superio.c7
-rw-r--r--drivers/pnp/isapnp/core.c4
-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.c314
-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.c20
-rw-r--r--drivers/s390/net/qeth_sys.c3
-rw-r--r--drivers/s390/s390_rdev.c3
-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/in2000.c24
-rw-r--r--drivers/scsi/libata-bmdma.c238
-rw-r--r--drivers/scsi/libata-core.c469
-rw-r--r--drivers/scsi/libata-scsi.c79
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c2
-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_uli.c37
-rw-r--r--drivers/scsi/sata_vsc.c4
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/serial/8250_hp300.c10
-rw-r--r--drivers/serial/ioc4_serial.c387
-rw-r--r--drivers/serial/mpc52xx_uart.c2
-rw-r--r--drivers/serial/mpsc.c260
-rw-r--r--drivers/serial/mpsc.h289
-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/masters/matrox_w1.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.c43
-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/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/befs/datastream.c2
-rw-r--r--fs/befs/linuxvfs.c3
-rw-r--r--fs/bfs/inode.c3
-rw-r--r--fs/binfmt_elf.c18
-rw-r--r--fs/binfmt_elf_fdpic.c3
-rw-r--r--fs/binfmt_flat.c73
-rw-r--r--fs/bio.c7
-rw-r--r--fs/block_dev.c9
-rw-r--r--fs/buffer.c87
-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/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.c5
-rw-r--r--fs/dcache.c23
-rw-r--r--fs/direct-io.c8
-rw-r--r--fs/dquot.c3
-rw-r--r--fs/efs/super.c2
-rw-r--r--fs/eventpoll.c4
-rw-r--r--fs/exec.c7
-rw-r--r--fs/ext2/ext2.h3
-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/super.c10
-rw-r--r--fs/fat/cache.c2
-rw-r--r--fs/fat/inode.c3
-rw-r--r--fs/freevxfs/vxfs_super.c2
-rw-r--r--fs/fs-writeback.c2
-rw-r--r--fs/hpfs/super.c3
-rw-r--r--fs/inode.c11
-rw-r--r--fs/inotify.c87
-rw-r--r--fs/isofs/inode.c3
-rw-r--r--fs/isofs/isofs.h12
-rw-r--r--fs/jbd/journal.c27
-rw-r--r--fs/jbd/transaction.c4
-rw-r--r--fs/jffs/inode-v23.c10
-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/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/namei.c22
-rw-r--r--fs/ncpfs/inode.c3
-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/super.c4
-rw-r--r--fs/ocfs2/alloc.c88
-rw-r--r--fs/ocfs2/aops.c18
-rw-r--r--fs/ocfs2/buffer_head_io.c11
-rw-r--r--fs/ocfs2/cluster/heartbeat.c38
-rw-r--r--fs/ocfs2/cluster/masklog.h10
-rw-r--r--fs/ocfs2/dcache.c9
-rw-r--r--fs/ocfs2/dir.c42
-rw-r--r--fs/ocfs2/dlm/dlmast.c22
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h21
-rw-r--r--fs/ocfs2/dlm/dlmconvert.c11
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c18
-rw-r--r--fs/ocfs2/dlm/dlmfs.c3
-rw-r--r--fs/ocfs2/dlm/dlmlock.c14
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c227
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c50
-rw-r--r--fs/ocfs2/dlm/dlmunlock.c11
-rw-r--r--fs/ocfs2/dlmglue.c101
-rw-r--r--fs/ocfs2/export.c24
-rw-r--r--fs/ocfs2/extent_map.c34
-rw-r--r--fs/ocfs2/file.c42
-rw-r--r--fs/ocfs2/inode.c116
-rw-r--r--fs/ocfs2/journal.c27
-rw-r--r--fs/ocfs2/localalloc.c17
-rw-r--r--fs/ocfs2/namei.c79
-rw-r--r--fs/ocfs2/ocfs2.h12
-rw-r--r--fs/ocfs2/suballoc.c72
-rw-r--r--fs/ocfs2/super.c22
-rw-r--r--fs/ocfs2/super.h8
-rw-r--r--fs/ocfs2/uptodate.c40
-rw-r--r--fs/ocfs2/vote.c63
-rw-r--r--fs/open.c4
-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.c37
-rw-r--r--fs/qnx4/inode.c3
-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/romfs/inode.c3
-rw-r--r--fs/smbfs/inode.c5
-rw-r--r--fs/super.c9
-rw-r--r--fs/sysv/inode.c2
-rw-r--r--fs/sysv/super.c4
-rw-r--r--fs/udf/inode.c6
-rw-r--r--fs/udf/super.c22
-rw-r--r--fs/ufs/super.c5
-rw-r--r--fs/xfs/linux-2.6/kmem.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c2
-rw-r--r--fs/xfs/xfs_vnodeops.c2
-rw-r--r--include/acpi/acpi_bus.h2
-rw-r--r--include/asm-alpha/io.h84
-rw-r--r--include/asm-alpha/poll.h2
-rw-r--r--include/asm-arm/arch-at91rm9200/at91rm9200_emac.h138
-rw-r--r--include/asm-arm/io.h36
-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-h8300/poll.h1
-rw-r--r--include/asm-i386/dmi.h11
-rw-r--r--include/asm-i386/io.h12
-rw-r--r--include/asm-i386/poll.h1
-rw-r--r--include/asm-i386/system.h2
-rw-r--r--include/asm-ia64/acpi.h4
-rw-r--r--include/asm-ia64/asmmacro.h11
-rw-r--r--include/asm-ia64/linkage.h8
-rw-r--r--include/asm-ia64/machvec_dig.h2
-rw-r--r--include/asm-ia64/numa.h2
-rw-r--r--include/asm-ia64/numnodes.h13
-rw-r--r--include/asm-ia64/page.h2
-rw-r--r--include/asm-ia64/pal.h3
-rw-r--r--include/asm-ia64/poll.h1
-rw-r--r--include/asm-ia64/processor.h1
-rw-r--r--include/asm-ia64/sn/l1.h3
-rw-r--r--include/asm-ia64/sn/pcibr_provider.h1
-rw-r--r--include/asm-ia64/sn/pcidev.h1
-rw-r--r--include/asm-ia64/sn/sn_feature_sets.h3
-rw-r--r--include/asm-ia64/sn/sn_sal.h28
-rw-r--r--include/asm-ia64/system.h2
-rw-r--r--include/asm-m32r/poll.h1
-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/io.h18
-rw-r--r--include/asm-parisc/poll.h1
-rw-r--r--include/asm-powerpc/poll.h1
-rw-r--r--include/asm-s390/bug.h5
-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/poll.h1
-rw-r--r--include/asm-v850/linkage.h4
-rw-r--r--include/asm-v850/poll.h1
-rw-r--r--include/asm-x86_64/apicdef.h1
-rw-r--r--include/asm-x86_64/dmi.h27
-rw-r--r--include/asm-x86_64/elf.h4
-rw-r--r--include/asm-x86_64/floppy.h2
-rw-r--r--include/asm-x86_64/io.h38
-rw-r--r--include/asm-x86_64/local.h10
-rw-r--r--include/asm-x86_64/mmu_context.h6
-rw-r--r--include/asm-x86_64/mmzone.h9
-rw-r--r--include/asm-x86_64/numa.h4
-rw-r--r--include/asm-x86_64/pda.h2
-rw-r--r--include/asm-x86_64/pgalloc.h28
-rw-r--r--include/asm-x86_64/pgtable.h10
-rw-r--r--include/asm-x86_64/poll.h1
-rw-r--r--include/asm-x86_64/proto.h3
-rw-r--r--include/asm-x86_64/string.h17
-rw-r--r--include/asm-x86_64/suspend.h4
-rw-r--r--include/asm-x86_64/system.h6
-rw-r--r--include/asm-xtensa/poll.h1
-rw-r--r--include/linux/bitmap.h3
-rw-r--r--include/linux/bitops.h7
-rw-r--r--include/linux/bootmem.h3
-rw-r--r--include/linux/capability.h3
-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/dmi.h2
-rw-r--r--include/linux/fadvise.h6
-rw-r--r--include/linux/fs.h18
-rw-r--r--include/linux/fsnotify.h19
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/ide.h1
-rw-r--r--include/linux/init.h4
-rw-r--r--include/linux/inotify.h11
-rw-r--r--include/linux/irq.h49
-rw-r--r--include/linux/jbd.h4
-rw-r--r--include/linux/kernel.h5
-rw-r--r--include/linux/libata.h12
-rw-r--r--include/linux/linkage.h16
-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/pagemap.h5
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/platform.h43
-rw-r--r--include/linux/ppdev.h2
-rw-r--r--include/linux/quota.h1
-rw-r--r--include/linux/radix-tree.h13
-rw-r--r--include/linux/reiserfs_fs.h5
-rw-r--r--include/linux/reiserfs_xattr.h6
-rw-r--r--include/linux/sched.h8
-rw-r--r--include/linux/security.h22
-rw-r--r--include/linux/slab.h39
-rw-r--r--include/linux/string.h2
-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_flip.h4
-rw-r--r--include/linux/udf_fs_i.h21
-rw-r--r--include/linux/videodev2.h1
-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/route.h2
-rw-r--r--include/net/sock.h2
-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/Kconfig46
-rw-r--r--init/do_mounts.c2
-rw-r--r--init/initramfs.c10
-rw-r--r--init/main.c24
-rw-r--r--ipc/msg.c3
-rw-r--r--ipc/shm.c3
-rw-r--r--kernel/capability.c16
-rw-r--r--kernel/cpu.c3
-rw-r--r--kernel/cpuset.c152
-rw-r--r--kernel/exec_domain.c1
-rw-r--r--kernel/fork.c1
-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/ksysfs.c4
-rw-r--r--kernel/kthread.c2
-rw-r--r--kernel/module.c202
-rw-r--r--kernel/params.c12
-rw-r--r--kernel/power/smp.c4
-rw-r--r--kernel/printk.c76
-rw-r--r--kernel/rcupdate.c5
-rw-r--r--kernel/rcutorture.c33
-rw-r--r--kernel/softlockup.c55
-rw-r--r--kernel/sys.c68
-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.debug16
-rw-r--r--lib/Makefile2
-rw-r--r--lib/bitmap.c163
-rw-r--r--lib/cpumask.c45
-rw-r--r--lib/radix-tree.c49
-rw-r--r--lib/swiotlb.c32
-rw-r--r--mm/Kconfig4
-rw-r--r--mm/bootmem.c2
-rw-r--r--mm/fadvise.c46
-rw-r--r--mm/filemap.c41
-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/slab.c351
-rw-r--r--mm/slob.c10
-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/skbuff.c2
-rw-r--r--net/core/sock.c5
-rw-r--r--net/dccp/proto.c2
-rw-r--r--net/ipv4/icmp.c2
-rw-r--r--net/ipv4/inet_hashtables.c2
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c2
-rw-r--r--net/ipv4/route.c45
-rw-r--r--net/ipv4/tcp.c28
-rw-r--r--net/netfilter/x_tables.c56
-rw-r--r--net/rxrpc/main.c2
-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/profile2linkerlist.pl21
-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/security.c23
-rw-r--r--sound/oss/.gitignore4
-rw-r--r--sound/oss/au1000.c2
-rw-r--r--sound/oss/au1550_ac97.c2
-rw-r--r--sound/oss/awe_wave.c6
-rw-r--r--sound/oss/dmasound/dmasound_core.c10
-rw-r--r--sound/oss/ite8172.c4
-rw-r--r--sound/oss/sb_mixer.c6
-rw-r--r--sound/oss/sequencer.c4
-rw-r--r--sound/oss/swarm_cs4297a.c4
-rw-r--r--sound/oss/waveartist.c8
-rw-r--r--sound/ppc/toonie.c4
-rw-r--r--sound/sparc/cs4231.c6
1047 files changed, 26140 insertions, 16959 deletions
diff --git a/CREDITS b/CREDITS
index af70678a0afd..c6d69bf10e15 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2007,13 +2007,14 @@ S: University of Stuttgart, Germany and
2007S: Ecole Nationale Superieure des Telecommunications, Paris 2007S: Ecole Nationale Superieure des Telecommunications, Paris
2008 2008
2009N: Jamie Lokier 2009N: Jamie Lokier
2010E: jamie@imbolc.ucc.ie 2010E: jamie@shareable.org
2011W: http://www.shareable.org/
2011D: Reboot-through-BIOS for broken 486 motherboards 2012D: Reboot-through-BIOS for broken 486 motherboards
2012D: Some parport fixes 2013D: Parport fixes, futex improvements
2013S: 11 Goodson Walk 2014D: First instruction of x86 sysenter path :)
2014S: Marston 2015S: 51 Sunningwell Road
2015S: Oxford 2016S: Oxford
2016S: OX3 0HX 2017S: OX1 4SZ
2017S: United Kingdom 2018S: United Kingdom
2018 2019
2019N: Mark Lord 2020N: Mark Lord
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 2975291e296a..7d87dd73cbe4 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -28,7 +28,7 @@ PS_METHOD = $(prefer-db2x)
28 28
29### 29###
30# The targets that may be used. 30# The targets that may be used.
31.PHONY: xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs 31PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
32 32
33BOOKS := $(addprefix $(obj)/,$(DOCBOOKS)) 33BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
34xmldocs: $(BOOKS) 34xmldocs: $(BOOKS)
@@ -211,3 +211,9 @@ clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS))
211 211
212#man put files in man subdir - traverse down 212#man put files in man subdir - traverse down
213subdir- := man/ 213subdir- := man/
214
215
216# Declare the contents of the .PHONY variable as phony. We keep that
217# information in a variable se we can use it in if_changed and friends.
218
219.PHONY: $(PHONY)
diff --git a/Documentation/DocBook/deviceiobook.tmpl b/Documentation/DocBook/deviceiobook.tmpl
index 6f41f2f5c6f6..90ed23df1f68 100644
--- a/Documentation/DocBook/deviceiobook.tmpl
+++ b/Documentation/DocBook/deviceiobook.tmpl
@@ -270,25 +270,6 @@ CPU B: spin_unlock_irqrestore(&dev_lock, flags)
270 </para> 270 </para>
271 </sect1> 271 </sect1>
272 272
273 <sect1>
274 <title>ISA legacy functions</title>
275 <para>
276 On older kernels (2.2 and earlier) the ISA bus could be read or
277 written with these functions and without ioremap being used. This is
278 no longer true in Linux 2.4. A set of equivalent functions exist for
279 easy legacy driver porting. The functions available are prefixed
280 with 'isa_' and are <function>isa_readb</function>,
281 <function>isa_writeb</function>, <function>isa_readw</function>,
282 <function>isa_writew</function>, <function>isa_readl</function>,
283 <function>isa_writel</function>, <function>isa_memcpy_fromio</function>
284 and <function>isa_memcpy_toio</function>
285 </para>
286 <para>
287 These functions should not be used in new drivers, and will
288 eventually be going away.
289 </para>
290 </sect1>
291
292 </chapter> 273 </chapter>
293 274
294 <chapter> 275 <chapter>
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index 5ed85af88789..b4ea51ad3610 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.
360 struct foo *new_fp; 360 struct foo *new_fp;
361 struct foo *old_fp; 361 struct foo *old_fp;
362 362
363 new_fp = kmalloc(sizeof(*fp), GFP_KERNEL); 363 new_fp = kmalloc(sizeof(*new_fp), GFP_KERNEL);
364 spin_lock(&foo_mutex); 364 spin_lock(&foo_mutex);
365 old_fp = gbl_foo; 365 old_fp = gbl_foo;
366 *new_fp = *old_fp; 366 *new_fp = *old_fp;
@@ -461,7 +461,7 @@ The foo_update_a() function might then be written as follows:
461 struct foo *new_fp; 461 struct foo *new_fp;
462 struct foo *old_fp; 462 struct foo *old_fp;
463 463
464 new_fp = kmalloc(sizeof(*fp), GFP_KERNEL); 464 new_fp = kmalloc(sizeof(*new_fp), GFP_KERNEL);
465 spin_lock(&foo_mutex); 465 spin_lock(&foo_mutex);
466 old_fp = gbl_foo; 466 old_fp = gbl_foo;
467 *new_fp = *old_fp; 467 *new_fp = *old_fp;
diff --git a/Documentation/arm/Booting b/Documentation/arm/Booting
index fad566bb02fc..76850295af8f 100644
--- a/Documentation/arm/Booting
+++ b/Documentation/arm/Booting
@@ -118,7 +118,7 @@ to store page tables. The recommended placement is 32KiB into RAM.
118 118
119In either case, the following conditions must be met: 119In either case, the following conditions must be met:
120 120
121- Quiesce all DMA capable devicess so that memory does not get 121- Quiesce all DMA capable devices so that memory does not get
122 corrupted by bogus network packets or disk data. This will save 122 corrupted by bogus network packets or disk data. This will save
123 you many hours of debug. 123 you many hours of debug.
124 124
diff --git a/Documentation/arm/README b/Documentation/arm/README
index 5ed6f3530b86..9b9c8226fdc4 100644
--- a/Documentation/arm/README
+++ b/Documentation/arm/README
@@ -89,7 +89,7 @@ Modules
89 Although modularisation is supported (and required for the FP emulator), 89 Although modularisation is supported (and required for the FP emulator),
90 each module on an ARM2/ARM250/ARM3 machine when is loaded will take 90 each module on an ARM2/ARM250/ARM3 machine when is loaded will take
91 memory up to the next 32k boundary due to the size of the pages. 91 memory up to the next 32k boundary due to the size of the pages.
92 Therefore, modularisation on these machines really worth it? 92 Therefore, is modularisation on these machines really worth it?
93 93
94 However, ARM6 and up machines allow modules to take multiples of 4k, and 94 However, ARM6 and up machines allow modules to take multiples of 4k, and
95 as such Acorn RiscPCs and other architectures using these processors can 95 as such Acorn RiscPCs and other architectures using these processors can
diff --git a/Documentation/arm/Setup b/Documentation/arm/Setup
index 0abd0720d7ed..0cb1e64bde80 100644
--- a/Documentation/arm/Setup
+++ b/Documentation/arm/Setup
@@ -58,7 +58,7 @@ below:
58 video_y 58 video_y
59 59
60 This describes the character position of cursor on VGA console, and 60 This describes the character position of cursor on VGA console, and
61 is otherwise unused. (should not used for other console types, and 61 is otherwise unused. (should not be used for other console types, and
62 should not be used for other purposes). 62 should not be used for other purposes).
63 63
64 memc_control_reg 64 memc_control_reg
diff --git a/Documentation/cpusets.txt b/Documentation/cpusets.txt
index 30c41459953c..159e2a0c3e80 100644
--- a/Documentation/cpusets.txt
+++ b/Documentation/cpusets.txt
@@ -18,7 +18,8 @@ CONTENTS:
18 1.4 What are exclusive cpusets ? 18 1.4 What are exclusive cpusets ?
19 1.5 What does notify_on_release do ? 19 1.5 What does notify_on_release do ?
20 1.6 What is memory_pressure ? 20 1.6 What is memory_pressure ?
21 1.7 How do I use cpusets ? 21 1.7 What is memory spread ?
22 1.8 How do I use cpusets ?
222. Usage Examples and Syntax 232. Usage Examples and Syntax
23 2.1 Basic Usage 24 2.1 Basic Usage
24 2.2 Adding/removing cpus 25 2.2 Adding/removing cpus
@@ -317,7 +318,78 @@ the tasks in the cpuset, in units of reclaims attempted per second,
317times 1000. 318times 1000.
318 319
319 320
3201.7 How do I use cpusets ? 3211.7 What is memory spread ?
322---------------------------
323There are two boolean flag files per cpuset that control where the
324kernel allocates pages for the file system buffers and related in
325kernel data structures. They are called 'memory_spread_page' and
326'memory_spread_slab'.
327
328If the per-cpuset boolean flag file 'memory_spread_page' is set, then
329the kernel will spread the file system buffers (page cache) evenly
330over all the nodes that the faulting task is allowed to use, instead
331of preferring to put those pages on the node where the task is running.
332
333If the per-cpuset boolean flag file 'memory_spread_slab' is set,
334then the kernel will spread some file system related slab caches,
335such as for inodes and dentries evenly over all the nodes that the
336faulting task is allowed to use, instead of preferring to put those
337pages on the node where the task is running.
338
339The setting of these flags does not affect anonymous data segment or
340stack segment pages of a task.
341
342By default, both kinds of memory spreading are off, and memory
343pages are allocated on the node local to where the task is running,
344except perhaps as modified by the tasks NUMA mempolicy or cpuset
345configuration, so long as sufficient free memory pages are available.
346
347When new cpusets are created, they inherit the memory spread settings
348of their parent.
349
350Setting memory spreading causes allocations for the affected page
351or slab caches to ignore the tasks NUMA mempolicy and be spread
352instead. Tasks using mbind() or set_mempolicy() calls to set NUMA
353mempolicies will not notice any change in these calls as a result of
354their containing tasks memory spread settings. If memory spreading
355is turned off, then the currently specified NUMA mempolicy once again
356applies to memory page allocations.
357
358Both 'memory_spread_page' and 'memory_spread_slab' are boolean flag
359files. By default they contain "0", meaning that the feature is off
360for that cpuset. If a "1" is written to that file, then that turns
361the named feature on.
362
363The implementation is simple.
364
365Setting the flag 'memory_spread_page' turns on a per-process flag
366PF_SPREAD_PAGE for each task that is in that cpuset or subsequently
367joins that cpuset. The page allocation calls for the page cache
368is modified to perform an inline check for this PF_SPREAD_PAGE task
369flag, and if set, a call to a new routine cpuset_mem_spread_node()
370returns the node to prefer for the allocation.
371
372Similarly, setting 'memory_spread_cache' turns on the flag
373PF_SPREAD_SLAB, and appropriately marked slab caches will allocate
374pages from the node returned by cpuset_mem_spread_node().
375
376The cpuset_mem_spread_node() routine is also simple. It uses the
377value of a per-task rotor cpuset_mem_spread_rotor to select the next
378node in the current tasks mems_allowed to prefer for the allocation.
379
380This memory placement policy is also known (in other contexts) as
381round-robin or interleave.
382
383This policy can provide substantial improvements for jobs that need
384to place thread local data on the corresponding node, but that need
385to access large file system data sets that need to be spread across
386the several nodes in the jobs cpuset in order to fit. Without this
387policy, especially for jobs that might have one thread reading in the
388data set, the memory allocation across the nodes in the jobs cpuset
389can become very uneven.
390
391
3921.8 How do I use cpusets ?
321-------------------------- 393--------------------------
322 394
323In order to minimize the impact of cpusets on critical kernel 395In 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 c7a4d0faab22..495858b236b6 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -116,6 +116,17 @@ Who: Harald Welte <laforge@netfilter.org>
116 116
117--------------------------- 117---------------------------
118 118
119What: remove EXPORT_SYMBOL(kernel_thread)
120When: August 2006
121Files: arch/*/kernel/*_ksyms.c
122Why: kernel_thread is a low-level implementation detail. Drivers should
123 use the <linux/kthread.h> API instead which shields them from
124 implementation details and provides a higherlevel interface that
125 prevents bugs and code duplication
126Who: Christoph Hellwig <hch@lst.de>
127
128---------------------------
129
119What: EXPORT_SYMBOL(lookup_hash) 130What: EXPORT_SYMBOL(lookup_hash)
120When: January 2006 131When: January 2006
121Why: Too low-level interface. Use lookup_one_len or lookup_create instead. 132Why: Too low-level interface. Use lookup_one_len or lookup_create instead.
@@ -165,6 +176,18 @@ Who: Richard Knutsson <ricknu-0@student.ltu.se> and Greg Kroah-Hartman <gregkh@s
165 176
166--------------------------- 177---------------------------
167 178
179What: Usage of invalid timevals in setitimer
180When: March 2007
181Why: POSIX requires to validate timevals in the setitimer call. This
182 was never done by Linux. The invalid (e.g. negative timevals) were
183 silently converted to more or less random timeouts and intervals.
184 Until the removal a per boot limited number of warnings is printed
185 and the timevals are sanitized.
186
187Who: Thomas Gleixner <tglx@linutronix.de>
188
189---------------------------
190
168What: I2C interface of the it87 driver 191What: I2C interface of the it87 driver
169When: January 2007 192When: January 2007
170Why: The ISA interface is faster and should be always available. The I2C 193Why: The ISA interface is faster and should be always available. The I2C
@@ -174,6 +197,17 @@ Who: Jean Delvare <khali@linux-fr.org>
174 197
175--------------------------- 198---------------------------
176 199
200What: remove EXPORT_SYMBOL(tasklist_lock)
201When: August 2006
202Files: kernel/fork.c
203Why: tasklist_lock protects the kernel internal task list. Modules have
204 no business looking at it, and all instances in drivers have been due
205 to use of too-lowlevel APIs. Having this symbol exported prevents
206 moving to more scalable locking schemes for the task list.
207Who: Christoph Hellwig <hch@lst.de>
208
209---------------------------
210
177What: mount/umount uevents 211What: mount/umount uevents
178When: February 2007 212When: February 2007
179Why: These events are not correct, and do not properly let userspace know 213Why: 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 24c7a9c41f0d..43b89c214d20 100644
--- a/Documentation/filesystems/v9fs.txt
+++ b/Documentation/filesystems/9p.txt
@@ -1,5 +1,5 @@
1 V9FS: 9P2000 for Linux 1 v9fs: Plan 9 Resource Sharing for Linux
2 ====================== 2 =======================================
3 3
4ABOUT 4ABOUT
5===== 5=====
@@ -9,18 +9,19 @@ v9fs is a Unix implementation of the Plan 9 9p remote filesystem protocol.
9This software was originally developed by Ron Minnich <rminnich@lanl.gov> 9This software was originally developed by Ron Minnich <rminnich@lanl.gov>
10and Maya Gokhale <maya@lanl.gov>. Additional development by Greg Watson 10and Maya Gokhale <maya@lanl.gov>. Additional development by Greg Watson
11<gwatson@lanl.gov> and most recently Eric Van Hensbergen 11<gwatson@lanl.gov> and most recently Eric Van Hensbergen
12<ericvh@gmail.com> and Latchesar Ionkov <lucho@ionkov.net>. 12<ericvh@gmail.com>, Latchesar Ionkov <lucho@ionkov.net> and Russ Cox
13<rsc@swtch.com>.
13 14
14USAGE 15USAGE
15===== 16=====
16 17
17For remote file server: 18For remote file server:
18 19
19 mount -t 9P 10.10.1.2 /mnt/9 20 mount -t 9p 10.10.1.2 /mnt/9
20 21
21For Plan 9 From User Space applications (http://swtch.com/plan9) 22For Plan 9 From User Space applications (http://swtch.com/plan9)
22 23
23 mount -t 9P `namespace`/acme /mnt/9 -o proto=unix,name=$USER 24 mount -t 9p `namespace`/acme /mnt/9 -o proto=unix,uname=$USER
24 25
25OPTIONS 26OPTIONS
26======= 27=======
@@ -32,7 +33,7 @@ OPTIONS
32 fd - used passed file descriptors for connection 33 fd - used passed file descriptors for connection
33 (see rfdno and wfdno) 34 (see rfdno and wfdno)
34 35
35 name=name user name to attempt mount as on the remote server. The 36 uname=name user name to attempt mount as on the remote server. The
36 server may override or ignore this value. Certain user 37 server may override or ignore this value. Certain user
37 names may require authentication. 38 names may require authentication.
38 39
@@ -42,7 +43,7 @@ OPTIONS
42 debug=n specifies debug level. The debug level is a bitmask. 43 debug=n specifies debug level. The debug level is a bitmask.
43 0x01 = display verbose error messages 44 0x01 = display verbose error messages
44 0x02 = developer debug (DEBUG_CURRENT) 45 0x02 = developer debug (DEBUG_CURRENT)
45 0x04 = display 9P trace 46 0x04 = display 9p trace
46 0x08 = display VFS trace 47 0x08 = display VFS trace
47 0x10 = display Marshalling debug 48 0x10 = display Marshalling debug
48 0x20 = display RPC debug 49 0x20 = display RPC debug
@@ -53,11 +54,11 @@ OPTIONS
53 54
54 wfdno=n the file descriptor for writing with proto=fd 55 wfdno=n the file descriptor for writing with proto=fd
55 56
56 maxdata=n the number of bytes to use for 9P packet payload (msize) 57 maxdata=n the number of bytes to use for 9p packet payload (msize)
57 58
58 port=n port to connect to on the remote server 59 port=n port to connect to on the remote server
59 60
60 noextend force legacy mode (no 9P2000.u semantics) 61 noextend force legacy mode (no 9p2000.u semantics)
61 62
62 uid attempt to mount as a particular uid 63 uid attempt to mount as a particular uid
63 64
@@ -72,7 +73,7 @@ OPTIONS
72RESOURCES 73RESOURCES
73========= 74=========
74 75
75The Linux version of the 9P server is now maintained under the npfs project 76The Linux version of the 9p server is now maintained under the npfs project
76on sourceforge (http://sourceforge.net/projects/npfs). 77on sourceforge (http://sourceforge.net/projects/npfs).
77 78
78There are user and developer mailing lists available through the v9fs project 79There are user and developer mailing lists available through the v9fs project
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 944cf109a6f5..99902ae6804e 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -121,7 +121,7 @@ Table 1-1: Process specific entries in /proc
121.............................................................................. 121..............................................................................
122 File Content 122 File Content
123 cmdline Command line arguments 123 cmdline Command line arguments
124 cpu Current and last cpu in wich it was executed (2.4)(smp) 124 cpu Current and last cpu in which it was executed (2.4)(smp)
125 cwd Link to the current working directory 125 cwd Link to the current working directory
126 environ Values of environment variables 126 environ Values of environment variables
127 exe Link to the executable of this process 127 exe Link to the executable of this process
@@ -309,13 +309,13 @@ is the same by default:
309 > cat /proc/irq/0/smp_affinity 309 > cat /proc/irq/0/smp_affinity
310 ffffffff 310 ffffffff
311 311
312It's a bitmask, in wich you can specify wich CPUs can handle the IRQ, you can 312It's a bitmask, in which you can specify which CPUs can handle the IRQ, you can
313set it by doing: 313set it by doing:
314 314
315 > echo 1 > /proc/irq/prof_cpu_mask 315 > echo 1 > /proc/irq/prof_cpu_mask
316 316
317This means that only the first CPU will handle the IRQ, but you can also echo 5 317This means that only the first CPU will handle the IRQ, but you can also echo 5
318wich means that only the first and fourth CPU can handle the IRQ. 318which means that only the first and fourth CPU can handle the IRQ.
319 319
320The way IRQs are routed is handled by the IO-APIC, and it's Round Robin 320The way IRQs are routed is handled by the IO-APIC, and it's Round Robin
321between all the CPUs which are allowed to handle it. As usual the kernel has 321between 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 e5213bc301f7..511b4230c053 100644
--- a/Documentation/filesystems/udf.txt
+++ b/Documentation/filesystems/udf.txt
@@ -26,6 +26,20 @@ The following mount options are supported:
26 nostrict Unset strict conformance 26 nostrict Unset strict conformance
27 iocharset= Set the NLS character set 27 iocharset= Set the NLS character set
28 28
29The uid= and gid= options need a bit more explaining. They will accept a
30decimal numeric value which will be used as the default ID for that mount.
31They will also accept the string "ignore" and "forget". For files on the disk
32that are owned by nobody ( -1 ), they will instead look as if they are owned
33by the default ID. The ignore option causes the default ID to override all
34IDs on the disk, not just -1. The forget option causes all IDs to be written
35to disk as -1, so when the media is later remounted, they will appear to be
36owned by whatever default ID it is mounted with at that time.
37
38For typical desktop use of removable media, you should set the ID to that
39of the interactively logged on user, and also specify both the forget and
40ignore options. This way the interactive user will always see the files
41on the disk as belonging to him.
42
29The remaining are for debugging and disaster recovery: 43The remaining are for debugging and disaster recovery:
30 44
31 novrs Skip volume sequence recognition 45 novrs Skip volume sequence recognition
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index e56e842847d3..adaa899e5c90 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
230or bottom half). 230or bottom half).
231 231
232 alloc_inode: this method is called by inode_alloc() to allocate memory 232 alloc_inode: this method is called by inode_alloc() to allocate memory
233 for struct inode and initialize it. 233 for struct inode and initialize it. If this function is not
234 defined, a simple 'struct inode' is allocated. Normally
235 alloc_inode will be used to allocate a larger structure which
236 contains a 'struct inode' embedded within it.
234 237
235 destroy_inode: this method is called by destroy_inode() to release 238 destroy_inode: this method is called by destroy_inode() to release
236 resources allocated for struct inode. 239 resources allocated for struct inode. It is only required if
240 ->alloc_inode was defined and simply undoes anything done by
241 ->alloc_inode.
237 242
238 read_inode: this method is called to read a specific inode from the 243 read_inode: this method is called to read a specific inode from the
239 mounted filesystem. The i_ino member in the struct inode is 244 mounted filesystem. The i_ino member in the struct inode is
@@ -443,14 +448,81 @@ otherwise noted.
443The Address Space Object 448The Address Space Object
444======================== 449========================
445 450
446The address space object is used to identify pages in the page cache. 451The address space object is used to group and manage pages in the page
447 452cache. It can be used to keep track of the pages in a file (or
453anything else) and also track the mapping of sections of the file into
454process address spaces.
455
456There are a number of distinct yet related services that an
457address-space can provide. These include communicating memory
458pressure, page lookup by address, and keeping track of pages tagged as
459Dirty or Writeback.
460
461The first can be used independently to the others. The VM can try to
462either write dirty pages in order to clean them, or release clean
463pages in order to reuse them. To do this it can call the ->writepage
464method on dirty pages, and ->releasepage on clean pages with
465PagePrivate set. Clean pages without PagePrivate and with no external
466references will be released without notice being given to the
467address_space.
468
469To achieve this functionality, pages need to be placed on an LRU with
470lru_cache_add and mark_page_active needs to be called whenever the
471page is used.
472
473Pages are normally kept in a radix tree index by ->index. This tree
474maintains information about the PG_Dirty and PG_Writeback status of
475each page, so that pages with either of these flags can be found
476quickly.
477
478The Dirty tag is primarily used by mpage_writepages - the default
479->writepages method. It uses the tag to find dirty pages to call
480->writepage on. If mpage_writepages is not used (i.e. the address
481provides its own ->writepages) , the PAGECACHE_TAG_DIRTY tag is
482almost unused. write_inode_now and sync_inode do use it (through
483__sync_single_inode) to check if ->writepages has been successful in
484writing out the whole address_space.
485
486The Writeback tag is used by filemap*wait* and sync_page* functions,
487via wait_on_page_writeback_range, to wait for all writeback to
488complete. While waiting ->sync_page (if defined) will be called on
489each page that is found to require writeback.
490
491An address_space handler may attach extra information to a page,
492typically using the 'private' field in the 'struct page'. If such
493information is attached, the PG_Private flag should be set. This will
494cause various VM routines to make extra calls into the address_space
495handler to deal with that data.
496
497An address space acts as an intermediate between storage and
498application. Data is read into the address space a whole page at a
499time, and provided to the application either by copying of the page,
500or by memory-mapping the page.
501Data is written into the address space by the application, and then
502written-back to storage typically in whole pages, however the
503address_space has finer control of write sizes.
504
505The read process essentially only requires 'readpage'. The write
506process is more complicated and uses prepare_write/commit_write or
507set_page_dirty to write data into the address_space, and writepage,
508sync_page, and writepages to writeback data to storage.
509
510Adding and removing pages to/from an address_space is protected by the
511inode's i_mutex.
512
513When data is written to a page, the PG_Dirty flag should be set. It
514typically remains set until writepage asks for it to be written. This
515should clear PG_Dirty and set PG_Writeback. It can be actually
516written at any point after PG_Dirty is clear. Once it is known to be
517safe, PG_Writeback is cleared.
518
519Writeback makes use of a writeback_control structure...
448 520
449struct address_space_operations 521struct address_space_operations
450------------------------------- 522-------------------------------
451 523
452This describes how the VFS can manipulate mapping of a file to page cache in 524This describes how the VFS can manipulate mapping of a file to page cache in
453your filesystem. As of kernel 2.6.13, the following members are defined: 525your filesystem. As of kernel 2.6.16, the following members are defined:
454 526
455struct address_space_operations { 527struct address_space_operations {
456 int (*writepage)(struct page *page, struct writeback_control *wbc); 528 int (*writepage)(struct page *page, struct writeback_control *wbc);
@@ -469,47 +541,148 @@ struct address_space_operations {
469 loff_t offset, unsigned long nr_segs); 541 loff_t offset, unsigned long nr_segs);
470 struct page* (*get_xip_page)(struct address_space *, sector_t, 542 struct page* (*get_xip_page)(struct address_space *, sector_t,
471 int); 543 int);
544 /* migrate the contents of a page to the specified target */
545 int (*migratepage) (struct page *, struct page *);
472}; 546};
473 547
474 writepage: called by the VM write a dirty page to backing store. 548 writepage: called by the VM to write a dirty page to backing store.
549 This may happen for data integrity reasons (i.e. 'sync'), or
550 to free up memory (flush). The difference can be seen in
551 wbc->sync_mode.
552 The PG_Dirty flag has been cleared and PageLocked is true.
553 writepage should start writeout, should set PG_Writeback,
554 and should make sure the page is unlocked, either synchronously
555 or asynchronously when the write operation completes.
556
557 If wbc->sync_mode is WB_SYNC_NONE, ->writepage doesn't have to
558 try too hard if there are problems, and may choose to write out
559 other pages from the mapping if that is easier (e.g. due to
560 internal dependencies). If it chooses not to start writeout, it
561 should return AOP_WRITEPAGE_ACTIVATE so that the VM will not keep
562 calling ->writepage on that page.
563
564 See the file "Locking" for more details.
475 565
476 readpage: called by the VM to read a page from backing store. 566 readpage: called by the VM to read a page from backing store.
567 The page will be Locked when readpage is called, and should be
568 unlocked and marked uptodate once the read completes.
569 If ->readpage discovers that it needs to unlock the page for
570 some reason, it can do so, and then return AOP_TRUNCATED_PAGE.
571 In this case, the page will be relocated, relocked and if
572 that all succeeds, ->readpage will be called again.
477 573
478 sync_page: called by the VM to notify the backing store to perform all 574 sync_page: called by the VM to notify the backing store to perform all
479 queued I/O operations for a page. I/O operations for other pages 575 queued I/O operations for a page. I/O operations for other pages
480 associated with this address_space object may also be performed. 576 associated with this address_space object may also be performed.
481 577
578 This function is optional and is called only for pages with
579 PG_Writeback set while waiting for the writeback to complete.
580
482 writepages: called by the VM to write out pages associated with the 581 writepages: called by the VM to write out pages associated with the
483 address_space object. 582 address_space object. If wbc->sync_mode is WBC_SYNC_ALL, then
583 the writeback_control will specify a range of pages that must be
584 written out. If it is WBC_SYNC_NONE, then a nr_to_write is given
585 and that many pages should be written if possible.
586 If no ->writepages is given, then mpage_writepages is used
587 instead. This will choose pages from the address space that are
588 tagged as DIRTY and will pass them to ->writepage.
484 589
485 set_page_dirty: called by the VM to set a page dirty. 590 set_page_dirty: called by the VM to set a page dirty.
591 This is particularly needed if an address space attaches
592 private data to a page, and that data needs to be updated when
593 a page is dirtied. This is called, for example, when a memory
594 mapped page gets modified.
595 If defined, it should set the PageDirty flag, and the
596 PAGECACHE_TAG_DIRTY tag in the radix tree.
486 597
487 readpages: called by the VM to read pages associated with the address_space 598 readpages: called by the VM to read pages associated with the address_space
488 object. 599 object. This is essentially just a vector version of
600 readpage. Instead of just one page, several pages are
601 requested.
602 readpages is only used for read-ahead, so read errors are
603 ignored. If anything goes wrong, feel free to give up.
489 604
490 prepare_write: called by the generic write path in VM to set up a write 605 prepare_write: called by the generic write path in VM to set up a write
491 request for a page. 606 request for a page. This indicates to the address space that
492 607 the given range of bytes is about to be written. The
493 commit_write: called by the generic write path in VM to write page to 608 address_space should check that the write will be able to
494 its backing store. 609 complete, by allocating space if necessary and doing any other
610 internal housekeeping. If the write will update parts of
611 any basic-blocks on storage, then those blocks should be
612 pre-read (if they haven't been read already) so that the
613 updated blocks can be written out properly.
614 The page will be locked. If prepare_write wants to unlock the
615 page it, like readpage, may do so and return
616 AOP_TRUNCATED_PAGE.
617 In this case the prepare_write will be retried one the lock is
618 regained.
619
620 commit_write: If prepare_write succeeds, new data will be copied
621 into the page and then commit_write will be called. It will
622 typically update the size of the file (if appropriate) and
623 mark the inode as dirty, and do any other related housekeeping
624 operations. It should avoid returning an error if possible -
625 errors should have been handled by prepare_write.
495 626
496 bmap: called by the VFS to map a logical block offset within object to 627 bmap: called by the VFS to map a logical block offset within object to
497 physical block number. This method is use by for the legacy FIBMAP 628 physical block number. This method is used by the FIBMAP
498 ioctl. Other uses are discouraged. 629 ioctl and for working with swap-files. To be able to swap to
499 630 a file, the file must have a stable mapping to a block
500 invalidatepage: called by the VM on truncate to disassociate a page from its 631 device. The swap system does not go through the filesystem
501 address_space mapping. 632 but instead uses bmap to find out where the blocks in the file
502 633 are and uses those addresses directly.
503 releasepage: called by the VFS to release filesystem specific metadata from 634
504 a page. 635
505 636 invalidatepage: If a page has PagePrivate set, then invalidatepage
506 direct_IO: called by the VM for direct I/O writes and reads. 637 will be called when part or all of the page is to be removed
638 from the address space. This generally corresponds to either a
639 truncation or a complete invalidation of the address space
640 (in the latter case 'offset' will always be 0).
641 Any private data associated with the page should be updated
642 to reflect this truncation. If offset is 0, then
643 the private data should be released, because the page
644 must be able to be completely discarded. This may be done by
645 calling the ->releasepage function, but in this case the
646 release MUST succeed.
647
648 releasepage: releasepage is called on PagePrivate pages to indicate
649 that the page should be freed if possible. ->releasepage
650 should remove any private data from the page and clear the
651 PagePrivate flag. It may also remove the page from the
652 address_space. If this fails for some reason, it may indicate
653 failure with a 0 return value.
654 This is used in two distinct though related cases. The first
655 is when the VM finds a clean page with no active users and
656 wants to make it a free page. If ->releasepage succeeds, the
657 page will be removed from the address_space and become free.
658
659 The second case if when a request has been made to invalidate
660 some or all pages in an address_space. This can happen
661 through the fadvice(POSIX_FADV_DONTNEED) system call or by the
662 filesystem explicitly requesting it as nfs and 9fs do (when
663 they believe the cache may be out of date with storage) by
664 calling invalidate_inode_pages2().
665 If the filesystem makes such a call, and needs to be certain
666 that all pages are invalidated, then its releasepage will
667 need to ensure this. Possibly it can clear the PageUptodate
668 bit if it cannot free private data yet.
669
670 direct_IO: called by the generic read/write routines to perform
671 direct_IO - that is IO requests which bypass the page cache
672 and transfer data directly between the storage and the
673 application's address space.
507 674
508 get_xip_page: called by the VM to translate a block number to a page. 675 get_xip_page: called by the VM to translate a block number to a page.
509 The page is valid until the corresponding filesystem is unmounted. 676 The page is valid until the corresponding filesystem is unmounted.
510 Filesystems that want to use execute-in-place (XIP) need to implement 677 Filesystems that want to use execute-in-place (XIP) need to implement
511 it. An example implementation can be found in fs/ext2/xip.c. 678 it. An example implementation can be found in fs/ext2/xip.c.
512 679
680 migrate_page: This is used to compact the physical memory usage.
681 If the VM wants to relocate a page (maybe off a memory card
682 that is signalling imminent failure) it will pass a new page
683 and an old page to this function. migrate_page should
684 transfer any private data across and update any references
685 that it has to the page.
513 686
514The File Object 687The File Object
515=============== 688===============
diff --git a/Documentation/firmware_class/firmware_sample_driver.c b/Documentation/firmware_class/firmware_sample_driver.c
index d3ad2c24490a..ad3edaba4533 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";
23#endif 23#endif
24 24
25static struct device ghost_device = { 25static struct device ghost_device = {
26 .name = "Ghost Device",
27 .bus_id = "ghost0", 26 .bus_id = "ghost0",
28}; 27};
29 28
@@ -92,7 +91,7 @@ static void sample_probe_async(void)
92{ 91{
93 /* Let's say that I can't sleep */ 92 /* Let's say that I can't sleep */
94 int error; 93 int error;
95 error = request_firmware_nowait (THIS_MODULE, 94 error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG,
96 "sample_driver_fw", &ghost_device, 95 "sample_driver_fw", &ghost_device,
97 "my device pointer", 96 "my device pointer",
98 sample_probe_async_cont); 97 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 57b956aecbc5..9e1b0e4051cd 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)
172static struct class_device *class_dev; 172static struct class_device *class_dev;
173 173
174static struct device my_device = { 174static struct device my_device = {
175 .name = "Sample Device",
176 .bus_id = "my_dev0", 175 .bus_id = "my_dev0",
177}; 176};
178 177
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 443230b43e09..a9c00facdf40 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -17,6 +17,7 @@ This document describes the Linux kernel Makefiles.
17 --- 3.8 Command line dependency 17 --- 3.8 Command line dependency
18 --- 3.9 Dependency tracking 18 --- 3.9 Dependency tracking
19 --- 3.10 Special Rules 19 --- 3.10 Special Rules
20 --- 3.11 $(CC) support functions
20 21
21 === 4 Host Program support 22 === 4 Host Program support
22 --- 4.1 Simple Host Program 23 --- 4.1 Simple Host Program
@@ -38,7 +39,6 @@ This document describes the Linux kernel Makefiles.
38 --- 6.6 Commands useful for building a boot image 39 --- 6.6 Commands useful for building a boot image
39 --- 6.7 Custom kbuild commands 40 --- 6.7 Custom kbuild commands
40 --- 6.8 Preprocessing linker scripts 41 --- 6.8 Preprocessing linker scripts
41 --- 6.9 $(CC) support functions
42 42
43 === 7 Kbuild Variables 43 === 7 Kbuild Variables
44 === 8 Makefile language 44 === 8 Makefile language
@@ -106,9 +106,9 @@ This document is aimed towards normal developers and arch developers.
106Most Makefiles within the kernel are kbuild Makefiles that use the 106Most Makefiles within the kernel are kbuild Makefiles that use the
107kbuild infrastructure. This chapter introduce the syntax used in the 107kbuild infrastructure. This chapter introduce the syntax used in the
108kbuild makefiles. 108kbuild makefiles.
109The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will 109The preferred name for the kbuild files are 'Makefile' but 'Kbuild' can
110continue to be supported. All new developmen is expected to use the 110be used and if both a 'Makefile' and a 'Kbuild' file exists then the 'Kbuild'
111Kbuild filename. 111file will be used.
112 112
113Section 3.1 "Goal definitions" is a quick intro, further chapters provide 113Section 3.1 "Goal definitions" is a quick intro, further chapters provide
114more details, with real examples. 114more details, with real examples.
@@ -385,6 +385,102 @@ more details, with real examples.
385 to prerequisites are referenced with $(src) (because they are not 385 to prerequisites are referenced with $(src) (because they are not
386 generated files). 386 generated files).
387 387
388--- 3.11 $(CC) support functions
389
390 The kernel may be build with several different versions of
391 $(CC), each supporting a unique set of features and options.
392 kbuild provide basic support to check for valid options for $(CC).
393 $(CC) is useally the gcc compiler, but other alternatives are
394 available.
395
396 as-option
397 as-option is used to check if $(CC) when used to compile
398 assembler (*.S) files supports the given option. An optional
399 second option may be specified if first option are not supported.
400
401 Example:
402 #arch/sh/Makefile
403 cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
404
405 In the above example cflags-y will be assinged the the option
406 -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC).
407 The second argument is optional, and if supplied will be used
408 if first argument is not supported.
409
410 cc-option
411 cc-option is used to check if $(CC) support a given option, and not
412 supported to use an optional second option.
413
414 Example:
415 #arch/i386/Makefile
416 cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
417
418 In the above example cflags-y will be assigned the option
419 -march=pentium-mmx if supported by $(CC), otherwise -march-i586.
420 The second argument to cc-option is optional, and if omitted
421 cflags-y will be assigned no value if first option is not supported.
422
423 cc-option-yn
424 cc-option-yn is used to check if gcc supports a given option
425 and return 'y' if supported, otherwise 'n'.
426
427 Example:
428 #arch/ppc/Makefile
429 biarch := $(call cc-option-yn, -m32)
430 aflags-$(biarch) += -a32
431 cflags-$(biarch) += -m32
432
433 In the above example $(biarch) is set to y if $(CC) supports the -m32
434 option. When $(biarch) equals to y the expanded variables $(aflags-y)
435 and $(cflags-y) will be assigned the values -a32 and -m32.
436
437 cc-option-align
438 gcc version >= 3.0 shifted type of options used to speify
439 alignment of functions, loops etc. $(cc-option-align) whrn used
440 as prefix to the align options will select the right prefix:
441 gcc < 3.00
442 cc-option-align = -malign
443 gcc >= 3.00
444 cc-option-align = -falign
445
446 Example:
447 CFLAGS += $(cc-option-align)-functions=4
448
449 In the above example the option -falign-functions=4 is used for
450 gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
451
452 cc-version
453 cc-version return a numerical version of the $(CC) compiler version.
454 The format is <major><minor> where both are two digits. So for example
455 gcc 3.41 would return 0341.
456 cc-version is useful when a specific $(CC) version is faulty in one
457 area, for example the -mregparm=3 were broken in some gcc version
458 even though the option was accepted by gcc.
459
460 Example:
461 #arch/i386/Makefile
462 cflags-y += $(shell \
463 if [ $(call cc-version) -ge 0300 ] ; then \
464 echo "-mregparm=3"; fi ;)
465
466 In the above example -mregparm=3 is only used for gcc version greater
467 than or equal to gcc 3.0.
468
469 cc-ifversion
470 cc-ifversion test the version of $(CC) and equals last argument if
471 version expression is true.
472
473 Example:
474 #fs/reiserfs/Makefile
475 EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1)
476
477 In this example EXTRA_CFLAGS will be assigned the value -O1 if the
478 $(CC) version is less than 4.2.
479 cc-ifversion takes all the shell operators:
480 -eq, -ne, -lt, -le, -gt, and -ge
481 The third parameter may be a text as in this example, but it may also
482 be an expanded variable or a macro.
483
388 484
389=== 4 Host Program support 485=== 4 Host Program support
390 486
@@ -973,74 +1069,6 @@ When kbuild executes the following steps are followed (roughly):
973 architecture specific files. 1069 architecture specific files.
974 1070
975 1071
976--- 6.9 $(CC) support functions
977
978 The kernel may be build with several different versions of
979 $(CC), each supporting a unique set of features and options.
980 kbuild provide basic support to check for valid options for $(CC).
981 $(CC) is useally the gcc compiler, but other alternatives are
982 available.
983
984 cc-option
985 cc-option is used to check if $(CC) support a given option, and not
986 supported to use an optional second option.
987
988 Example:
989 #arch/i386/Makefile
990 cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
991
992 In the above example cflags-y will be assigned the option
993 -march=pentium-mmx if supported by $(CC), otherwise -march-i586.
994 The second argument to cc-option is optional, and if omitted
995 cflags-y will be assigned no value if first option is not supported.
996
997 cc-option-yn
998 cc-option-yn is used to check if gcc supports a given option
999 and return 'y' if supported, otherwise 'n'.
1000
1001 Example:
1002 #arch/ppc/Makefile
1003 biarch := $(call cc-option-yn, -m32)
1004 aflags-$(biarch) += -a32
1005 cflags-$(biarch) += -m32
1006
1007 In the above example $(biarch) is set to y if $(CC) supports the -m32
1008 option. When $(biarch) equals to y the expanded variables $(aflags-y)
1009 and $(cflags-y) will be assigned the values -a32 and -m32.
1010
1011 cc-option-align
1012 gcc version >= 3.0 shifted type of options used to speify
1013 alignment of functions, loops etc. $(cc-option-align) whrn used
1014 as prefix to the align options will select the right prefix:
1015 gcc < 3.00
1016 cc-option-align = -malign
1017 gcc >= 3.00
1018 cc-option-align = -falign
1019
1020 Example:
1021 CFLAGS += $(cc-option-align)-functions=4
1022
1023 In the above example the option -falign-functions=4 is used for
1024 gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
1025
1026 cc-version
1027 cc-version return a numerical version of the $(CC) compiler version.
1028 The format is <major><minor> where both are two digits. So for example
1029 gcc 3.41 would return 0341.
1030 cc-version is useful when a specific $(CC) version is faulty in one
1031 area, for example the -mregparm=3 were broken in some gcc version
1032 even though the option was accepted by gcc.
1033
1034 Example:
1035 #arch/i386/Makefile
1036 cflags-y += $(shell \
1037 if [ $(call cc-version) -ge 0300 ] ; then \
1038 echo "-mregparm=3"; fi ;)
1039
1040 In the above example -mregparm=3 is only used for gcc version greater
1041 than or equal to gcc 3.0.
1042
1043
1044=== 7 Kbuild Variables 1072=== 7 Kbuild Variables
1045 1073
1046The top Makefile exports the following variables: 1074The top Makefile exports the following variables:
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index 7e77f93634ea..fcccf2432f98 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -13,6 +13,7 @@ In this document you will find information about:
13 --- 2.2 Available targets 13 --- 2.2 Available targets
14 --- 2.3 Available options 14 --- 2.3 Available options
15 --- 2.4 Preparing the kernel tree for module build 15 --- 2.4 Preparing the kernel tree for module build
16 --- 2.5 Building separate files for a module
16 === 3. Example commands 17 === 3. Example commands
17 === 4. Creating a kbuild file for an external module 18 === 4. Creating a kbuild file for an external module
18 === 5. Include files 19 === 5. Include files
@@ -22,7 +23,10 @@ In this document you will find information about:
22 === 6. Module installation 23 === 6. Module installation
23 --- 6.1 INSTALL_MOD_PATH 24 --- 6.1 INSTALL_MOD_PATH
24 --- 6.2 INSTALL_MOD_DIR 25 --- 6.2 INSTALL_MOD_DIR
25 === 7. Module versioning 26 === 7. Module versioning & Module.symvers
27 --- 7.1 Symbols fron the kernel (vmlinux + modules)
28 --- 7.2 Symbols and external modules
29 --- 7.3 Symbols from another external module
26 === 8. Tips & Tricks 30 === 8. Tips & Tricks
27 --- 8.1 Testing for CONFIG_FOO_BAR 31 --- 8.1 Testing for CONFIG_FOO_BAR
28 32
@@ -88,7 +92,8 @@ when building an external module.
88 make -C $KDIR M=$PWD modules_install 92 make -C $KDIR M=$PWD modules_install
89 Install the external module(s). 93 Install the external module(s).
90 Installation default is in /lib/modules/<kernel-version>/extra, 94 Installation default is in /lib/modules/<kernel-version>/extra,
91 but may be prefixed with INSTALL_MOD_PATH - see separate chapter. 95 but may be prefixed with INSTALL_MOD_PATH - see separate
96 chapter.
92 97
93 make -C $KDIR M=$PWD clean 98 make -C $KDIR M=$PWD clean
94 Remove all generated files for the module - the kernel 99 Remove all generated files for the module - the kernel
@@ -131,6 +136,16 @@ when building an external module.
131 Therefore a full kernel build needs to be executed to make 136 Therefore a full kernel build needs to be executed to make
132 module versioning work. 137 module versioning work.
133 138
139--- 2.5 Building separate files for a module
140 It is possible to build single files which is part of a module.
141 This works equal for the kernel, a module and even for external
142 modules.
143 Examples (module foo.ko, consist of bar.o, baz.o):
144 make -C $KDIR M=`pwd` bar.lst
145 make -C $KDIR M=`pwd` bar.o
146 make -C $KDIR M=`pwd` foo.ko
147 make -C $KDIR M=`pwd` /
148
134 149
135=== 3. Example commands 150=== 3. Example commands
136 151
@@ -422,7 +437,7 @@ External modules are installed in the directory:
422 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf 437 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
423 438
424 439
425=== 7. Module versioning 440=== 7. Module versioning & Module.symvers
426 441
427Module versioning is enabled by the CONFIG_MODVERSIONS tag. 442Module versioning is enabled by the CONFIG_MODVERSIONS tag.
428 443
@@ -432,11 +447,80 @@ when a module is loaded/used then the CRC values contained in the kernel are
432compared with similar values in the module. If they are not equal then the 447compared with similar values in the module. If they are not equal then the
433kernel refuses to load the module. 448kernel refuses to load the module.
434 449
435During a kernel build a file named Module.symvers will be generated. This 450Module.symvers contains a list of all exported symbols from a kernel build.
436file includes the symbol version of all symbols within the kernel. If the 451
437Module.symvers file is saved from the last full kernel compile one does not 452--- 7.1 Symbols fron the kernel (vmlinux + modules)
438have to do a full kernel compile to build a module version's compatible module. 453
454 During a kernel build a file named Module.symvers will be generated.
455 Module.symvers contains all exported symbols from the kernel and
456 compiled modules. For each symbols the corresponding CRC value
457 is stored too.
458
459 The syntax of the Module.symvers file is:
460 <CRC> <Symbol> <module>
461 Sample:
462 0x2d036834 scsi_remove_host drivers/scsi/scsi_mod
439 463
464 For a kernel build without CONFIG_MODVERSIONING enabled the crc
465 would read: 0x00000000
466
467 Module.symvers serve two purposes.
468 1) It list all exported symbols both from vmlinux and all modules
469 2) It list CRC if CONFIG_MODVERSION is enabled
470
471--- 7.2 Symbols and external modules
472
473 When building an external module the build system needs access to
474 the symbols from the kernel to check if all external symbols are
475 defined. This is done in the MODPOST step and to obtain all
476 symbols modpost reads Module.symvers from the kernel.
477 If a Module.symvers file is present in the directory where
478 the external module is being build this file will be read too.
479 During the MODPOST step a new Module.symvers file will be written
480 containing all exported symbols that was not defined in the kernel.
481
482--- 7.3 Symbols from another external module
483
484 Sometimes one external module uses exported symbols from another
485 external module. Kbuild needs to have full knowledge on all symbols
486 to avoid spitting out warnings about undefined symbols.
487 Two solutions exist to let kbuild know all symbols of more than
488 one external module.
489 The method with a top-level kbuild file is recommended but may be
490 impractical in certain situations.
491
492 Use a top-level Kbuild file
493 If you have two modules: 'foo', 'bar' and 'foo' needs symbols
494 from 'bar' then one can use a common top-level kbuild file so
495 both modules are compiled in same build.
496
497 Consider following directory layout:
498 ./foo/ <= contains the foo module
499 ./bar/ <= contains the bar module
500 The top-level Kbuild file would then look like:
501
502 #./Kbuild: (this file may also be named Makefile)
503 obj-y := foo/ bar/
504
505 Executing:
506 make -C $KDIR M=`pwd`
507
508 will then do the expected and compile both modules with full
509 knowledge on symbols from both modules.
510
511 Use an extra Module.symvers file
512 When an external module is build a Module.symvers file is
513 generated containing all exported symbols which are not
514 defined in the kernel.
515 To get access to symbols from module 'bar' one can copy the
516 Module.symvers file from the compilation of the 'bar' module
517 to the directory where the 'foo' module is build.
518 During the module build kbuild will read the Module.symvers
519 file in the directory of the external module and when the
520 build is finished a new Module.symvers file is created
521 containing the sum of all symbols defined and not part of the
522 kernel.
523
440=== 8. Tips & Tricks 524=== 8. Tips & Tricks
441 525
442--- 8.1 Testing for CONFIG_FOO_BAR 526--- 8.1 Testing for CONFIG_FOO_BAR
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 44a25f3f51d1..f8cb55c30b0f 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -367,12 +367,17 @@ running once the system is up.
367 tty<n> Use the virtual console device <n>. 367 tty<n> Use the virtual console device <n>.
368 368
369 ttyS<n>[,options] 369 ttyS<n>[,options]
370 ttyUSB0[,options]
370 Use the specified serial port. The options are of 371 Use the specified serial port. The options are of
371 the form "bbbbpn", where "bbbb" is the baud rate, 372 the form "bbbbpnf", where "bbbb" is the baud rate,
372 "p" is parity ("n", "o", or "e"), and "n" is bits. 373 "p" is parity ("n", "o", or "e"), "n" is number of
373 Default is "9600n8". 374 bits, and "f" is flow control ("r" for RTS or
374 375 omit it). Default is "9600n8".
375 See also Documentation/serial-console.txt. 376
377 See Documentation/serial-console.txt for more
378 information. See
379 Documentation/networking/netconsole.txt for an
380 alternative.
376 381
377 uart,io,<addr>[,options] 382 uart,io,<addr>[,options]
378 uart,mmio,<addr>[,options] 383 uart,mmio,<addr>[,options]
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index 8d4cf78258e4..4fc8e9874320 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
40+ How to use CONFIG_PACKET_MMAP 40+ How to use CONFIG_PACKET_MMAP
41-------------------------------------------------------------------------------- 41--------------------------------------------------------------------------------
42 42
43From the user standpoint, you should use the higher level libpcap library, wich 43From the user standpoint, you should use the higher level libpcap library, which
44is a de facto standard, portable across nearly all operating systems 44is a de facto standard, portable across nearly all operating systems
45including Win32. 45including Win32.
46 46
@@ -217,8 +217,8 @@ called pg_vec, its size limits the number of blocks that can be allocated.
217 217
218kmalloc allocates any number of bytes of phisically contiguous memory from 218kmalloc allocates any number of bytes of phisically contiguous memory from
219a pool of pre-determined sizes. This pool of memory is mantained by the slab 219a pool of pre-determined sizes. This pool of memory is mantained by the slab
220allocator wich is at the end the responsible for doing the allocation and 220allocator which is at the end the responsible for doing the allocation and
221hence wich imposes the maximum memory that kmalloc can allocate. 221hence which imposes the maximum memory that kmalloc can allocate.
222 222
223In a 2.4/2.6 kernel and the i386 architecture, the limit is 131072 bytes. The 223In a 2.4/2.6 kernel and the i386 architecture, the limit is 131072 bytes. The
224predetermined sizes that kmalloc uses can be checked in the "size-<bytes>" 224predetermined sizes that kmalloc uses can be checked in the "size-<bytes>"
@@ -254,7 +254,7 @@ and, the number of frames be
254 254
255 <block number> * <block size> / <frame size> 255 <block number> * <block size> / <frame size>
256 256
257Suposse the following parameters, wich apply for 2.6 kernel and an 257Suposse the following parameters, which apply for 2.6 kernel and an
258i386 architecture: 258i386 architecture:
259 259
260 <size-max> = 131072 bytes 260 <size-max> = 131072 bytes
@@ -360,7 +360,7 @@ TP_STATUS_LOSING : indicates there were packet drops from last time
360 statistics where checked with getsockopt() and 360 statistics where checked with getsockopt() and
361 the PACKET_STATISTICS option. 361 the PACKET_STATISTICS option.
362 362
363TP_STATUS_CSUMNOTREADY: currently it's used for outgoing IP packets wich 363TP_STATUS_CSUMNOTREADY: currently it's used for outgoing IP packets which
364 it's checksum will be done in hardware. So while 364 it's checksum will be done in hardware. So while
365 reading the packet we should not try to check the 365 reading the packet we should not try to check the
366 checksum. 366 checksum.
diff --git a/Documentation/networking/ray_cs.txt b/Documentation/networking/ray_cs.txt
index 5427f8c7df95..145d27a52395 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.
25This will change after the method of sorting out parameters for all 25This will change after the method of sorting out parameters for all
26the PCMCIA drivers is agreed upon. If you must have a built in driver 26the PCMCIA drivers is agreed upon. If you must have a built in driver
27with nondefault parameters, they can be edited in 27with nondefault parameters, they can be edited in
28/usr/src/linux/drivers/net/pcmcia/ray_cs.c. Searching for MODULE_PARM 28/usr/src/linux/drivers/net/pcmcia/ray_cs.c. Searching for module_param
29will find them all. 29will find them all.
30 30
31Information on card services is available at: 31Information on card services is available at:
diff --git a/Documentation/nfsroot.txt b/Documentation/nfsroot.txt
index a87d4af216c0..d56dc71d9430 100644
--- a/Documentation/nfsroot.txt
+++ b/Documentation/nfsroot.txt
@@ -3,6 +3,7 @@ Mounting the root filesystem via NFS (nfsroot)
3 3
4Written 1996 by Gero Kuhlmann <gero@gkminix.han.de> 4Written 1996 by Gero Kuhlmann <gero@gkminix.han.de>
5Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz> 5Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org>
6 7
7 8
8 9
@@ -168,7 +169,6 @@ depend on what facilities are available:
168 root. If it got a BOOTP answer the directory name in that answer 169 root. If it got a BOOTP answer the directory name in that answer
169 is used. 170 is used.
170 171
171
1723.2) Using LILO 1723.2) Using LILO
173 When using LILO you can specify all necessary command line 173 When using LILO you can specify all necessary command line
174 parameters with the 'append=' command in the LILO configuration 174 parameters with the 'append=' command in the LILO configuration
@@ -177,7 +177,11 @@ depend on what facilities are available:
177 LILO and its 'append=' command please refer to the LILO 177 LILO and its 'append=' command please refer to the LILO
178 documentation. 178 documentation.
179 179
1803.3) Using loadlin 1803.3) Using GRUB
181 When you use GRUB, you simply append the parameters after the kernel
182 specification: "kernel <kernel> <parameters>" (without the quotes).
183
1843.4) Using loadlin
181 When you want to boot Linux from a DOS command prompt without 185 When you want to boot Linux from a DOS command prompt without
182 having a local hard disk to mount as root, you can use loadlin. 186 having a local hard disk to mount as root, you can use loadlin.
183 I was told that it works, but haven't used it myself yet. In 187 I was told that it works, but haven't used it myself yet. In
@@ -185,7 +189,7 @@ depend on what facilities are available:
185 lar to how LILO is doing it. Please refer to the loadlin docu- 189 lar to how LILO is doing it. Please refer to the loadlin docu-
186 mentation for further information. 190 mentation for further information.
187 191
1883.4) Using a boot ROM 1923.5) Using a boot ROM
189 This is probably the most elegant way of booting a diskless 193 This is probably the most elegant way of booting a diskless
190 client. With a boot ROM the kernel gets loaded using the TFTP 194 client. With a boot ROM the kernel gets loaded using the TFTP
191 protocol. As far as I know, no commercial boot ROMs yet 195 protocol. As far as I know, no commercial boot ROMs yet
@@ -194,6 +198,13 @@ depend on what facilities are available:
194 and its mirrors. They are called 'netboot-nfs' and 'etherboot'. 198 and its mirrors. They are called 'netboot-nfs' and 'etherboot'.
195 Both contain everything you need to boot a diskless Linux client. 199 Both contain everything you need to boot a diskless Linux client.
196 200
2013.6) Using pxelinux
202 Using pxelinux you specify the kernel you built with
203 "kernel <relative-path-below /tftpboot>". The nfsroot parameters
204 are passed to the kernel by adding them to the "append" line.
205 You may perhaps also want to fine tune the console output,
206 see Documentation/serial-console.txt for serial console help.
207
197 208
198 209
199 210
diff --git a/Documentation/s390/driver-model.txt b/Documentation/s390/driver-model.txt
index df09758bf3fe..efb674eda4d4 100644
--- a/Documentation/s390/driver-model.txt
+++ b/Documentation/s390/driver-model.txt
@@ -16,10 +16,12 @@ devices/
16 - 0.0.0000/0.0.0815/ 16 - 0.0.0000/0.0.0815/
17 - 0.0.0001/0.0.4711/ 17 - 0.0.0001/0.0.4711/
18 - 0.0.0002/ 18 - 0.0.0002/
19 - 0.1.0000/0.1.1234/
19 ... 20 ...
20 21
21In this example, device 0815 is accessed via subchannel 0, device 4711 via 22In this example, device 0815 is accessed via subchannel 0 in subchannel set 0,
22subchannel 1, and subchannel 2 is a non-I/O subchannel. 23device 4711 via subchannel 1 in subchannel set 0, and subchannel 2 is a non-I/O
24subchannel. Device 1234 is accessed via subchannel 0 in subchannel set 1.
23 25
24You should address a ccw device via its bus id (e.g. 0.0.4711); the device can 26You should address a ccw device via its bus id (e.g. 0.0.4711); the device can
25be found under bus/ccw/devices/. 27be found under bus/ccw/devices/.
@@ -97,7 +99,7 @@ is not available to the device driver.
97 99
98Each driver should declare in a MODULE_DEVICE_TABLE into which CU types/models 100Each driver should declare in a MODULE_DEVICE_TABLE into which CU types/models
99and/or device types/models it is interested. This information can later be found 101and/or device types/models it is interested. This information can later be found
100found in the struct ccw_device_id fields: 102in the struct ccw_device_id fields:
101 103
102struct ccw_device_id { 104struct ccw_device_id {
103 __u16 match_flags; 105 __u16 match_flags;
@@ -208,6 +210,11 @@ Each ccwgroup device also provides an 'ungroup' attribute to destroy the device
208again (only when offline). This is a generic ccwgroup mechanism (the driver does 210again (only when offline). This is a generic ccwgroup mechanism (the driver does
209not need to implement anything beyond normal removal routines). 211not need to implement anything beyond normal removal routines).
210 212
213A ccw device which is a member of a ccwgroup device carries a pointer to the
214ccwgroup device in the driver_data of its device struct. This field must not be
215touched by the driver - it should use the ccwgroup device's driver_data for its
216private data.
217
211To implement a ccwgroup driver, please refer to include/asm/ccwgroup.h. Keep in 218To implement a ccwgroup driver, please refer to include/asm/ccwgroup.h. Keep in
212mind that most drivers will need to implement both a ccwgroup and a ccw driver 219mind that most drivers will need to implement both a ccwgroup and a ccw driver
213(unless you have a meta ccw driver, like cu3088 for lcs and ctc). 220(unless you have a meta ccw driver, like cu3088 for lcs and ctc).
@@ -230,6 +237,8 @@ status - Can be 'online' or 'offline'.
230 a channel path the user knows to be online, but the machine hasn't 237 a channel path the user knows to be online, but the machine hasn't
231 created a machine check for. 238 created a machine check for.
232 239
240type - The physical type of the channel path.
241
233 242
2343. System devices 2433. System devices
235----------------- 244-----------------
diff --git a/Documentation/serial-console.txt b/Documentation/serial-console.txt
index 6c689b0df2b8..9a7bc8b3f479 100644
--- a/Documentation/serial-console.txt
+++ b/Documentation/serial-console.txt
@@ -17,11 +17,13 @@ The format of this option is:
17 ttyX for any other virtual console 17 ttyX for any other virtual console
18 ttySx for a serial port 18 ttySx for a serial port
19 lp0 for the first parallel port 19 lp0 for the first parallel port
20 ttyUSB0 for the first USB serial device
20 21
21 options: depend on the driver. For the serial port this 22 options: depend on the driver. For the serial port this
22 defines the baudrate/parity/bits of the port, 23 defines the baudrate/parity/bits/flow control of
23 in the format BBBBPN, where BBBB is the speed, 24 the port, in the format BBBBPNF, where BBBB is the
24 P is parity (n/o/e), and N is bits. Default is 25 speed, P is parity (n/o/e), N is number of bits,
26 and F is flow control ('r' for RTS). Default is
25 9600n8. The maximum baudrate is 115200. 27 9600n8. The maximum baudrate is 115200.
26 28
27You can specify multiple console= options on the kernel command line. 29You can specify multiple console= options on the kernel command line.
@@ -45,6 +47,9 @@ become the console.
45You will need to create a new device to use /dev/console. The official 47You will need to create a new device to use /dev/console. The official
46/dev/console is now character device 5,1. 48/dev/console is now character device 5,1.
47 49
50(You can also use a network device as a console. See
51Documentation/networking/netconsole.txt for information on that.)
52
48Here's an example that will use /dev/ttyS1 (COM2) as the console. 53Here's an example that will use /dev/ttyS1 (COM2) as the console.
49Replace the sample values as needed. 54Replace the sample values as needed.
50 55
diff --git a/Documentation/smart-config.txt b/Documentation/smart-config.txt
index c9bed4cf8773..8467447b5a87 100644
--- a/Documentation/smart-config.txt
+++ b/Documentation/smart-config.txt
@@ -56,10 +56,6 @@ Here is the solution:
56 writing one file per option. It updates only the files for options 56 writing one file per option. It updates only the files for options
57 that have changed. 57 that have changed.
58 58
59 mkdep.c no longer generates warning messages for missing or unneeded
60 <linux/config.h> lines. The new top-level target 'make checkconfig'
61 checks for these problems.
62
63Flag Dependencies 59Flag Dependencies
64 60
65 Martin Von Loewis contributed another feature to this patch: 61 Martin Von Loewis contributed another feature to this patch:
diff --git a/Documentation/sound/oss/Introduction b/Documentation/sound/oss/Introduction
index 15d4fb975ac0..f04ba6bb7395 100644
--- a/Documentation/sound/oss/Introduction
+++ b/Documentation/sound/oss/Introduction
@@ -69,7 +69,7 @@ are available, for example IRQ, address, DMA.
69 69
70Warning, the options for different cards sometime use different names 70Warning, the options for different cards sometime use different names
71for the same or a similar feature (dma1= versus dma16=). As a last 71for the same or a similar feature (dma1= versus dma16=). As a last
72resort, inspect the code (search for MODULE_PARM). 72resort, inspect the code (search for module_param).
73 73
74Notes: 74Notes:
75 75
diff --git a/Documentation/sound/oss/cs46xx b/Documentation/sound/oss/cs46xx
index 88d6cf8b39f3..b54432709863 100644
--- a/Documentation/sound/oss/cs46xx
+++ b/Documentation/sound/oss/cs46xx
@@ -88,7 +88,7 @@ parameters. for a copy email: twoller@crystal.cirrus.com
88 88
89MODULE_PARMS definitions 89MODULE_PARMS definitions
90------------------------ 90------------------------
91MODULE_PARM(defaultorder, "i"); 91module_param(defaultorder, ulong, 0);
92defaultorder=N 92defaultorder=N
93where N is a value from 1 to 12 93where N is a value from 1 to 12
94The buffer order determines the size of the dma buffer for the driver. 94The 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)
98rather than 64k as some of the games work more responsively. 98rather than 64k as some of the games work more responsively.
99(2^N) * PAGE_SIZE = allocated buffer size 99(2^N) * PAGE_SIZE = allocated buffer size
100 100
101MODULE_PARM(cs_debuglevel, "i"); 101module_param(cs_debuglevel, ulong, 0644);
102MODULE_PARM(cs_debugmask, "i"); 102module_param(cs_debugmask, ulong, 0644);
103cs_debuglevel=N 103cs_debuglevel=N
104cs_debugmask=0xMMMMMMMM 104cs_debugmask=0xMMMMMMMM
105where N is a value from 0 (no debug printfs), to 9 (maximum) 105where N is a value from 0 (no debug printfs), to 9 (maximum)
1060xMMMMMMMM is a debug mask corresponding to the CS_xxx bits (see driver source). 1060xMMMMMMMM is a debug mask corresponding to the CS_xxx bits (see driver source).
107 107
108MODULE_PARM(hercules_egpio_disable, "i"); 108module_param(hercules_egpio_disable, ulong, 0);
109hercules_egpio_disable=N 109hercules_egpio_disable=N
110where N is a 0 (enable egpio), or a 1 (disable egpio support) 110where N is a 0 (enable egpio), or a 1 (disable egpio support)
111 111
112MODULE_PARM(initdelay, "i"); 112module_param(initdelay, ulong, 0);
113initdelay=N 113initdelay=N
114This value is used to determine the millescond delay during the initialization 114This value is used to determine the millescond delay during the initialization
115code prior to powering up the PLL. On laptops this value can be used to 115code 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
118properly delay the required time. Also, if the system is booted under AC power 118properly delay the required time. Also, if the system is booted under AC power
119and then the power removed, the mdelay()/udelay() functions will not delay properly. 119and then the power removed, the mdelay()/udelay() functions will not delay properly.
120 120
121MODULE_PARM(powerdown, "i"); 121module_param(powerdown, ulong, 0);
122powerdown=N 122powerdown=N
123where N is 0 (disable any powerdown of the internal blocks) or 1 (enable powerdown) 123where N is 0 (disable any powerdown of the internal blocks) or 1 (enable powerdown)
124 124
125 125
126MODULE_PARM(external_amp, "i"); 126module_param(external_amp, bool, 0);
127external_amp=1 127external_amp=1
128if N is set to 1, then force enabling the EAPD support in the primary AC97 codec. 128if N is set to 1, then force enabling the EAPD support in the primary AC97 codec.
129override the detection logic and force the external amp bit in the AC97 0x26 register 129override the detection logic and force the external amp bit in the AC97 0x26 register
130to be reset (0). EAPD should be 0 for powerup, and 1 for powerdown. The VTB Santa Cruz 130to be reset (0). EAPD should be 0 for powerup, and 1 for powerdown. The VTB Santa Cruz
131card has inverted logic, so there is a special function for these cards. 131card has inverted logic, so there is a special function for these cards.
132 132
133MODULE_PARM(thinkpad, "i"); 133module_param(thinkpad, bool, 0);
134thinkpad=1 134thinkpad=1
135if N is set to 1, then force enabling the clkrun functionality. 135if N is set to 1, then force enabling the clkrun functionality.
136Currently, when the part is being used, then clkrun is disabled for the entire system, 136Currently, 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 e415e3604539..464e4cec94cb 100644
--- a/Documentation/video4linux/CQcam.txt
+++ b/Documentation/video4linux/CQcam.txt
@@ -1,7 +1,7 @@
1c-qcam - Connectix Color QuickCam video4linux kernel driver 1c-qcam - Connectix Color QuickCam video4linux kernel driver
2 2
3Copyright (C) 1999 Dave Forrest <drf5n@virginia.edu> 3Copyright (C) 1999 Dave Forrest <drf5n@virginia.edu>
4 released under GNU GPL. 4 released under GNU GPL.
5 5
61999-12-08 Dave Forrest, written with kernel version 2.2.12 in mind 61999-12-08 Dave Forrest, written with kernel version 2.2.12 in mind
7 7
@@ -45,21 +45,21 @@ configuration. The appropriate flags are:
45 CONFIG_PNP_PARPORT M for autoprobe.o IEEE1284 readback module 45 CONFIG_PNP_PARPORT M for autoprobe.o IEEE1284 readback module
46 CONFIG_PRINTER_READBACK M for parport_probe.o IEEE1284 readback module 46 CONFIG_PRINTER_READBACK M for parport_probe.o IEEE1284 readback module
47 CONFIG_VIDEO_DEV M for videodev.o video4linux module 47 CONFIG_VIDEO_DEV M for videodev.o video4linux module
48 CONFIG_VIDEO_CQCAM M for c-qcam.o Color Quickcam module 48 CONFIG_VIDEO_CQCAM M for c-qcam.o Color Quickcam module
49 49
50 With these flags, the kernel should compile and install the modules. 50 With these flags, the kernel should compile and install the modules.
51To record and monitor the compilation, I use: 51To record and monitor the compilation, I use:
52 52
53 (make zlilo ; \ 53 (make zlilo ; \
54 make modules; \ 54 make modules; \
55 make modules_install ; 55 make modules_install ;
56 depmod -a ) &>log & 56 depmod -a ) &>log &
57 less log # then a capital 'F' to watch the progress 57 less log # then a capital 'F' to watch the progress
58 58
59But that is my personal preference. 59But that is my personal preference.
60 60
612.2 Configuration 612.2 Configuration
62 62
63 The configuration requires module configuration and device 63 The configuration requires module configuration and device
64configuration. I like kmod or kerneld process with the 64configuration. I like kmod or kerneld process with the
65/etc/modprobe.conf file so the modules can automatically load/unload as 65/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
68these procedures. 68these procedures.
69 69
70 70
712.1 Module Configuration 712.1 Module Configuration
72 72
73 Using modules requires a bit of work to install and pass the 73 Using modules requires a bit of work to install and pass the
74parameters. Understand that entries in /etc/modprobe.conf of: 74parameters. Understand that entries in /etc/modprobe.conf of:
@@ -128,9 +128,9 @@ system (CONFIG_PROC_FS), the parallel printer support
128(CONFIG_PRINTER), the IEEE 1284 system,(CONFIG_PRINTER_READBACK), you 128(CONFIG_PRINTER), the IEEE 1284 system,(CONFIG_PRINTER_READBACK), you
129should be able to read some identification from your quickcam with 129should be able to read some identification from your quickcam with
130 130
131 modprobe -v parport 131 modprobe -v parport
132 modprobe -v parport_probe 132 modprobe -v parport_probe
133 cat /proc/parport/PORTNUMBER/autoprobe 133 cat /proc/parport/PORTNUMBER/autoprobe
134Returns: 134Returns:
135 CLASS:MEDIA; 135 CLASS:MEDIA;
136 MODEL:Color QuickCam 2.0; 136 MODEL:Color QuickCam 2.0;
@@ -140,7 +140,7 @@ Returns:
140and well. A common problem is that the current driver does not 140and well. A common problem is that the current driver does not
141reliably detect a c-qcam, even though one is attached. In this case, 141reliably detect a c-qcam, even though one is attached. In this case,
142 142
143 modprobe -v c-qcam 143 modprobe -v c-qcam
144or 144or
145 insmod -v c-qcam 145 insmod -v c-qcam
146 146
@@ -152,16 +152,16 @@ video4linux mailing list and archive for more current information.
1523.1 Checklist: 1523.1 Checklist:
153 153
154 Can you get an image? 154 Can you get an image?
155 v4lgrab >qcam.ppm ; wc qcam.ppm ; xv qcam.ppm 155 v4lgrab >qcam.ppm ; wc qcam.ppm ; xv qcam.ppm
156 156
157 Is a working c-qcam connected to the port? 157 Is a working c-qcam connected to the port?
158 grep ^ /proc/parport/?/autoprobe 158 grep ^ /proc/parport/?/autoprobe
159 159
160 Do the /dev/video* files exist? 160 Do the /dev/video* files exist?
161 ls -lad /dev/video 161 ls -lad /dev/video
162 162
163 Is the c-qcam module loaded? 163 Is the c-qcam module loaded?
164 modprobe -v c-qcam ; lsmod 164 modprobe -v c-qcam ; lsmod
165 165
166 Does the camera work with alternate programs? cqcam, etc? 166 Does the camera work with alternate programs? cqcam, etc?
167 167
@@ -174,7 +174,7 @@ video4linux mailing list and archive for more current information.
174isn't, you might try patching the c-qcam module to add a parport=xxx 174isn't, you might try patching the c-qcam module to add a parport=xxx
175option as in the bw-qcam module so you can specify the parallel port: 175option as in the bw-qcam module so you can specify the parallel port:
176 176
177 insmod -v c-qcam parport=0 177 insmod -v c-qcam parport=0
178 178
179And bypass the detection code, see ../../drivers/char/c-qcam.c and 179And bypass the detection code, see ../../drivers/char/c-qcam.c and
180look for the 'qc_detect' code and call. 180look for the 'qc_detect' code and call.
@@ -183,12 +183,12 @@ look for the 'qc_detect' code and call.
183this work is documented at the video4linux2 site listed below. 183this work is documented at the video4linux2 site listed below.
184 184
185 185
1869.0 --- A sample program using v4lgrabber, 1869.0 --- A sample program using v4lgrabber,
187 187
188This program is a simple image grabber that will copy a frame from the 188This program is a simple image grabber that will copy a frame from the
189first video device, /dev/video0 to standard output in portable pixmap 189first video device, /dev/video0 to standard output in portable pixmap
190format (.ppm) Using this like: 'v4lgrab | convert - c-qcam.jpg' 190format (.ppm) Using this like: 'v4lgrab | convert - c-qcam.jpg'
191produced this picture of me at 191produced this picture of me at
192 http://mug.sys.virginia.edu/~drf5n/extras/c-qcam.jpg 192 http://mug.sys.virginia.edu/~drf5n/extras/c-qcam.jpg
193 193
194-------------------- 8< ---------------- 8< ----------------------------- 194-------------------- 8< ---------------- 8< -----------------------------
@@ -202,8 +202,8 @@ produced this picture of me at
202 * Use as: 202 * Use as:
203 * v4lgrab >image.ppm 203 * v4lgrab >image.ppm
204 * 204 *
205 * Copyright (C) 1998-05-03, Phil Blundell <philb@gnu.org> 205 * Copyright (C) 1998-05-03, Phil Blundell <philb@gnu.org>
206 * Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c 206 * Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c
207 * with minor modifications (Dave Forrest, drf5n@virginia.edu). 207 * with minor modifications (Dave Forrest, drf5n@virginia.edu).
208 * 208 *
209 */ 209 */
@@ -225,55 +225,55 @@ produced this picture of me at
225 225
226#define READ_VIDEO_PIXEL(buf, format, depth, r, g, b) \ 226#define READ_VIDEO_PIXEL(buf, format, depth, r, g, b) \
227{ \ 227{ \
228 switch (format) \ 228 switch (format) \
229 { \ 229 { \
230 case VIDEO_PALETTE_GREY: \ 230 case VIDEO_PALETTE_GREY: \
231 switch (depth) \ 231 switch (depth) \
232 { \ 232 { \
233 case 4: \ 233 case 4: \
234 case 6: \ 234 case 6: \
235 case 8: \ 235 case 8: \
236 (r) = (g) = (b) = (*buf++ << 8);\ 236 (r) = (g) = (b) = (*buf++ << 8);\
237 break; \ 237 break; \
238 \ 238 \
239 case 16: \ 239 case 16: \
240 (r) = (g) = (b) = \ 240 (r) = (g) = (b) = \
241 *((unsigned short *) buf); \ 241 *((unsigned short *) buf); \
242 buf += 2; \ 242 buf += 2; \
243 break; \ 243 break; \
244 } \ 244 } \
245 break; \ 245 break; \
246 \ 246 \
247 \ 247 \
248 case VIDEO_PALETTE_RGB565: \ 248 case VIDEO_PALETTE_RGB565: \
249 { \ 249 { \
250 unsigned short tmp = *(unsigned short *)buf; \ 250 unsigned short tmp = *(unsigned short *)buf; \
251 (r) = tmp&0xF800; \ 251 (r) = tmp&0xF800; \
252 (g) = (tmp<<5)&0xFC00; \ 252 (g) = (tmp<<5)&0xFC00; \
253 (b) = (tmp<<11)&0xF800; \ 253 (b) = (tmp<<11)&0xF800; \
254 buf += 2; \ 254 buf += 2; \
255 } \ 255 } \
256 break; \ 256 break; \
257 \ 257 \
258 case VIDEO_PALETTE_RGB555: \ 258 case VIDEO_PALETTE_RGB555: \
259 (r) = (buf[0]&0xF8)<<8; \ 259 (r) = (buf[0]&0xF8)<<8; \
260 (g) = ((buf[0] << 5 | buf[1] >> 3)&0xF8)<<8; \ 260 (g) = ((buf[0] << 5 | buf[1] >> 3)&0xF8)<<8; \
261 (b) = ((buf[1] << 2 ) & 0xF8)<<8; \ 261 (b) = ((buf[1] << 2 ) & 0xF8)<<8; \
262 buf += 2; \ 262 buf += 2; \
263 break; \ 263 break; \
264 \ 264 \
265 case VIDEO_PALETTE_RGB24: \ 265 case VIDEO_PALETTE_RGB24: \
266 (r) = buf[0] << 8; (g) = buf[1] << 8; \ 266 (r) = buf[0] << 8; (g) = buf[1] << 8; \
267 (b) = buf[2] << 8; \ 267 (b) = buf[2] << 8; \
268 buf += 3; \ 268 buf += 3; \
269 break; \ 269 break; \
270 \ 270 \
271 default: \ 271 default: \
272 fprintf(stderr, \ 272 fprintf(stderr, \
273 "Format %d not yet supported\n", \ 273 "Format %d not yet supported\n", \
274 format); \ 274 format); \
275 } \ 275 } \
276} 276}
277 277
278int get_brightness_adj(unsigned char *image, long size, int *brightness) { 278int get_brightness_adj(unsigned char *image, long size, int *brightness) {
279 long i, tot = 0; 279 long i, tot = 0;
@@ -324,40 +324,40 @@ int main(int argc, char ** argv)
324 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) { 324 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
325 vpic.depth=6; 325 vpic.depth=6;
326 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) { 326 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
327 vpic.depth=4; 327 vpic.depth=4;
328 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) { 328 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
329 fprintf(stderr, "Unable to find a supported capture format.\n"); 329 fprintf(stderr, "Unable to find a supported capture format.\n");
330 close(fd); 330 close(fd);
331 exit(1); 331 exit(1);
332 } 332 }
333 } 333 }
334 } 334 }
335 } else { 335 } else {
336 vpic.depth=24; 336 vpic.depth=24;
337 vpic.palette=VIDEO_PALETTE_RGB24; 337 vpic.palette=VIDEO_PALETTE_RGB24;
338 338
339 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) { 339 if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
340 vpic.palette=VIDEO_PALETTE_RGB565; 340 vpic.palette=VIDEO_PALETTE_RGB565;
341 vpic.depth=16; 341 vpic.depth=16;
342 342
343 if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) { 343 if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
344 vpic.palette=VIDEO_PALETTE_RGB555; 344 vpic.palette=VIDEO_PALETTE_RGB555;
345 vpic.depth=15; 345 vpic.depth=15;
346 346
347 if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) { 347 if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
348 fprintf(stderr, "Unable to find a supported capture format.\n"); 348 fprintf(stderr, "Unable to find a supported capture format.\n");
349 return -1; 349 return -1;
350 } 350 }
351 } 351 }
352 } 352 }
353 } 353 }
354 354
355 buffer = malloc(win.width * win.height * bpp); 355 buffer = malloc(win.width * win.height * bpp);
356 if (!buffer) { 356 if (!buffer) {
357 fprintf(stderr, "Out of memory.\n"); 357 fprintf(stderr, "Out of memory.\n");
358 exit(1); 358 exit(1);
359 } 359 }
360 360
361 do { 361 do {
362 int newbright; 362 int newbright;
363 read(fd, buffer, win.width * win.height * bpp); 363 read(fd, buffer, win.width * win.height * bpp);
@@ -365,8 +365,8 @@ int main(int argc, char ** argv)
365 if (f) { 365 if (f) {
366 vpic.brightness += (newbright << 8); 366 vpic.brightness += (newbright << 8);
367 if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) { 367 if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
368 perror("VIDIOSPICT"); 368 perror("VIDIOSPICT");
369 break; 369 break;
370 } 370 }
371 } 371 }
372 } while (f); 372 } while (f);
@@ -381,7 +381,7 @@ int main(int argc, char ** argv)
381 fputc(g>>8, stdout); 381 fputc(g>>8, stdout);
382 fputc(b>>8, stdout); 382 fputc(b>>8, stdout);
383 } 383 }
384 384
385 close(fd); 385 close(fd);
386 return 0; 386 return 0;
387} 387}
diff --git a/Documentation/video4linux/README.cpia b/Documentation/video4linux/README.cpia
index c95e7bbc0fdf..19cd3bf24981 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
87at the LILO-prompt or specify it in lilo.conf. I use the following 87at the LILO-prompt or specify it in lilo.conf. I use the following
88append-line in lilo.conf: 88append-line in lilo.conf:
89 89
90 append="parport=0x378,7,3" 90 append="parport=0x378,7,3"
91 91
92See Documentation/parport.txt for more information about the 92See Documentation/parport.txt for more information about the
93configuration of the parport and the values given above. Do not simply 93configuration of the parport and the values given above. Do not simply
@@ -175,7 +175,7 @@ THANKS (in no particular order):
175- Manuel J. Petit de Gabriel <mpetit@dit.upm.es> for providing help 175- Manuel J. Petit de Gabriel <mpetit@dit.upm.es> for providing help
176 with Isabel (http://isabel.dit.upm.es/) 176 with Isabel (http://isabel.dit.upm.es/)
177- Bas Huisman <bhuism@cs.utwente.nl> for writing the initial parport code 177- Bas Huisman <bhuism@cs.utwente.nl> for writing the initial parport code
178- Jarl Totland <Jarl.Totland@bdc.no> for setting up the mailing list 178- Jarl Totland <Jarl.Totland@bdc.no> for setting up the mailing list
179 and maintaining the web-server[3] 179 and maintaining the web-server[3]
180- Chris Whiteford <Chris@informinteractive.com> for fixes related to the 180- Chris Whiteford <Chris@informinteractive.com> for fixes related to the
181 1.02 firmware 181 1.02 firmware
diff --git a/Documentation/video4linux/Zoran b/Documentation/video4linux/Zoran
index 52c94bd7dca1..be9f21b84555 100644
--- a/Documentation/video4linux/Zoran
+++ b/Documentation/video4linux/Zoran
@@ -28,7 +28,7 @@ Iomega Buz:
28* Philips saa7111 TV decoder 28* Philips saa7111 TV decoder
29* Philips saa7185 TV encoder 29* Philips saa7185 TV encoder
30Drivers to use: videodev, i2c-core, i2c-algo-bit, 30Drivers to use: videodev, i2c-core, i2c-algo-bit,
31 videocodec, saa7111, saa7185, zr36060, zr36067 31 videocodec, saa7111, saa7185, zr36060, zr36067
32Inputs/outputs: Composite and S-video 32Inputs/outputs: Composite and S-video
33Norms: PAL, SECAM (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps) 33Norms: PAL, SECAM (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps)
34Card number: 7 34Card number: 7
@@ -39,7 +39,7 @@ Linux Media Labs LML33:
39* Brooktree bt819 TV decoder 39* Brooktree bt819 TV decoder
40* Brooktree bt856 TV encoder 40* Brooktree bt856 TV encoder
41Drivers to use: videodev, i2c-core, i2c-algo-bit, 41Drivers to use: videodev, i2c-core, i2c-algo-bit,
42 videocodec, bt819, bt856, zr36060, zr36067 42 videocodec, bt819, bt856, zr36060, zr36067
43Inputs/outputs: Composite and S-video 43Inputs/outputs: Composite and S-video
44Norms: PAL (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps) 44Norms: PAL (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps)
45Card number: 5 45Card number: 5
@@ -50,7 +50,7 @@ Linux Media Labs LML33R10:
50* Philips saa7114 TV decoder 50* Philips saa7114 TV decoder
51* Analog Devices adv7170 TV encoder 51* Analog Devices adv7170 TV encoder
52Drivers to use: videodev, i2c-core, i2c-algo-bit, 52Drivers to use: videodev, i2c-core, i2c-algo-bit,
53 videocodec, saa7114, adv7170, zr36060, zr36067 53 videocodec, saa7114, adv7170, zr36060, zr36067
54Inputs/outputs: Composite and S-video 54Inputs/outputs: Composite and S-video
55Norms: PAL (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps) 55Norms: PAL (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps)
56Card number: 6 56Card number: 6
@@ -61,7 +61,7 @@ Pinnacle/Miro DC10(new):
61* Philips saa7110a TV decoder 61* Philips saa7110a TV decoder
62* Analog Devices adv7176 TV encoder 62* Analog Devices adv7176 TV encoder
63Drivers to use: videodev, i2c-core, i2c-algo-bit, 63Drivers to use: videodev, i2c-core, i2c-algo-bit,
64 videocodec, saa7110, adv7175, zr36060, zr36067 64 videocodec, saa7110, adv7175, zr36060, zr36067
65Inputs/outputs: Composite, S-video and Internal 65Inputs/outputs: Composite, S-video and Internal
66Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps) 66Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps)
67Card number: 1 67Card number: 1
@@ -84,7 +84,7 @@ Pinnacle/Miro DC10(old): *
84* Micronas vpx3220a TV decoder 84* Micronas vpx3220a TV decoder
85* mse3000 TV encoder or Analog Devices adv7176 TV encoder * 85* mse3000 TV encoder or Analog Devices adv7176 TV encoder *
86Drivers to use: videodev, i2c-core, i2c-algo-bit, 86Drivers to use: videodev, i2c-core, i2c-algo-bit,
87 videocodec, vpx3220, mse3000/adv7175, zr36050, zr36016, zr36067 87 videocodec, vpx3220, mse3000/adv7175, zr36050, zr36016, zr36067
88Inputs/outputs: Composite, S-video and Internal 88Inputs/outputs: Composite, S-video and Internal
89Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps) 89Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps)
90Card number: 0 90Card number: 0
@@ -96,7 +96,7 @@ Pinnacle/Miro DC30: *
96* Micronas vpx3225d/vpx3220a/vpx3216b TV decoder 96* Micronas vpx3225d/vpx3220a/vpx3216b TV decoder
97* Analog Devices adv7176 TV encoder 97* Analog Devices adv7176 TV encoder
98Drivers to use: videodev, i2c-core, i2c-algo-bit, 98Drivers to use: videodev, i2c-core, i2c-algo-bit,
99 videocodec, vpx3220/vpx3224, adv7175, zr36050, zr36016, zr36067 99 videocodec, vpx3220/vpx3224, adv7175, zr36050, zr36016, zr36067
100Inputs/outputs: Composite, S-video and Internal 100Inputs/outputs: Composite, S-video and Internal
101Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps) 101Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps)
102Card number: 3 102Card number: 3
@@ -123,11 +123,11 @@ Note: use encoder=X or decoder=X for non-default i2c chips (see i2c-id.h)
123 123
124The best know TV standards are NTSC/PAL/SECAM. but for decoding a frame that 124The best know TV standards are NTSC/PAL/SECAM. but for decoding a frame that
125information is not enough. There are several formats of the TV standards. 125information is not enough. There are several formats of the TV standards.
126And not every TV decoder is able to handle every format. Also the every 126And not every TV decoder is able to handle every format. Also the every
127combination is supported by the driver. There are currently 11 different 127combination is supported by the driver. There are currently 11 different
128tv broadcast formats all aver the world. 128tv broadcast formats all aver the world.
129 129
130The CCIR defines parameters needed for broadcasting the signal. 130The CCIR defines parameters needed for broadcasting the signal.
131The CCIR has defined different standards: A,B,D,E,F,G,D,H,I,K,K1,L,M,N,... 131The CCIR has defined different standards: A,B,D,E,F,G,D,H,I,K,K1,L,M,N,...
132The CCIR says not much about about the colorsystem used !!! 132The CCIR says not much about about the colorsystem used !!!
133And talking about a colorsystem says not to much about how it is broadcast. 133And 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.
136 136
137When you speak about NTSC, you usually mean the standard: CCIR - M using 137When you speak about NTSC, you usually mean the standard: CCIR - M using
138the NTSC colorsystem which is used in the USA, Japan, Mexico, Canada 138the NTSC colorsystem which is used in the USA, Japan, Mexico, Canada
139and a few others. 139and a few others.
140 140
141When you talk about PAL, you usually mean: CCIR - B/G using the PAL 141When you talk about PAL, you usually mean: CCIR - B/G using the PAL
142colorsystem which is used in many Countries. 142colorsystem which is used in many Countries.
143 143
144When you talk about SECAM, you mean: CCIR - L using the SECAM Colorsystem 144When you talk about SECAM, you mean: CCIR - L using the SECAM Colorsystem
145which is used in France, and a few others. 145which is used in France, and a few others.
146 146
147There the other version of SECAM, CCIR - D/K is used in Bulgaria, China, 147There the other version of SECAM, CCIR - D/K is used in Bulgaria, China,
148Slovakai, Hungary, Korea (Rep.), Poland, Rumania and a others. 148Slovakai, Hungary, Korea (Rep.), Poland, Rumania and a others.
149 149
150The CCIR - H uses the PAL colorsystem (sometimes SECAM) and is used in 150The CCIR - H uses the PAL colorsystem (sometimes SECAM) and is used in
151Egypt, Libya, Sri Lanka, Syrain Arab. Rep. 151Egypt, Libya, Sri Lanka, Syrain Arab. Rep.
152 152
153The CCIR - I uses the PAL colorsystem, and is used in Great Britain, Hong Kong, 153The 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
158 158
159We do not talk about how the audio is broadcast ! 159We do not talk about how the audio is broadcast !
160 160
161A rather good sites about the TV standards are: 161A rather good sites about the TV standards are:
162http://www.sony.jp/ServiceArea/Voltage_map/ 162http://www.sony.jp/ServiceArea/Voltage_map/
163http://info.electronicwerkstatt.de/bereiche/fernsehtechnik/frequenzen_und_normen/Fernsehnormen/ 163http://info.electronicwerkstatt.de/bereiche/fernsehtechnik/frequenzen_und_normen/Fernsehnormen/
164and http://www.cabl.com/restaurant/channel.html 164and http://www.cabl.com/restaurant/channel.html
165 165
166Other weird things around: NTSC 4.43 is a modificated NTSC, which is mainly 166Other weird things around: NTSC 4.43 is a modificated NTSC, which is mainly
167used in PAL VCR's that are able to play back NTSC. PAL 60 seems to be the same 167used in PAL VCR's that are able to play back NTSC. PAL 60 seems to be the same
168as NTSC 4.43 . The Datasheets also talk about NTSC 44, It seems as if it would 168as NTSC 4.43 . The Datasheets also talk about NTSC 44, It seems as if it would
169be the same as NTSC 4.43. 169be the same as NTSC 4.43.
170NTSC Combs seems to be a decoder mode where the decoder uses a comb filter 170NTSC Combs seems to be a decoder mode where the decoder uses a comb filter
171to split coma and luma instead of a Delay line. 171to split coma and luma instead of a Delay line.
172 172
173But I did not defiantly find out what NTSC Comb is. 173But I did not defiantly find out what NTSC Comb is.
174 174
175Philips saa7111 TV decoder 175Philips saa7111 TV decoder
176was introduced in 1997, is used in the BUZ and 176was introduced in 1997, is used in the BUZ and
177can handle: PAL B/G/H/I, PAL N, PAL M, NTSC M, NTSC N, NTSC 4.43 and SECAM 177can handle: PAL B/G/H/I, PAL N, PAL M, NTSC M, NTSC N, NTSC 4.43 and SECAM
178 178
179Philips saa7110a TV decoder 179Philips saa7110a TV decoder
180was introduced in 1995, is used in the Pinnacle/Miro DC10(new), DC10+ and 180was introduced in 1995, is used in the Pinnacle/Miro DC10(new), DC10+ and
181can handle: PAL B/G, NTSC M and SECAM 181can handle: PAL B/G, NTSC M and SECAM
182 182
183Philips saa7114 TV decoder 183Philips saa7114 TV decoder
184was introduced in 2000, is used in the LML33R10 and 184was introduced in 2000, is used in the LML33R10 and
185can handle: PAL B/G/D/H/I/N, PAL N, PAL M, NTSC M, NTSC 4.43 and SECAM 185can handle: PAL B/G/D/H/I/N, PAL N, PAL M, NTSC M, NTSC 4.43 and SECAM
186 186
187Brooktree bt819 TV decoder 187Brooktree bt819 TV decoder
@@ -206,7 +206,7 @@ was introduced in 1996, is used in the BUZ
206can generate: PAL B/G, NTSC M 206can generate: PAL B/G, NTSC M
207 207
208Brooktree bt856 TV Encoder 208Brooktree bt856 TV Encoder
209was introduced in 1994, is used in the LML33 209was introduced in 1994, is used in the LML33
210can generate: PAL B/D/G/H/I/N, PAL M, NTSC M, PAL-N (Argentina) 210can generate: PAL B/D/G/H/I/N, PAL M, NTSC M, PAL-N (Argentina)
211 211
212Analog Devices adv7170 TV Encoder 212Analog Devices adv7170 TV Encoder
@@ -221,9 +221,9 @@ ITT mse3000 TV encoder
221was introduced in 1991, is used in the DC10 old 221was introduced in 1991, is used in the DC10 old
222can generate: PAL , NTSC , SECAM 222can generate: PAL , NTSC , SECAM
223 223
224The adv717x, should be able to produce PAL N. But you find nothing PAL N 224The adv717x, should be able to produce PAL N. But you find nothing PAL N
225specific in the registers. Seem that you have to reuse a other standard 225specific in the registers. Seem that you have to reuse a other standard
226to generate PAL N, maybe it would work if you use the PAL M settings. 226to generate PAL N, maybe it would work if you use the PAL M settings.
227 227
228========================== 228==========================
229 229
@@ -261,7 +261,7 @@ Here's my experience of using LML33 and Buz on various motherboards:
261 261
262VIA MVP3 262VIA MVP3
263 Forget it. Pointless. Doesn't work. 263 Forget it. Pointless. Doesn't work.
264Intel 430FX (Pentium 200) 264Intel 430FX (Pentium 200)
265 LML33 perfect, Buz tolerable (3 or 4 frames dropped per movie) 265 LML33 perfect, Buz tolerable (3 or 4 frames dropped per movie)
266Intel 440BX (early stepping) 266Intel 440BX (early stepping)
267 LML33 tolerable. Buz starting to get annoying (6-10 frames/hour) 267 LML33 tolerable. Buz starting to get annoying (6-10 frames/hour)
@@ -438,52 +438,52 @@ importance of buffer sizes:
438> -q 25 -b 128 : 24.655.992 438> -q 25 -b 128 : 24.655.992
439> -q 25 -b 256 : 25.859.820 439> -q 25 -b 256 : 25.859.820
440 440
441I woke up, and can't go to sleep again. I'll kill some time explaining why 441I woke up, and can't go to sleep again. I'll kill some time explaining why
442this doesn't look strange to me. 442this doesn't look strange to me.
443 443
444Let's do some math using a width of 704 pixels. I'm not sure whether the Buz 444Let's do some math using a width of 704 pixels. I'm not sure whether the Buz
445actually use that number or not, but that's not too important right now. 445actually use that number or not, but that's not too important right now.
446 446
447704x288 pixels, one field, is 202752 pixels. Divided by 64 pixels per block; 447704x288 pixels, one field, is 202752 pixels. Divided by 64 pixels per block;
4483168 blocks per field. Each pixel consist of two bytes; 128 bytes per block; 4483168 blocks per field. Each pixel consist of two bytes; 128 bytes per block;
4491024 bits per block. 100% in the new driver mean 1:2 compression; the maximum 4491024 bits per block. 100% in the new driver mean 1:2 compression; the maximum
450output becomes 512 bits per block. Actually 510, but 512 is simpler to use 450output becomes 512 bits per block. Actually 510, but 512 is simpler to use
451for calculations. 451for calculations.
452 452
453Let's say that we specify d1q50. We thus want 256 bits per block; times 3168 453Let's say that we specify d1q50. We thus want 256 bits per block; times 3168
454becomes 811008 bits; 101376 bytes per field. We're talking raw bits and bytes 454becomes 811008 bits; 101376 bytes per field. We're talking raw bits and bytes
455here, so we don't need to do any fancy corrections for bits-per-pixel or such 455here, so we don't need to do any fancy corrections for bits-per-pixel or such
456things. 101376 bytes per field. 456things. 101376 bytes per field.
457 457
458d1 video contains two fields per frame. Those sum up to 202752 bytes per 458d1 video contains two fields per frame. Those sum up to 202752 bytes per
459frame, and one of those frames goes into each buffer. 459frame, and one of those frames goes into each buffer.
460 460
461But wait a second! -b128 gives 128kB buffers! It's not possible to cram 461But wait a second! -b128 gives 128kB buffers! It's not possible to cram
462202752 bytes of JPEG data into 128kB! 462202752 bytes of JPEG data into 128kB!
463 463
464This is what the driver notice and automatically compensate for in your 464This is what the driver notice and automatically compensate for in your
465examples. Let's do some math using this information: 465examples. Let's do some math using this information:
466 466
467128kB is 131072 bytes. In this buffer, we want to store two fields, which 467128kB is 131072 bytes. In this buffer, we want to store two fields, which
468leaves 65536 bytes for each field. Using 3168 blocks per field, we get 468leaves 65536 bytes for each field. Using 3168 blocks per field, we get
46920.68686868... available bytes per block; 165 bits. We can't allow the 46920.68686868... available bytes per block; 165 bits. We can't allow the
470request for 256 bits per block when there's only 165 bits available! The -q50 470request for 256 bits per block when there's only 165 bits available! The -q50
471option is silently overridden, and the -b128 option takes precedence, leaving 471option is silently overridden, and the -b128 option takes precedence, leaving
472us with the equivalence of -q32. 472us with the equivalence of -q32.
473 473
474This gives us a data rate of 165 bits per block, which, times 3168, sums up 474This gives us a data rate of 165 bits per block, which, times 3168, sums up
475to 65340 bytes per field, out of the allowed 65536. The current driver has 475to 65340 bytes per field, out of the allowed 65536. The current driver has
476another level of rate limiting; it won't accept -q values that fill more than 476another level of rate limiting; it won't accept -q values that fill more than
4776/8 of the specified buffers. (I'm not sure why. "Playing it safe" seem to be 4776/8 of the specified buffers. (I'm not sure why. "Playing it safe" seem to be
478a safe bet. Personally, I think I would have lowered requested-bits-per-block 478a safe bet. Personally, I think I would have lowered requested-bits-per-block
479by one, or something like that.) We can't use 165 bits per block, but have to 479by one, or something like that.) We can't use 165 bits per block, but have to
480lower it again, to 6/8 of the available buffer space: We end up with 124 bits 480lower it again, to 6/8 of the available buffer space: We end up with 124 bits
481per block, the equivalence of -q24. With 128kB buffers, you can't use greater 481per block, the equivalence of -q24. With 128kB buffers, you can't use greater
482than -q24 at -d1. (And PAL, and 704 pixels width...) 482than -q24 at -d1. (And PAL, and 704 pixels width...)
483 483
484The third example is limited to -q24 through the same process. The second 484The third example is limited to -q24 through the same process. The second
485example, using very similar calculations, is limited to -q48. The only 485example, using very similar calculations, is limited to -q48. The only
486example that actually grab at the specified -q value is the last one, which 486example that actually grab at the specified -q value is the last one, which
487is clearly visible, looking at the file size. 487is clearly visible, looking at the file size.
488-- 488--
489 489
diff --git a/Documentation/video4linux/bttv/ICs b/Documentation/video4linux/bttv/ICs
index 6b7491336967..611315f87c3e 100644
--- a/Documentation/video4linux/bttv/ICs
+++ b/Documentation/video4linux/bttv/ICs
@@ -14,13 +14,13 @@ Hauppauge Win/TV pci (version 405):
14 14
15Microchip 24LC02B or 15Microchip 24LC02B or
16Philips 8582E2Y: 256 Byte EEPROM with configuration information 16Philips 8582E2Y: 256 Byte EEPROM with configuration information
17 I2C 0xa0-0xa1, (24LC02B also responds to 0xa2-0xaf) 17 I2C 0xa0-0xa1, (24LC02B also responds to 0xa2-0xaf)
18Philips SAA5246AGP/E: Videotext decoder chip, I2C 0x22-0x23 18Philips SAA5246AGP/E: Videotext decoder chip, I2C 0x22-0x23
19TDA9800: sound decoder 19TDA9800: sound decoder
20Winbond W24257AS-35: 32Kx8 CMOS static RAM (Videotext buffer mem) 20Winbond W24257AS-35: 32Kx8 CMOS static RAM (Videotext buffer mem)
2114052B: analog switch for selection of sound source 2114052B: analog switch for selection of sound source
22 22
23PAL: 23PAL:
24TDA5737: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners 24TDA5737: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners
25TSA5522: 1.4 GHz I2C-bus controlled synthesizer, I2C 0xc2-0xc3 25TSA5522: 1.4 GHz I2C-bus controlled synthesizer, I2C 0xc2-0xc3
26 26
diff --git a/Documentation/video4linux/bttv/PROBLEMS b/Documentation/video4linux/bttv/PROBLEMS
index 8e31e9e36bf7..2b8b0079f7c7 100644
--- a/Documentation/video4linux/bttv/PROBLEMS
+++ b/Documentation/video4linux/bttv/PROBLEMS
@@ -3,7 +3,7 @@
3- Start capturing by pressing "c" or by selecting it via a menu!!! 3- Start capturing by pressing "c" or by selecting it via a menu!!!
4 4
5- The memory of some S3 cards is not recognized right: 5- The memory of some S3 cards is not recognized right:
6 6
7 First of all, if you are not using XFree-3.2 or newer, upgrade AT LEAST to 7 First of all, if you are not using XFree-3.2 or newer, upgrade AT LEAST to
8 XFree-3.2A! This solved the problem for most people. 8 XFree-3.2A! This solved the problem for most people.
9 9
@@ -31,23 +31,23 @@
31 (mostly with Trio 64 but also with some others) 31 (mostly with Trio 64 but also with some others)
32 Get the free demo version of Accelerated X from www.xinside.com and try 32 Get the free demo version of Accelerated X from www.xinside.com and try
33 bttv with it. bttv seems to work with most S3 cards with Accelerated X. 33 bttv with it. bttv seems to work with most S3 cards with Accelerated X.
34 34
35 Since I do not know much (better make that almost nothing) about VGA card 35 Since I do not know much (better make that almost nothing) about VGA card
36 programming I do not know the reason for this. 36 programming I do not know the reason for this.
37 Looks like XFree does something different when setting up the video memory? 37 Looks like XFree does something different when setting up the video memory?
38 Maybe somebody can enlighten me? 38 Maybe somebody can enlighten me?
39 Would be nice if somebody could get this to work with XFree since 39 Would be nice if somebody could get this to work with XFree since
40 Accelerated X costs more than some of the grabber cards ... 40 Accelerated X costs more than some of the grabber cards ...
41 41
42 Better linear frame buffer support for S3 cards will probably be in 42 Better linear frame buffer support for S3 cards will probably be in
43 XFree 4.0. 43 XFree 4.0.
44 44
45- Grabbing is not switched off when changing consoles with XFree. 45- Grabbing is not switched off when changing consoles with XFree.
46 That's because XFree and some AcceleratedX versions do not send unmap 46 That's because XFree and some AcceleratedX versions do not send unmap
47 events. 47 events.
48 48
49- Some popup windows (e.g. of the window manager) are not refreshed. 49- Some popup windows (e.g. of the window manager) are not refreshed.
50 50
51 Disable backing store by starting X with the option "-bs" 51 Disable backing store by starting X with the option "-bs"
52 52
53- When using 32 bpp in XFree or 24+8bpp mode in AccelX 3.1 the system 53- 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 e8edb87df711..92e03929a6b2 100644
--- a/Documentation/video4linux/bttv/README.quirks
+++ b/Documentation/video4linux/bttv/README.quirks
@@ -38,9 +38,9 @@ tolerate.
38------------------------ 38------------------------
39 39
40When using the 430FX PCI, the following rules will ensure 40When using the 430FX PCI, the following rules will ensure
41compatibility: 41compatibility:
42 42
43 (1) Deassert REQ at the same time as asserting FRAME. 43 (1) Deassert REQ at the same time as asserting FRAME.
44 (2) Do not reassert REQ to request another bus transaction until after 44 (2) Do not reassert REQ to request another bus transaction until after
45 finish-ing the previous transaction. 45 finish-ing the previous transaction.
46 46
diff --git a/Documentation/video4linux/bttv/THANKS b/Documentation/video4linux/bttv/THANKS
index 2085399da7d4..950aa781c2e9 100644
--- a/Documentation/video4linux/bttv/THANKS
+++ b/Documentation/video4linux/bttv/THANKS
@@ -1,6 +1,6 @@
1Many thanks to: 1Many thanks to:
2 2
3- Markus Schroeder <schroedm@uni-duesseldorf.de> for information on the Bt848 3- Markus Schroeder <schroedm@uni-duesseldorf.de> for information on the Bt848
4 and tuner programming and his control program xtvc. 4 and tuner programming and his control program xtvc.
5 5
6- Martin Buck <martin-2.buck@student.uni-ulm.de> for his great Videotext 6- Martin Buck <martin-2.buck@student.uni-ulm.de> for his great Videotext
@@ -16,7 +16,7 @@ Many thanks to:
16- MIRO for providing a free PCTV card and detailed information about the 16- MIRO for providing a free PCTV card and detailed information about the
17 components on their cards. (E.g. how the tuner type is detected) 17 components on their cards. (E.g. how the tuner type is detected)
18 Without their card I could not have debugged the NTSC mode. 18 Without their card I could not have debugged the NTSC mode.
19 19
20- Hauppauge for telling how the sound input is selected and what components 20- Hauppauge for telling how the sound input is selected and what components
21 they do and will use on their radio cards. 21 they do and will use on their radio cards.
22 Also many thanks for faxing me the FM1216 data sheet. 22 Also many thanks for faxing me the FM1216 data sheet.
diff --git a/Documentation/video4linux/radiotrack.txt b/Documentation/video4linux/radiotrack.txt
index 2b75345f13e3..d1f3ed199186 100644
--- a/Documentation/video4linux/radiotrack.txt
+++ b/Documentation/video4linux/radiotrack.txt
@@ -131,17 +131,17 @@ Check Stereo: BASE <-- 0xd8 (current volume, stereo detect,
131 x=0xff ==> "not stereo", x=0xfd ==> "stereo detected" 131 x=0xff ==> "not stereo", x=0xfd ==> "stereo detected"
132 132
133Set Frequency: code = (freq*40) + 10486188 133Set Frequency: code = (freq*40) + 10486188
134 foreach of the 24 bits in code, 134 foreach of the 24 bits in code,
135 (from Least to Most Significant): 135 (from Least to Most Significant):
136 to write a "zero" bit, 136 to write a "zero" bit,
137 BASE <-- 0x01 (audio mute, no stereo detect, radio 137 BASE <-- 0x01 (audio mute, no stereo detect, radio
138 disable, "zero" bit phase 1, tuner adjust) 138 disable, "zero" bit phase 1, tuner adjust)
139 BASE <-- 0x03 (audio mute, no stereo detect, radio 139 BASE <-- 0x03 (audio mute, no stereo detect, radio
140 disable, "zero" bit phase 2, tuner adjust) 140 disable, "zero" bit phase 2, tuner adjust)
141 to write a "one" bit, 141 to write a "one" bit,
142 BASE <-- 0x05 (audio mute, no stereo detect, radio 142 BASE <-- 0x05 (audio mute, no stereo detect, radio
143 disable, "one" bit phase 1, tuner adjust) 143 disable, "one" bit phase 1, tuner adjust)
144 BASE <-- 0x07 (audio mute, no stereo detect, radio 144 BASE <-- 0x07 (audio mute, no stereo detect, radio
145 disable, "one" bit phase 2, tuner adjust) 145 disable, "one" bit phase 2, tuner adjust)
146 146
147---------------------------------------------------------------------------- 147----------------------------------------------------------------------------
diff --git a/Documentation/video4linux/w9966.txt b/Documentation/video4linux/w9966.txt
index e7ac33a7eb06..78a651254b84 100644
--- a/Documentation/video4linux/w9966.txt
+++ b/Documentation/video4linux/w9966.txt
@@ -26,7 +26,7 @@ is called VIDEO_PALETTE_YUV422 (16 bpp).
26A minimal test application (with source) is available from: 26A minimal test application (with source) is available from:
27 http://hem.fyristorg.com/mogul/w9966.html 27 http://hem.fyristorg.com/mogul/w9966.html
28 28
29The slow framerate is due to missing DMA ECP read support in the 29The slow framerate is due to missing DMA ECP read support in the
30parport drivers. I might add working EPP support later. 30parport drivers. I might add working EPP support later.
31 31
32Good luck! 32Good luck!
diff --git a/Documentation/video4linux/zr36120.txt b/Documentation/video4linux/zr36120.txt
index 5d6357eefde4..ac6d92d01944 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
2------ --- ----- -------- -------- ------------ ------- - - - 2------ --- ----- -------- -------- ------------ ------- - - -
3 3
4- ZORAN ------------------------------------------------------ 4- ZORAN ------------------------------------------------------
5 Author: Pauline Middelink <middelin@polyware.nl> 5 Author: Pauline Middelink <middelin@polyware.nl>
6 Date: 18 September 1999 6 Date: 18 September 1999
7Version: 0.6.1 7Version: 0.6.1
8 8
@@ -115,7 +115,7 @@ After making/checking the devices do:
115<n> is the cardtype of the card you have. The cardnumber can 115<n> is the cardtype of the card you have. The cardnumber can
116be found in the source of zr36120. Look for tvcards. If your 116be found in the source of zr36120. Look for tvcards. If your
117card is not there, please try if any other card gives some 117card is not there, please try if any other card gives some
118response, and mail me if you got a working tvcard addition. 118response, and mail me if you got a working tvcard addition.
119 119
120PS. <TVCard editors behold!) 120PS. <TVCard editors behold!)
121 Dont forget to set video_input to the number of inputs 121 Dont forget to set video_input to the number of inputs
diff --git a/MAINTAINERS b/MAINTAINERS
index bfd7fbfe90ab..4e8fbbc5566d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -147,6 +147,18 @@ M: p_gortmaker@yahoo.com
147L: netdev@vger.kernel.org 147L: netdev@vger.kernel.org
148S: Maintained 148S: Maintained
149 149
1509P FILE SYSTEM
151P: Eric Van Hensbergen
152M: ericvh@gmail.com
153P: Ron Minnich
154M: rminnich@lanl.gov
155P: Latchesar Ionkov
156M: lucho@ionkov.net
157L: v9fs-developer@lists.sourceforge.net
158W: http://v9fs.sf.net
159T: git kernel.org:/pub/scm/linux/kernel/ericvh/v9fs.git
160S: Maintained
161
150A2232 SERIAL BOARD DRIVER 162A2232 SERIAL BOARD DRIVER
151P: Enver Haase 163P: Enver Haase
152M: ehaase@inf.fu-berlin.de 164M: ehaase@inf.fu-berlin.de
@@ -2013,12 +2025,6 @@ L: parisc-linux@parisc-linux.org
2013W: http://www.parisc-linux.org/ 2025W: http://www.parisc-linux.org/
2014S: Maintained 2026S: Maintained
2015 2027
2016PERSONALITY HANDLING
2017P: Christoph Hellwig
2018M: hch@infradead.org
2019L: linux-abi-devel@lists.sourceforge.net
2020S: Maintained
2021
2022PCI ERROR RECOVERY 2028PCI ERROR RECOVERY
2023P: Linas Vepstas 2029P: Linas Vepstas
2024M: linas@austin.ibm.com 2030M: linas@austin.ibm.com
@@ -2069,6 +2075,12 @@ M: tsbogend@alpha.franken.de
2069L: netdev@vger.kernel.org 2075L: netdev@vger.kernel.org
2070S: Maintained 2076S: Maintained
2071 2077
2078PERSONALITY HANDLING
2079P: Christoph Hellwig
2080M: hch@infradead.org
2081L: linux-abi-devel@lists.sourceforge.net
2082S: Maintained
2083
2072PHRAM MTD DRIVER 2084PHRAM MTD DRIVER
2073P: Jörn Engel 2085P: Jörn Engel
2074M: joern@wh.fh-wedel.de 2086M: joern@wh.fh-wedel.de
@@ -2212,13 +2224,6 @@ S: Maintained
2212RISCOM8 DRIVER 2224RISCOM8 DRIVER
2213S: Orphan 2225S: Orphan
2214 2226
2215RTLINUX REALTIME LINUX
2216P: Victor Yodaiken
2217M: yodaiken@fsmlabs.com
2218L: rtl@rtlinux.org
2219W: www.rtlinux.org
2220S: Maintained
2221
2222S3 SAVAGE FRAMEBUFFER DRIVER 2227S3 SAVAGE FRAMEBUFFER DRIVER
2223P: Antonino Daplas 2228P: Antonino Daplas
2224M: adaplas@pol.net 2229M: adaplas@pol.net
@@ -2488,6 +2493,13 @@ M: kristen.c.accardi@intel.com
2488L: pcihpd-discuss@lists.sourceforge.net 2493L: pcihpd-discuss@lists.sourceforge.net
2489S: Maintained 2494S: Maintained
2490 2495
2496SECURE DIGITAL HOST CONTROLLER INTERFACE DRIVER
2497P: Pierre Ossman
2498M: drzeus-sdhci@drzeus.cx
2499L: sdhci-devel@list.drzeus.cx
2500W: http://mmc.drzeus.cx/wiki/Linux/Drivers/sdhci
2501S: Maintained
2502
2491SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS 2503SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS
2492P: Stephen Hemminger 2504P: Stephen Hemminger
2493M: shemminger@osdl.org 2505M: shemminger@osdl.org
@@ -2524,7 +2536,6 @@ S: Unsupported ?
2524STRADIS MPEG-2 DECODER DRIVER 2536STRADIS MPEG-2 DECODER DRIVER
2525P: Nathan Laredo 2537P: Nathan Laredo
2526M: laredo@gnu.org 2538M: laredo@gnu.org
2527W: http://mpeg.openprojects.net/
2528W: http://www.stradis.com/ 2539W: http://www.stradis.com/
2529S: Maintained 2540S: Maintained
2530 2541
@@ -2643,7 +2654,7 @@ S: Maintained
2643 2654
2644TUN/TAP driver 2655TUN/TAP driver
2645P: Maxim Krasnyansky 2656P: Maxim Krasnyansky
2646M: maxk@qualcomm.com, max_mk@yahoo.com 2657M: maxk@qualcomm.com
2647L: vtun@office.satix.net 2658L: vtun@office.satix.net
2648W: http://vtun.sourceforge.net/tun 2659W: http://vtun.sourceforge.net/tun
2649S: Maintained 2660S: Maintained
@@ -2972,18 +2983,6 @@ L: rio500-users@lists.sourceforge.net
2972W: http://rio500.sourceforge.net 2983W: http://rio500.sourceforge.net
2973S: Maintained 2984S: Maintained
2974 2985
2975V9FS FILE SYSTEM
2976P: Eric Van Hensbergen
2977M: ericvh@gmail.com
2978P: Ron Minnich
2979M: rminnich@lanl.gov
2980P: Latchesar Ionkov
2981M: lucho@ionkov.net
2982L: v9fs-developer@lists.sourceforge.net
2983W: http://v9fs.sf.net
2984T: git kernel.org:/pub/scm/linux/kernel/ericvh/v9fs-devel.git
2985S: Maintained
2986
2987VIDEO FOR LINUX 2986VIDEO FOR LINUX
2988P: Mauro Carvalho Chehab 2987P: Mauro Carvalho Chehab
2989M: mchehab@infradead.org 2988M: mchehab@infradead.org
diff --git a/Makefile b/Makefile
index cb5790580fca..af6210d48836 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,7 @@ ifdef O
95endif 95endif
96 96
97# That's our default target when none is given on the command line 97# That's our default target when none is given on the command line
98.PHONY: _all 98PHONY := _all
99_all: 99_all:
100 100
101ifneq ($(KBUILD_OUTPUT),) 101ifneq ($(KBUILD_OUTPUT),)
@@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
106$(if $(KBUILD_OUTPUT),, \ 106$(if $(KBUILD_OUTPUT),, \
107 $(error output directory "$(saved-output)" does not exist)) 107 $(error output directory "$(saved-output)" does not exist))
108 108
109.PHONY: $(MAKECMDGOALS) 109PHONY += $(MAKECMDGOALS)
110 110
111$(filter-out _all,$(MAKECMDGOALS)) _all: 111$(filter-out _all,$(MAKECMDGOALS)) _all:
112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ 112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
@@ -123,7 +123,7 @@ ifeq ($(skip-makefile),)
123 123
124# If building an external module we do not care about the all: rule 124# If building an external module we do not care about the all: rule
125# but instead _all depend on modules 125# but instead _all depend on modules
126.PHONY: all 126PHONY += all
127ifeq ($(KBUILD_EXTMOD),) 127ifeq ($(KBUILD_EXTMOD),)
128_all: all 128_all: all
129else 129else
@@ -137,7 +137,7 @@ objtree := $(CURDIR)
137src := $(srctree) 137src := $(srctree)
138obj := $(objtree) 138obj := $(objtree)
139 139
140VPATH := $(srctree) 140VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
141 141
142export srctree objtree VPATH TOPDIR 142export srctree objtree VPATH TOPDIR
143 143
@@ -151,7 +151,7 @@ export srctree objtree VPATH TOPDIR
151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ 151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
152 -e s/arm.*/arm/ -e s/sa110/arm/ \ 152 -e s/arm.*/arm/ -e s/sa110/arm/ \
153 -e s/s390x/s390/ -e s/parisc64/parisc/ \ 153 -e s/s390x/s390/ -e s/parisc64/parisc/ \
154 -e s/ppc.*/powerpc/ ) 154 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
155 155
156# Cross compiling and selecting different set of gcc/bin-utils 156# Cross compiling and selecting different set of gcc/bin-utils
157# --------------------------------------------------------------------------- 157# ---------------------------------------------------------------------------
@@ -258,38 +258,6 @@ endif
258 258
259export quiet Q KBUILD_VERBOSE 259export quiet Q KBUILD_VERBOSE
260 260
261######
262# cc support functions to be used (only) in arch/$(ARCH)/Makefile
263# See documentation in Documentation/kbuild/makefiles.txt
264
265# as-option
266# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
267
268as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
269 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
270 else echo "$(2)"; fi ;)
271
272# cc-option
273# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
274
275cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
276 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
277
278# cc-option-yn
279# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
280cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
281 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
282
283# cc-option-align
284# Prefix align with either -falign or -malign
285cc-option-align = $(subst -functions=0,,\
286 $(call cc-option,-falign-functions=0,-malign-functions=0))
287
288# cc-version
289# Usage gcc-ver := $(call cc-version $(CC))
290cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
291 $(if $(1), $(1), $(CC)))
292
293 261
294# Look for make include files relative to root of kernel src 262# Look for make include files relative to root of kernel src
295MAKEFLAGS += --include-dir=$(srctree) 263MAKEFLAGS += --include-dir=$(srctree)
@@ -338,8 +306,7 @@ LINUXINCLUDE := -Iinclude \
338CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 306CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
339 307
340CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 308CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
341 -fno-strict-aliasing -fno-common \ 309 -fno-strict-aliasing -fno-common
342 -ffreestanding
343AFLAGS := -D__ASSEMBLY__ 310AFLAGS := -D__ASSEMBLY__
344 311
345# Read KERNELRELEASE from .kernelrelease (if it exists) 312# Read KERNELRELEASE from .kernelrelease (if it exists)
@@ -369,14 +336,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
369# Rules shared between *config targets and build targets 336# Rules shared between *config targets and build targets
370 337
371# Basic helpers built in scripts/ 338# Basic helpers built in scripts/
372.PHONY: scripts_basic 339PHONY += scripts_basic
373scripts_basic: 340scripts_basic:
374 $(Q)$(MAKE) $(build)=scripts/basic 341 $(Q)$(MAKE) $(build)=scripts/basic
375 342
376# To avoid any implicit rule to kick in, define an empty command. 343# To avoid any implicit rule to kick in, define an empty command.
377scripts/basic/%: scripts_basic ; 344scripts/basic/%: scripts_basic ;
378 345
379.PHONY: outputmakefile 346PHONY += outputmakefile
380# outputmakefile generate a Makefile to be placed in output directory, if 347# outputmakefile generate a Makefile to be placed in output directory, if
381# using a seperate output directory. This allows convinient use 348# using a seperate output directory. This allows convinient use
382# of make in output directory 349# of make in output directory
@@ -452,7 +419,7 @@ ifeq ($(KBUILD_EXTMOD),)
452# Additional helpers built in scripts/ 419# Additional helpers built in scripts/
453# Carefully list dependencies so we do not try to build scripts twice 420# Carefully list dependencies so we do not try to build scripts twice
454# in parrallel 421# in parrallel
455.PHONY: scripts 422PHONY += scripts
456scripts: scripts_basic include/config/MARKER 423scripts: scripts_basic include/config/MARKER
457 $(Q)$(MAKE) $(build)=$(@) 424 $(Q)$(MAKE) $(build)=$(@)
458 425
@@ -504,19 +471,16 @@ else
504CFLAGS += -O2 471CFLAGS += -O2
505endif 472endif
506 473
507#Add align options if CONFIG_CC_* is not equal to 0
508add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1)))
509CFLAGS += $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions)
510CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels)
511CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
512CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
513
514ifdef CONFIG_FRAME_POINTER 474ifdef CONFIG_FRAME_POINTER
515CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) 475CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
516else 476else
517CFLAGS += -fomit-frame-pointer 477CFLAGS += -fomit-frame-pointer
518endif 478endif
519 479
480ifdef CONFIG_UNWIND_INFO
481CFLAGS += -fasynchronous-unwind-tables
482endif
483
520ifdef CONFIG_DEBUG_INFO 484ifdef CONFIG_DEBUG_INFO
521CFLAGS += -g 485CFLAGS += -g
522endif 486endif
@@ -752,7 +716,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
752# make menuconfig etc. 716# make menuconfig etc.
753# Error messages still appears in the original language 717# Error messages still appears in the original language
754 718
755.PHONY: $(vmlinux-dirs) 719PHONY += $(vmlinux-dirs)
756$(vmlinux-dirs): prepare scripts 720$(vmlinux-dirs): prepare scripts
757 $(Q)$(MAKE) $(build)=$@ 721 $(Q)$(MAKE) $(build)=$@
758 722
@@ -805,10 +769,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full)
805# version.h and scripts_basic is processed / created. 769# version.h and scripts_basic is processed / created.
806 770
807# Listed in dependency order 771# Listed in dependency order
808.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 772PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
809 773
810# prepare-all is deprecated, use prepare as valid replacement 774# prepare-all is deprecated, use prepare as valid replacement
811.PHONY: prepare-all 775PHONY += prepare-all
812 776
813# prepare3 is used to check if we are building in a separate output directory, 777# prepare3 is used to check if we are building in a separate output directory,
814# and if so do: 778# and if so do:
@@ -849,27 +813,6 @@ prepare prepare-all: prepare0
849 813
850export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) 814export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
851 815
852# Single targets
853# ---------------------------------------------------------------------------
854
855%.s: %.c scripts FORCE
856 $(Q)$(MAKE) $(build)=$(@D) $@
857%.i: %.c scripts FORCE
858 $(Q)$(MAKE) $(build)=$(@D) $@
859%.o: %.c scripts FORCE
860 $(Q)$(MAKE) $(build)=$(@D) $@
861%.ko: scripts FORCE
862 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) $(@:.ko=.o)
863 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
864%/: scripts prepare FORCE
865 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
866%.lst: %.c scripts FORCE
867 $(Q)$(MAKE) $(build)=$(@D) $@
868%.s: %.S scripts FORCE
869 $(Q)$(MAKE) $(build)=$(@D) $@
870%.o: %.S scripts FORCE
871 $(Q)$(MAKE) $(build)=$(@D) $@
872
873# FIXME: The asm symlink changes when $(ARCH) changes. That's 816# FIXME: The asm symlink changes when $(ARCH) changes. That's
874# hard to detect, but I suppose "make mrproper" is a good idea 817# hard to detect, but I suppose "make mrproper" is a good idea
875# before switching between archs anyway. 818# before switching between archs anyway.
@@ -910,7 +853,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE
910 853
911# --------------------------------------------------------------------------- 854# ---------------------------------------------------------------------------
912 855
913.PHONY: depend dep 856PHONY += depend dep
914depend dep: 857depend dep:
915 @echo '*** Warning: make $@ is unnecessary now.' 858 @echo '*** Warning: make $@ is unnecessary now.'
916 859
@@ -925,21 +868,21 @@ all: modules
925 868
926# Build modules 869# Build modules
927 870
928.PHONY: modules 871PHONY += modules
929modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) 872modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
930 @echo ' Building modules, stage 2.'; 873 @echo ' Building modules, stage 2.';
931 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 874 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
932 875
933 876
934# Target to prepare building external modules 877# Target to prepare building external modules
935.PHONY: modules_prepare 878PHONY += modules_prepare
936modules_prepare: prepare scripts 879modules_prepare: prepare scripts
937 880
938# Target to install modules 881# Target to install modules
939.PHONY: modules_install 882PHONY += modules_install
940modules_install: _modinst_ _modinst_post 883modules_install: _modinst_ _modinst_post
941 884
942.PHONY: _modinst_ 885PHONY += _modinst_
943_modinst_: 886_modinst_:
944 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ 887 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
945 echo "Warning: you may need to install module-init-tools"; \ 888 echo "Warning: you may need to install module-init-tools"; \
@@ -966,7 +909,7 @@ depmod_opts :=
966else 909else
967depmod_opts := -b $(INSTALL_MOD_PATH) -r 910depmod_opts := -b $(INSTALL_MOD_PATH) -r
968endif 911endif
969.PHONY: _modinst_post 912PHONY += _modinst_post
970_modinst_post: _modinst_ 913_modinst_post: _modinst_
971 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi 914 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
972 915
@@ -1009,7 +952,7 @@ clean: rm-dirs := $(CLEAN_DIRS)
1009clean: rm-files := $(CLEAN_FILES) 952clean: rm-files := $(CLEAN_FILES)
1010clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) 953clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
1011 954
1012.PHONY: $(clean-dirs) clean archclean 955PHONY += $(clean-dirs) clean archclean
1013$(clean-dirs): 956$(clean-dirs):
1014 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 957 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1015 958
@@ -1027,7 +970,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
1027mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 970mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1028mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) 971mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
1029 972
1030.PHONY: $(mrproper-dirs) mrproper archmrproper 973PHONY += $(mrproper-dirs) mrproper archmrproper
1031$(mrproper-dirs): 974$(mrproper-dirs):
1032 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 975 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1033 976
@@ -1037,7 +980,7 @@ mrproper: clean archmrproper $(mrproper-dirs)
1037 980
1038# distclean 981# distclean
1039# 982#
1040.PHONY: distclean 983PHONY += distclean
1041 984
1042distclean: mrproper 985distclean: mrproper
1043 @find $(srctree) $(RCS_FIND_IGNORE) \ 986 @find $(srctree) $(RCS_FIND_IGNORE) \
@@ -1053,12 +996,10 @@ distclean: mrproper
1053# rpm target kept for backward compatibility 996# rpm target kept for backward compatibility
1054package-dir := $(srctree)/scripts/package 997package-dir := $(srctree)/scripts/package
1055 998
1056.PHONY: %-pkg rpm
1057
1058%pkg: FORCE 999%pkg: FORCE
1059 $(Q)$(MAKE) -f $(package-dir)/Makefile $@ 1000 $(Q)$(MAKE) $(build)=$(package-dir) $@
1060rpm: FORCE 1001rpm: FORCE
1061 $(Q)$(MAKE) -f $(package-dir)/Makefile $@ 1002 $(Q)$(MAKE) $(build)=$(package-dir) $@
1062 1003
1063 1004
1064# Brief documentation of the typical targets used 1005# Brief documentation of the typical targets used
@@ -1090,13 +1031,11 @@ help:
1090 @echo ' kernelversion - Output the version stored in Makefile' 1031 @echo ' kernelversion - Output the version stored in Makefile'
1091 @echo '' 1032 @echo ''
1092 @echo 'Static analysers' 1033 @echo 'Static analysers'
1093 @echo ' buildcheck - List dangling references to vmlinux discarded sections'
1094 @echo ' and init sections from non-init sections'
1095 @echo ' checkstack - Generate a list of stack hogs' 1034 @echo ' checkstack - Generate a list of stack hogs'
1096 @echo ' namespacecheck - Name space analysis on compiled kernel' 1035 @echo ' namespacecheck - Name space analysis on compiled kernel'
1097 @echo '' 1036 @echo ''
1098 @echo 'Kernel packaging:' 1037 @echo 'Kernel packaging:'
1099 @$(MAKE) -f $(package-dir)/Makefile help 1038 @$(MAKE) $(build)=$(package-dir) help
1100 @echo '' 1039 @echo ''
1101 @echo 'Documentation targets:' 1040 @echo 'Documentation targets:'
1102 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp 1041 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
@@ -1145,11 +1084,12 @@ else # KBUILD_EXTMOD
1145 1084
1146# We are always building modules 1085# We are always building modules
1147KBUILD_MODULES := 1 1086KBUILD_MODULES := 1
1148.PHONY: crmodverdir 1087PHONY += crmodverdir
1149crmodverdir: 1088crmodverdir:
1089 $(Q)rm -rf $(MODVERDIR)
1150 $(Q)mkdir -p $(MODVERDIR) 1090 $(Q)mkdir -p $(MODVERDIR)
1151 1091
1152.PHONY: $(objtree)/Module.symvers 1092PHONY += $(objtree)/Module.symvers
1153$(objtree)/Module.symvers: 1093$(objtree)/Module.symvers:
1154 @test -e $(objtree)/Module.symvers || ( \ 1094 @test -e $(objtree)/Module.symvers || ( \
1155 echo; \ 1095 echo; \
@@ -1158,7 +1098,7 @@ $(objtree)/Module.symvers:
1158 echo ) 1098 echo )
1159 1099
1160module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) 1100module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1161.PHONY: $(module-dirs) modules 1101PHONY += $(module-dirs) modules
1162$(module-dirs): crmodverdir $(objtree)/Module.symvers 1102$(module-dirs): crmodverdir $(objtree)/Module.symvers
1163 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) 1103 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1164 1104
@@ -1166,13 +1106,32 @@ modules: $(module-dirs)
1166 @echo ' Building modules, stage 2.'; 1106 @echo ' Building modules, stage 2.';
1167 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 1107 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1168 1108
1169.PHONY: modules_install 1109PHONY += modules_install
1170modules_install: 1110modules_install: _emodinst_ _emodinst_post
1111
1112install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1113PHONY += _emodinst_
1114_emodinst_:
1115 $(Q)rm -rf $(MODLIB)/$(install-dir)
1116 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1171 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst 1117 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
1172 1118
1119# Run depmod only is we have System.map and depmod is executable
1120quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1121 cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
1122 $(DEPMOD) -ae -F System.map \
1123 $(if $(strip $(INSTALL_MOD_PATH)), \
1124 -b $(INSTALL_MOD_PATH) -r) \
1125 $(KERNELRELEASE); \
1126 fi
1127
1128PHONY += _emodinst_post
1129_emodinst_post: _emodinst_
1130 $(call cmd,depmod)
1131
1173clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) 1132clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1174 1133
1175.PHONY: $(clean-dirs) clean 1134PHONY += $(clean-dirs) clean
1176$(clean-dirs): 1135$(clean-dirs):
1177 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1136 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1178 1137
@@ -1192,6 +1151,11 @@ help:
1192 @echo ' modules_install - install the module' 1151 @echo ' modules_install - install the module'
1193 @echo ' clean - remove generated files in module directory only' 1152 @echo ' clean - remove generated files in module directory only'
1194 @echo '' 1153 @echo ''
1154
1155# Dummies...
1156PHONY += prepare scripts
1157prepare: ;
1158scripts: ;
1195endif # KBUILD_EXTMOD 1159endif # KBUILD_EXTMOD
1196 1160
1197# Generate tags for editors 1161# Generate tags for editors
@@ -1292,17 +1256,13 @@ versioncheck:
1292 -name '*.[hcS]' -type f -print | sort \ 1256 -name '*.[hcS]' -type f -print | sort \
1293 | xargs $(PERL) -w scripts/checkversion.pl 1257 | xargs $(PERL) -w scripts/checkversion.pl
1294 1258
1295buildcheck:
1296 $(PERL) $(srctree)/scripts/reference_discarded.pl
1297 $(PERL) $(srctree)/scripts/reference_init.pl
1298
1299namespacecheck: 1259namespacecheck:
1300 $(PERL) $(srctree)/scripts/namespace.pl 1260 $(PERL) $(srctree)/scripts/namespace.pl
1301 1261
1302endif #ifeq ($(config-targets),1) 1262endif #ifeq ($(config-targets),1)
1303endif #ifeq ($(mixed-targets),1) 1263endif #ifeq ($(mixed-targets),1)
1304 1264
1305.PHONY: checkstack 1265PHONY += checkstack
1306checkstack: 1266checkstack:
1307 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1267 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1308 $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1268 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
@@ -1313,6 +1273,44 @@ kernelrelease:
1313kernelversion: 1273kernelversion:
1314 @echo $(KERNELVERSION) 1274 @echo $(KERNELVERSION)
1315 1275
1276# Single targets
1277# ---------------------------------------------------------------------------
1278# The directory part is taken from first prerequisite, so this
1279# works even with external modules
1280%.s: %.c prepare scripts FORCE
1281 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1282%.i: %.c prepare scripts FORCE
1283 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1284%.o: %.c prepare scripts FORCE
1285 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1286%.lst: %.c prepare scripts FORCE
1287 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1288%.s: %.S prepare scripts FORCE
1289 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1290%.o: %.S prepare scripts FORCE
1291 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1292
1293# For external modules we shall include any directory of the target,
1294# but usual case there is no directory part.
1295# make M=`pwd` module.o => $(dir $@)=./
1296# make M=`pwd` foo/module.o => $(dir $@)=foo/
1297# make M=`pwd` / => $(dir $@)=/
1298
1299ifeq ($(KBUILD_EXTMOD),)
1300 target-dir = $(@D)
1301else
1302 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1303 target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1304endif
1305
1306/ %/: scripts prepare FORCE
1307 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1308 $(build)=$(target-dir)
1309%.ko: scripts FORCE
1310 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1311 $(build)=$(target-dir) $(@:.ko=.o)
1312 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1313
1316# FIXME Should go into a make.lib or something 1314# FIXME Should go into a make.lib or something
1317# =========================================================================== 1315# ===========================================================================
1318 1316
@@ -1347,4 +1345,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1347 1345
1348endif # skip-makefile 1346endif # skip-makefile
1349 1347
1348PHONY += FORCE
1350FORCE: 1349FORCE:
1350
1351
1352# Declare the contents of the .PHONY variable as phony. We keep that
1353# information in a variable se we can use it in if_changed and friends.
1354.PHONY: $(PHONY)
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index b5b1e4087516..99c0d323719a 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm/Makefile 2# arch/arm/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -177,7 +180,7 @@ endif
177 180
178archprepare: maketools 181archprepare: maketools
179 182
180.PHONY: maketools FORCE 183PHONY += maketools FORCE
181maketools: include/linux/version.h include/asm-arm/.arch FORCE 184maketools: include/linux/version.h include/asm-arm/.arch FORCE
182 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h 185 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
183 186
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index a174d63395ea..ec9c400c7f82 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm/boot/Makefile 2# arch/arm/boot/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -73,7 +76,7 @@ $(obj)/bootpImage: $(obj)/bootp/bootp FORCE
73 $(call if_changed,objcopy) 76 $(call if_changed,objcopy)
74 @echo ' Kernel: $@ is ready' 77 @echo ' Kernel: $@ is ready'
75 78
76.PHONY: initrd FORCE 79PHONY += initrd FORCE
77initrd: 80initrd:
78 @test "$(INITRD_PHYS)" != "" || \ 81 @test "$(INITRD_PHYS)" != "" || \
79 (echo This machine does not support INITRD; exit -1) 82 (echo This machine does not support INITRD; exit -1)
diff --git a/arch/arm/boot/bootp/Makefile b/arch/arm/boot/bootp/Makefile
index 8e8879b6b3d7..c394e305447c 100644
--- a/arch/arm/boot/bootp/Makefile
+++ b/arch/arm/boot/bootp/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# linux/arch/arm/boot/bootp/Makefile 2# linux/arch/arm/boot/bootp/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4 7
5LDFLAGS_bootp :=-p --no-undefined -X \ 8LDFLAGS_bootp :=-p --no-undefined -X \
6 --defsym initrd_phys=$(INITRD_PHYS) \ 9 --defsym initrd_phys=$(INITRD_PHYS) \
@@ -21,4 +24,4 @@ $(obj)/kernel.o: arch/arm/boot/zImage FORCE
21 24
22$(obj)/initrd.o: $(INITRD) FORCE 25$(obj)/initrd.o: $(INITRD) FORCE
23 26
24.PHONY: $(INITRD) FORCE 27PHONY += $(INITRD) FORCE
diff --git a/arch/arm/mach-pxa/leds-mainstone.c b/arch/arm/mach-pxa/leds-mainstone.c
index bbd3f87a9fc2..c06d3d7a8dd4 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)
85 break; 85 break;
86 86
87 case led_green_on: 87 case led_green_on:
88 hw_led_state |= D21;; 88 hw_led_state |= D21;
89 break; 89 break;
90 90
91 case led_green_off: 91 case led_green_off:
@@ -93,7 +93,7 @@ void mainstone_leds_event(led_event_t evt)
93 break; 93 break;
94 94
95 case led_amber_on: 95 case led_amber_on:
96 hw_led_state |= D22;; 96 hw_led_state |= D22;
97 break; 97 break;
98 98
99 case led_amber_off: 99 case led_amber_off:
@@ -101,7 +101,7 @@ void mainstone_leds_event(led_event_t evt)
101 break; 101 break;
102 102
103 case led_red_on: 103 case led_red_on:
104 hw_led_state |= D23;; 104 hw_led_state |= D23;
105 break; 105 break;
106 106
107 case led_red_off: 107 case led_red_off:
diff --git a/arch/arm/mach-s3c2410/cpu.c b/arch/arm/mach-s3c2410/cpu.c
index 00a379334b60..70c34fcf7858 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)
146 board = b; 146 board = b;
147 147
148 if (b->clocks_count != 0) { 148 if (b->clocks_count != 0) {
149 struct clk **ptr = b->clocks;; 149 struct clk **ptr = b->clocks;
150 150
151 for (i = b->clocks_count; i > 0; i--, ptr++) 151 for (i = b->clocks_count; i > 0; i--, ptr++)
152 s3c24xx_register_clock(*ptr); 152 s3c24xx_register_clock(*ptr);
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 6888816a1935..102454082474 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -40,6 +40,7 @@
40#include <asm/hardware/scoop.h> 40#include <asm/hardware/scoop.h>
41#include <asm/mach/sharpsl_param.h> 41#include <asm/mach/sharpsl_param.h>
42#include <asm/hardware/locomo.h> 42#include <asm/hardware/locomo.h>
43#include <asm/arch/mcp.h>
43 44
44#include "generic.h" 45#include "generic.h"
45 46
@@ -66,6 +67,32 @@ struct platform_device colliescoop_device = {
66 .resource = collie_scoop_resources, 67 .resource = collie_scoop_resources,
67}; 68};
68 69
70static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
71{
72 .dev = &colliescoop_device.dev,
73 .irq = COLLIE_IRQ_GPIO_CF_IRQ,
74 .cd_irq = COLLIE_IRQ_GPIO_CF_CD,
75 .cd_irq_str = "PCMCIA0 CD",
76},
77};
78
79static struct scoop_pcmcia_config collie_pcmcia_config = {
80 .devs = &collie_pcmcia_scoop[0],
81 .num_devs = 1,
82};
83
84
85static struct mcp_plat_data collie_mcp_data = {
86 .mccr0 = MCCR0_ADM,
87 .sclk_rate = 11981000,
88};
89
90
91static struct sa1100_port_fns collie_port_fns __initdata = {
92 .set_mctrl = collie_uart_set_mctrl,
93 .get_mctrl = collie_uart_get_mctrl,
94};
95
69 96
70static struct resource locomo_resources[] = { 97static struct resource locomo_resources[] = {
71 [0] = { 98 [0] = {
@@ -159,6 +186,8 @@ static void __init collie_init(void)
159 GPDR |= GPIO_32_768kHz; 186 GPDR |= GPIO_32_768kHz;
160 TUCR = TUCR_32_768kHz; 187 TUCR = TUCR_32_768kHz;
161 188
189 platform_scoop_config = &collie_pcmcia_config;
190
162 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 191 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
163 if (ret) { 192 if (ret) {
164 printk(KERN_WARNING "collie: Unable to register LoCoMo device\n"); 193 printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
@@ -166,6 +195,7 @@ static void __init collie_init(void)
166 195
167 sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources, 196 sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources,
168 ARRAY_SIZE(collie_flash_resources)); 197 ARRAY_SIZE(collie_flash_resources));
198 sa11x0_set_mcp_data(&collie_mcp_data);
169 199
170 sharpsl_save_param(); 200 sharpsl_save_param();
171} 201}
diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile
index 844a9e46886e..fe91eda98a94 100644
--- a/arch/arm26/Makefile
+++ b/arch/arm26/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm26/Makefile 2# arch/arm26/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -49,9 +52,9 @@ all: zImage
49 52
50boot := arch/arm26/boot 53boot := arch/arm26/boot
51 54
52.PHONY: maketools FORCE 55PHONY += maketools FORCE
53maketools: FORCE 56maketools: FORCE
54 57
55 58
56# Convert bzImage to zImage 59# Convert bzImage to zImage
57bzImage: vmlinux 60bzImage: vmlinux
diff --git a/arch/arm26/boot/Makefile b/arch/arm26/boot/Makefile
index b5c2277654d4..68acb7b0d47f 100644
--- a/arch/arm26/boot/Makefile
+++ b/arch/arm26/boot/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm26/boot/Makefile 2# arch/arm26/boot/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -60,7 +63,7 @@ $(obj)/xipImage: vmlinux FORCE
60 @echo ' Kernel: $@ is ready' 63 @echo ' Kernel: $@ is ready'
61endif 64endif
62 65
63.PHONY: initrd 66PHONY += initrd
64initrd: 67initrd:
65 @test "$(INITRD_PHYS)" != "" || \ 68 @test "$(INITRD_PHYS)" != "" || \
66 (echo This machine does not support INITRD; exit -1) 69 (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 501fa52d8d3a..c59ee28a35f4 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
2944 int spdl_err; 2944 int spdl_err;
2945 /* Mark output pages dirty. */ 2945 /* Mark output pages dirty. */
2946 spdl_err = set_page_dirty_lock(outpages[i]); 2946 spdl_err = set_page_dirty_lock(outpages[i]);
2947 DEBUG(if (spdl_err)printk("cryptocop_ioctl_process: set_page_dirty_lock returned %d\n", spdl_err)); 2947 DEBUG(if (spdl_err < 0)printk("cryptocop_ioctl_process: set_page_dirty_lock returned %d\n", spdl_err));
2948 } 2948 }
2949 for (i = 0; i < nooutpages; i++){ 2949 for (i = 0; i < nooutpages; i++){
2950 put_page(outpages[i]); 2950 put_page(outpages[i]);
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 4ab3e87115b6..123451c44154 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -116,6 +116,7 @@
116#include <asm/pgtable.h> 116#include <asm/pgtable.h>
117#include <asm/uaccess.h> 117#include <asm/uaccess.h>
118#include <asm/irq.h> 118#include <asm/irq.h>
119#include <asm/system.h>
119#include <linux/module.h> 120#include <linux/module.h>
120#include <linux/spinlock.h> 121#include <linux/spinlock.h>
121#include <linux/fs_struct.h> 122#include <linux/fs_struct.h>
@@ -194,8 +195,6 @@ EXPORT_SYMBOL(enable_hlt);
194 */ 195 */
195void (*pm_idle)(void); 196void (*pm_idle)(void);
196 197
197extern void default_idle(void);
198
199/* 198/*
200 * The idle thread. There's no useful work to be 199 * The idle thread. There's no useful work to be
201 * done, so just try to conserve power and have a 200 * 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 8f860d9c4947..508601fad079 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -1406,7 +1406,7 @@ void gdbstub(int sigval)
1406 __debug_frame->psr |= PSR_S; 1406 __debug_frame->psr |= PSR_S;
1407 __debug_regs->brr = (__debug_frame->tbr & TBR_TT) << 12; 1407 __debug_regs->brr = (__debug_frame->tbr & TBR_TT) << 12;
1408 __debug_regs->brr |= BRR_EB; 1408 __debug_regs->brr |= BRR_EB;
1409 sigval = SIGXCPU;; 1409 sigval = SIGXCPU;
1410 } 1410 }
1411 1411
1412 LEDS(0x5002); 1412 LEDS(0x5002);
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index dd344f112cfe..16ccddc69c2b 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -54,7 +54,7 @@ asmlinkage void ret_from_fork(void);
54 * The idle loop on an H8/300.. 54 * The idle loop on an H8/300..
55 */ 55 */
56#if !defined(CONFIG_H8300H_SIM) && !defined(CONFIG_H8S_SIM) 56#if !defined(CONFIG_H8300H_SIM) && !defined(CONFIG_H8S_SIM)
57void default_idle(void) 57static void default_idle(void)
58{ 58{
59 local_irq_disable(); 59 local_irq_disable();
60 if (!need_resched()) { 60 if (!need_resched()) {
@@ -65,7 +65,7 @@ void default_idle(void)
65 local_irq_enable(); 65 local_irq_enable();
66} 66}
67#else 67#else
68void default_idle(void) 68static void default_idle(void)
69{ 69{
70 cpu_relax(); 70 cpu_relax();
71} 71}
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index bfea1bedcbf2..b008fb0cd7b7 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -737,7 +737,7 @@ config PHYSICAL_START
737 737
738config HOTPLUG_CPU 738config HOTPLUG_CPU
739 bool "Support for hot-pluggable CPUs (EXPERIMENTAL)" 739 bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
740 depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER 740 depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER && !X86_PC
741 ---help--- 741 ---help---
742 Say Y here to experiment with turning CPUs off and on. CPUs 742 Say Y here to experiment with turning CPUs off and on. CPUs
743 can be controlled through /sys/devices/system/cpu. 743 can be controlled through /sys/devices/system/cpu.
diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug
index 00108ba9a78d..6e97df6979e8 100644
--- a/arch/i386/Kconfig.debug
+++ b/arch/i386/Kconfig.debug
@@ -44,8 +44,8 @@ comment "Page alloc debug is incompatible with Software Suspend on i386"
44 depends on DEBUG_KERNEL && SOFTWARE_SUSPEND 44 depends on DEBUG_KERNEL && SOFTWARE_SUSPEND
45 45
46config DEBUG_PAGEALLOC 46config DEBUG_PAGEALLOC
47 bool "Page alloc debugging" 47 bool "Debug page memory allocations"
48 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND 48 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND && !HUGETLBFS
49 help 49 help
50 Unmap pages from the kernel linear mapping after free_pages(). 50 Unmap pages from the kernel linear mapping after free_pages().
51 This results in a large slowdown, but helps to find certain types 51 This results in a large slowdown, but helps to find certain types
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 36bef6543ac1..c848a5b30391 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -39,6 +39,9 @@ include $(srctree)/arch/i386/Makefile.cpu
39 39
40cflags-$(CONFIG_REGPARM) += -mregparm=3 40cflags-$(CONFIG_REGPARM) += -mregparm=3
41 41
42# temporary until string.h is fixed
43cflags-y += -ffreestanding
44
42# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use 45# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
43# a lot more stack due to the lack of sharing of stacklots: 46# a lot more stack due to the lack of sharing of stacklots:
44CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;) 47CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
@@ -99,8 +102,8 @@ AFLAGS += $(mflags-y)
99 102
100boot := arch/i386/boot 103boot := arch/i386/boot
101 104
102.PHONY: zImage bzImage compressed zlilo bzlilo \ 105PHONY += zImage bzImage compressed zlilo bzlilo \
103 zdisk bzdisk fdimage fdimage144 fdimage288 install 106 zdisk bzdisk fdimage fdimage144 fdimage288 install
104 107
105all: bzImage 108all: bzImage
106 109
diff --git a/arch/i386/Makefile.cpu b/arch/i386/Makefile.cpu
index dcd936ef45db..a11befba26d5 100644
--- a/arch/i386/Makefile.cpu
+++ b/arch/i386/Makefile.cpu
@@ -39,3 +39,7 @@ cflags-$(CONFIG_X86_ELAN) += -march=i486
39# Geode GX1 support 39# Geode GX1 support
40cflags-$(CONFIG_MGEODEGX1) += -march=pentium-mmx 40cflags-$(CONFIG_MGEODEGX1) += -march=pentium-mmx
41 41
42# add at the end to overwrite eventual tuning options from earlier
43# cpu entries
44cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic)
45
diff --git a/arch/i386/boot/edd.S b/arch/i386/boot/edd.S
index d8d69f2b911d..4b84ea216f2b 100644
--- a/arch/i386/boot/edd.S
+++ b/arch/i386/boot/edd.S
@@ -76,6 +76,8 @@ edd_mbr_sig_read:
76 popw %es 76 popw %es
77 popw %bx 77 popw %bx
78 jc edd_mbr_sig_done # on failure, we're done. 78 jc edd_mbr_sig_done # on failure, we're done.
79 cmpb $0, %ah # some BIOSes do not set CF
80 jne edd_mbr_sig_done # on failure, we're done.
79 movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR 81 movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR
80 movl %eax, (%bx) # store success 82 movl %eax, (%bx) # store success
81 incb (EDD_MBR_SIG_NR_BUF) # note that we stored something 83 incb (EDD_MBR_SIG_NR_BUF) # note that we stored something
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 05312a8abb8b..da30a374dd4e 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -824,8 +824,6 @@ static void apm_do_busy(void)
824 824
825static void (*original_pm_idle)(void); 825static void (*original_pm_idle)(void);
826 826
827extern void default_idle(void);
828
829/** 827/**
830 * apm_cpu_idle - cpu idling for APM capable Linux 828 * apm_cpu_idle - cpu idling for APM capable Linux
831 * 829 *
diff --git a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig
index 26892d2099b0..e44a4c6a4fe5 100644
--- a/arch/i386/kernel/cpu/cpufreq/Kconfig
+++ b/arch/i386/kernel/cpu/cpufreq/Kconfig
@@ -96,7 +96,6 @@ config X86_POWERNOW_K8_ACPI
96 96
97config X86_GX_SUSPMOD 97config X86_GX_SUSPMOD
98 tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" 98 tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
99 depends on PCI
100 help 99 help
101 This add the CPUFreq driver for NatSemi Geode processors which 100 This add the CPUFreq driver for NatSemi Geode processors which
102 support suspend modulation. 101 support suspend modulation.
@@ -115,9 +114,9 @@ config X86_SPEEDSTEP_CENTRINO
115 you also need to say Y to "Use ACPI tables to decode..." below 114 you also need to say Y to "Use ACPI tables to decode..." below
116 [which might imply enabling ACPI] if you want to use this driver 115 [which might imply enabling ACPI] if you want to use this driver
117 on non-Banias CPUs. 116 on non-Banias CPUs.
118 117
119 For details, take a look at <file:Documentation/cpu-freq/>. 118 For details, take a look at <file:Documentation/cpu-freq/>.
120 119
121 If in doubt, say N. 120 If in doubt, say N.
122 121
123config X86_SPEEDSTEP_CENTRINO_ACPI 122config X86_SPEEDSTEP_CENTRINO_ACPI
@@ -148,7 +147,7 @@ config X86_SPEEDSTEP_ICH
148 help 147 help
149 This adds the CPUFreq driver for certain mobile Intel Pentium III 148 This adds the CPUFreq driver for certain mobile Intel Pentium III
150 (Coppermine), all mobile Intel Pentium III-M (Tualatin) and all 149 (Coppermine), all mobile Intel Pentium III-M (Tualatin) and all
151 mobile Intel Pentium 4 P4-M on systems which have an Intel ICH2, 150 mobile Intel Pentium 4 P4-M on systems which have an Intel ICH2,
152 ICH3 or ICH4 southbridge. 151 ICH3 or ICH4 southbridge.
153 152
154 For details, take a look at <file:Documentation/cpu-freq/>. 153 For details, take a look at <file:Documentation/cpu-freq/>.
@@ -161,7 +160,7 @@ config X86_SPEEDSTEP_SMI
161 depends on EXPERIMENTAL 160 depends on EXPERIMENTAL
162 help 161 help
163 This adds the CPUFreq driver for certain mobile Intel Pentium III 162 This adds the CPUFreq driver for certain mobile Intel Pentium III
164 (Coppermine), all mobile Intel Pentium III-M (Tualatin) 163 (Coppermine), all mobile Intel Pentium III-M (Tualatin)
165 on systems which have an Intel 440BX/ZX/MX southbridge. 164 on systems which have an Intel 440BX/ZX/MX southbridge.
166 165
167 For details, take a look at <file:Documentation/cpu-freq/>. 166 For details, take a look at <file:Documentation/cpu-freq/>.
@@ -203,9 +202,10 @@ config X86_LONGRUN
203config X86_LONGHAUL 202config X86_LONGHAUL
204 tristate "VIA Cyrix III Longhaul" 203 tristate "VIA Cyrix III Longhaul"
205 select CPU_FREQ_TABLE 204 select CPU_FREQ_TABLE
205 depends on BROKEN
206 help 206 help
207 This adds the CPUFreq driver for VIA Samuel/CyrixIII, 207 This adds the CPUFreq driver for VIA Samuel/CyrixIII,
208 VIA Cyrix Samuel/C3, VIA Cyrix Ezra and VIA Cyrix Ezra-T 208 VIA Cyrix Samuel/C3, VIA Cyrix Ezra and VIA Cyrix Ezra-T
209 processors. 209 processors.
210 210
211 For details, take a look at <file:Documentation/cpu-freq/>. 211 For details, take a look at <file:Documentation/cpu-freq/>.
@@ -215,11 +215,11 @@ config X86_LONGHAUL
215comment "shared options" 215comment "shared options"
216 216
217config X86_ACPI_CPUFREQ_PROC_INTF 217config X86_ACPI_CPUFREQ_PROC_INTF
218 bool "/proc/acpi/processor/../performance interface (deprecated)" 218 bool "/proc/acpi/processor/../performance interface (deprecated)"
219 depends on PROC_FS 219 depends on PROC_FS
220 depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K7_ACPI || X86_POWERNOW_K8_ACPI 220 depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K7_ACPI || X86_POWERNOW_K8_ACPI
221 help 221 help
222 This enables the deprecated /proc/acpi/processor/../performance 222 This enables the deprecated /proc/acpi/processor/../performance
223 interface. While it is helpful for debugging, the generic, 223 interface. While it is helpful for debugging, the generic,
224 cross-architecture cpufreq interfaces should be used. 224 cross-architecture cpufreq interfaces should be used.
225 225
@@ -233,9 +233,9 @@ config X86_SPEEDSTEP_RELAXED_CAP_CHECK
233 bool "Relaxed speedstep capability checks" 233 bool "Relaxed speedstep capability checks"
234 depends on (X86_SPEEDSTEP_SMI || X86_SPEEDSTEP_ICH) 234 depends on (X86_SPEEDSTEP_SMI || X86_SPEEDSTEP_ICH)
235 help 235 help
236 Don't perform all checks for a speedstep capable system which would 236 Don't perform all checks for a speedstep capable system which would
237 normally be done. Some ancient or strange systems, though speedstep 237 normally be done. Some ancient or strange systems, though speedstep
238 capable, don't always indicate that they are speedstep capable. This 238 capable, don't always indicate that they are speedstep capable. This
239 option lets the probing code bypass some of those checks if the 239 option lets the probing code bypass some of those checks if the
240 parameter "relaxed_check=1" is passed to the module. 240 parameter "relaxed_check=1" is passed to the module.
241 241
diff --git a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
index 2b62dee35c6c..f275e0d4aee5 100644
--- a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
+++ b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
@@ -39,7 +39,7 @@ static struct pci_dev *nforce2_chipset_dev;
39static int fid = 0; 39static int fid = 0;
40 40
41/* min_fsb, max_fsb: 41/* min_fsb, max_fsb:
42 * minimum and maximum FSB (= FSB at boot time) 42 * minimum and maximum FSB (= FSB at boot time)
43 */ 43 */
44static int min_fsb = 0; 44static int min_fsb = 0;
45static int max_fsb = 0; 45static int max_fsb = 0;
@@ -57,10 +57,10 @@ MODULE_PARM_DESC(min_fsb,
57 57
58#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "cpufreq-nforce2", msg) 58#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "cpufreq-nforce2", msg)
59 59
60/* 60/**
61 * nforce2_calc_fsb - calculate FSB 61 * nforce2_calc_fsb - calculate FSB
62 * @pll: PLL value 62 * @pll: PLL value
63 * 63 *
64 * Calculates FSB from PLL value 64 * Calculates FSB from PLL value
65 */ 65 */
66static int nforce2_calc_fsb(int pll) 66static int nforce2_calc_fsb(int pll)
@@ -76,10 +76,10 @@ static int nforce2_calc_fsb(int pll)
76 return 0; 76 return 0;
77} 77}
78 78
79/* 79/**
80 * nforce2_calc_pll - calculate PLL value 80 * nforce2_calc_pll - calculate PLL value
81 * @fsb: FSB 81 * @fsb: FSB
82 * 82 *
83 * Calculate PLL value for given FSB 83 * Calculate PLL value for given FSB
84 */ 84 */
85static int nforce2_calc_pll(unsigned int fsb) 85static int nforce2_calc_pll(unsigned int fsb)
@@ -106,10 +106,10 @@ static int nforce2_calc_pll(unsigned int fsb)
106 return NFORCE2_PLL(mul, div); 106 return NFORCE2_PLL(mul, div);
107} 107}
108 108
109/* 109/**
110 * nforce2_write_pll - write PLL value to chipset 110 * nforce2_write_pll - write PLL value to chipset
111 * @pll: PLL value 111 * @pll: PLL value
112 * 112 *
113 * Writes new FSB PLL value to chipset 113 * Writes new FSB PLL value to chipset
114 */ 114 */
115static void nforce2_write_pll(int pll) 115static void nforce2_write_pll(int pll)
@@ -121,15 +121,13 @@ static void nforce2_write_pll(int pll)
121 pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLADR, temp); 121 pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLADR, temp);
122 122
123 /* Now write the value in all 64 registers */ 123 /* Now write the value in all 64 registers */
124 for (temp = 0; temp <= 0x3f; temp++) { 124 for (temp = 0; temp <= 0x3f; temp++)
125 pci_write_config_dword(nforce2_chipset_dev, 125 pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLREG, pll);
126 NFORCE2_PLLREG, pll);
127 }
128 126
129 return; 127 return;
130} 128}
131 129
132/* 130/**
133 * nforce2_fsb_read - Read FSB 131 * nforce2_fsb_read - Read FSB
134 * 132 *
135 * Read FSB from chipset 133 * Read FSB from chipset
@@ -140,39 +138,32 @@ static unsigned int nforce2_fsb_read(int bootfsb)
140 struct pci_dev *nforce2_sub5; 138 struct pci_dev *nforce2_sub5;
141 u32 fsb, temp = 0; 139 u32 fsb, temp = 0;
142 140
143
144 /* Get chipset boot FSB from subdevice 5 (FSB at boot-time) */ 141 /* Get chipset boot FSB from subdevice 5 (FSB at boot-time) */
145 nforce2_sub5 = pci_get_subsys(PCI_VENDOR_ID_NVIDIA, 142 nforce2_sub5 = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
146 0x01EF, 143 0x01EF,PCI_ANY_ID,PCI_ANY_ID,NULL);
147 PCI_ANY_ID,
148 PCI_ANY_ID,
149 NULL);
150
151 if (!nforce2_sub5) 144 if (!nforce2_sub5)
152 return 0; 145 return 0;
153 146
154 pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb); 147 pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb);
155 fsb /= 1000000; 148 fsb /= 1000000;
156 149
157 /* Check if PLL register is already set */ 150 /* Check if PLL register is already set */
158 pci_read_config_byte(nforce2_chipset_dev, 151 pci_read_config_byte(nforce2_chipset_dev,NFORCE2_PLLENABLE, (u8 *)&temp);
159 NFORCE2_PLLENABLE, (u8 *)&temp); 152
160
161 if(bootfsb || !temp) 153 if(bootfsb || !temp)
162 return fsb; 154 return fsb;
163 155
164 /* Use PLL register FSB value */ 156 /* Use PLL register FSB value */
165 pci_read_config_dword(nforce2_chipset_dev, 157 pci_read_config_dword(nforce2_chipset_dev,NFORCE2_PLLREG, &temp);
166 NFORCE2_PLLREG, &temp);
167 fsb = nforce2_calc_fsb(temp); 158 fsb = nforce2_calc_fsb(temp);
168 159
169 return fsb; 160 return fsb;
170} 161}
171 162
172/* 163/**
173 * nforce2_set_fsb - set new FSB 164 * nforce2_set_fsb - set new FSB
174 * @fsb: New FSB 165 * @fsb: New FSB
175 * 166 *
176 * Sets new FSB 167 * Sets new FSB
177 */ 168 */
178static int nforce2_set_fsb(unsigned int fsb) 169static int nforce2_set_fsb(unsigned int fsb)
@@ -186,7 +177,7 @@ static int nforce2_set_fsb(unsigned int fsb)
186 printk(KERN_ERR "cpufreq: FSB %d is out of range!\n", fsb); 177 printk(KERN_ERR "cpufreq: FSB %d is out of range!\n", fsb);
187 return -EINVAL; 178 return -EINVAL;
188 } 179 }
189 180
190 tfsb = nforce2_fsb_read(0); 181 tfsb = nforce2_fsb_read(0);
191 if (!tfsb) { 182 if (!tfsb) {
192 printk(KERN_ERR "cpufreq: Error while reading the FSB\n"); 183 printk(KERN_ERR "cpufreq: Error while reading the FSB\n");
@@ -194,8 +185,7 @@ static int nforce2_set_fsb(unsigned int fsb)
194 } 185 }
195 186
196 /* First write? Then set actual value */ 187 /* First write? Then set actual value */
197 pci_read_config_byte(nforce2_chipset_dev, 188 pci_read_config_byte(nforce2_chipset_dev,NFORCE2_PLLENABLE, (u8 *)&temp);
198 NFORCE2_PLLENABLE, (u8 *)&temp);
199 if (!temp) { 189 if (!temp) {
200 pll = nforce2_calc_pll(tfsb); 190 pll = nforce2_calc_pll(tfsb);
201 191
@@ -223,7 +213,7 @@ static int nforce2_set_fsb(unsigned int fsb)
223 /* Calculate the PLL reg. value */ 213 /* Calculate the PLL reg. value */
224 if ((pll = nforce2_calc_pll(tfsb)) == -1) 214 if ((pll = nforce2_calc_pll(tfsb)) == -1)
225 return -EINVAL; 215 return -EINVAL;
226 216
227 nforce2_write_pll(pll); 217 nforce2_write_pll(pll);
228#ifdef NFORCE2_DELAY 218#ifdef NFORCE2_DELAY
229 mdelay(NFORCE2_DELAY); 219 mdelay(NFORCE2_DELAY);
@@ -239,7 +229,7 @@ static int nforce2_set_fsb(unsigned int fsb)
239/** 229/**
240 * nforce2_get - get the CPU frequency 230 * nforce2_get - get the CPU frequency
241 * @cpu: CPU number 231 * @cpu: CPU number
242 * 232 *
243 * Returns the CPU frequency 233 * Returns the CPU frequency
244 */ 234 */
245static unsigned int nforce2_get(unsigned int cpu) 235static unsigned int nforce2_get(unsigned int cpu)
@@ -354,10 +344,10 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
354 344
355 printk(KERN_INFO "cpufreq: FSB currently at %i MHz, FID %d.%d\n", fsb, 345 printk(KERN_INFO "cpufreq: FSB currently at %i MHz, FID %d.%d\n", fsb,
356 fid / 10, fid % 10); 346 fid / 10, fid % 10);
357 347
358 /* Set maximum FSB to FSB at boot time */ 348 /* Set maximum FSB to FSB at boot time */
359 max_fsb = nforce2_fsb_read(1); 349 max_fsb = nforce2_fsb_read(1);
360 350
361 if(!max_fsb) 351 if(!max_fsb)
362 return -EIO; 352 return -EIO;
363 353
@@ -398,17 +388,15 @@ static struct cpufreq_driver nforce2_driver = {
398 * nforce2_detect_chipset - detect the Southbridge which contains FSB PLL logic 388 * nforce2_detect_chipset - detect the Southbridge which contains FSB PLL logic
399 * 389 *
400 * Detects nForce2 A2 and C1 stepping 390 * Detects nForce2 A2 and C1 stepping
401 * 391 *
402 */ 392 */
403static unsigned int nforce2_detect_chipset(void) 393static unsigned int nforce2_detect_chipset(void)
404{ 394{
405 u8 revision; 395 u8 revision;
406 396
407 nforce2_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA, 397 nforce2_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
408 PCI_DEVICE_ID_NVIDIA_NFORCE2, 398 PCI_DEVICE_ID_NVIDIA_NFORCE2,
409 PCI_ANY_ID, 399 PCI_ANY_ID, PCI_ANY_ID, NULL);
410 PCI_ANY_ID,
411 NULL);
412 400
413 if (nforce2_chipset_dev == NULL) 401 if (nforce2_chipset_dev == NULL)
414 return -ENODEV; 402 return -ENODEV;
diff --git a/arch/i386/kernel/cpu/cpufreq/elanfreq.c b/arch/i386/kernel/cpu/cpufreq/elanfreq.c
index 3f7caa4ae6d6..f317276afa7a 100644
--- a/arch/i386/kernel/cpu/cpufreq/elanfreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/elanfreq.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * elanfreq: cpufreq driver for the AMD ELAN family 2 * elanfreq: cpufreq driver for the AMD ELAN family
3 * 3 *
4 * (c) Copyright 2002 Robert Schwebel <r.schwebel@pengutronix.de> 4 * (c) Copyright 2002 Robert Schwebel <r.schwebel@pengutronix.de>
5 * 5 *
6 * Parts of this code are (c) Sven Geggus <sven@geggus.net> 6 * Parts of this code are (c) Sven Geggus <sven@geggus.net>
7 * 7 *
8 * All Rights Reserved. 8 * All Rights Reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version. 13 * 2 of the License, or (at your option) any later version.
14 * 14 *
15 * 2002-02-13: - initial revision for 2.4.18-pre9 by Robert Schwebel 15 * 2002-02-13: - initial revision for 2.4.18-pre9 by Robert Schwebel
16 * 16 *
@@ -28,7 +28,7 @@
28#include <asm/timex.h> 28#include <asm/timex.h>
29#include <asm/io.h> 29#include <asm/io.h>
30 30
31#define REG_CSCIR 0x22 /* Chip Setup and Control Index Register */ 31#define REG_CSCIR 0x22 /* Chip Setup and Control Index Register */
32#define REG_CSCDR 0x23 /* Chip Setup and Control Data Register */ 32#define REG_CSCDR 0x23 /* Chip Setup and Control Data Register */
33 33
34/* Module parameter */ 34/* Module parameter */
@@ -41,7 +41,7 @@ struct s_elan_multiplier {
41}; 41};
42 42
43/* 43/*
44 * It is important that the frequencies 44 * It is important that the frequencies
45 * are listed in ascending order here! 45 * are listed in ascending order here!
46 */ 46 */
47struct s_elan_multiplier elan_multiplier[] = { 47struct s_elan_multiplier elan_multiplier[] = {
@@ -72,78 +72,79 @@ static struct cpufreq_frequency_table elanfreq_table[] = {
72 * elanfreq_get_cpu_frequency: determine current cpu speed 72 * elanfreq_get_cpu_frequency: determine current cpu speed
73 * 73 *
74 * Finds out at which frequency the CPU of the Elan SOC runs 74 * Finds out at which frequency the CPU of the Elan SOC runs
75 * at the moment. Frequencies from 1 to 33 MHz are generated 75 * at the moment. Frequencies from 1 to 33 MHz are generated
76 * the normal way, 66 and 99 MHz are called "Hyperspeed Mode" 76 * the normal way, 66 and 99 MHz are called "Hyperspeed Mode"
77 * and have the rest of the chip running with 33 MHz. 77 * and have the rest of the chip running with 33 MHz.
78 */ 78 */
79 79
80static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu) 80static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
81{ 81{
82 u8 clockspeed_reg; /* Clock Speed Register */ 82 u8 clockspeed_reg; /* Clock Speed Register */
83 83
84 local_irq_disable(); 84 local_irq_disable();
85 outb_p(0x80,REG_CSCIR); 85 outb_p(0x80,REG_CSCIR);
86 clockspeed_reg = inb_p(REG_CSCDR); 86 clockspeed_reg = inb_p(REG_CSCDR);
87 local_irq_enable(); 87 local_irq_enable();
88 88
89 if ((clockspeed_reg & 0xE0) == 0xE0) { return 0; } 89 if ((clockspeed_reg & 0xE0) == 0xE0)
90 return 0;
90 91
91 /* Are we in CPU clock multiplied mode (66/99 MHz)? */ 92 /* Are we in CPU clock multiplied mode (66/99 MHz)? */
92 if ((clockspeed_reg & 0xE0) == 0xC0) { 93 if ((clockspeed_reg & 0xE0) == 0xC0) {
93 if ((clockspeed_reg & 0x01) == 0) { 94 if ((clockspeed_reg & 0x01) == 0)
94 return 66000; 95 return 66000;
95 } else { 96 else
96 return 99000; 97 return 99000;
97 } 98 }
98 }
99 99
100 /* 33 MHz is not 32 MHz... */ 100 /* 33 MHz is not 32 MHz... */
101 if ((clockspeed_reg & 0xE0)==0xA0) 101 if ((clockspeed_reg & 0xE0)==0xA0)
102 return 33000; 102 return 33000;
103 103
104 return ((1<<((clockspeed_reg & 0xE0) >> 5)) * 1000); 104 return ((1<<((clockspeed_reg & 0xE0) >> 5)) * 1000);
105} 105}
106 106
107 107
108/** 108/**
109 * elanfreq_set_cpu_frequency: Change the CPU core frequency 109 * elanfreq_set_cpu_frequency: Change the CPU core frequency
110 * @cpu: cpu number 110 * @cpu: cpu number
111 * @freq: frequency in kHz 111 * @freq: frequency in kHz
112 * 112 *
113 * This function takes a frequency value and changes the CPU frequency 113 * This function takes a frequency value and changes the CPU frequency
114 * according to this. Note that the frequency has to be checked by 114 * according to this. Note that the frequency has to be checked by
115 * elanfreq_validatespeed() for correctness! 115 * elanfreq_validatespeed() for correctness!
116 * 116 *
117 * There is no return value. 117 * There is no return value.
118 */ 118 */
119 119
120static void elanfreq_set_cpu_state (unsigned int state) { 120static void elanfreq_set_cpu_state (unsigned int state)
121 121{
122 struct cpufreq_freqs freqs; 122 struct cpufreq_freqs freqs;
123 123
124 freqs.old = elanfreq_get_cpu_frequency(0); 124 freqs.old = elanfreq_get_cpu_frequency(0);
125 freqs.new = elan_multiplier[state].clock; 125 freqs.new = elan_multiplier[state].clock;
126 freqs.cpu = 0; /* elanfreq.c is UP only driver */ 126 freqs.cpu = 0; /* elanfreq.c is UP only driver */
127 127
128 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 128 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
129 129
130 printk(KERN_INFO "elanfreq: attempting to set frequency to %i kHz\n",elan_multiplier[state].clock); 130 printk(KERN_INFO "elanfreq: attempting to set frequency to %i kHz\n",
131 elan_multiplier[state].clock);
131 132
132 133
133 /* 134 /*
134 * Access to the Elan's internal registers is indexed via 135 * Access to the Elan's internal registers is indexed via
135 * 0x22: Chip Setup & Control Register Index Register (CSCI) 136 * 0x22: Chip Setup & Control Register Index Register (CSCI)
136 * 0x23: Chip Setup & Control Register Data Register (CSCD) 137 * 0x23: Chip Setup & Control Register Data Register (CSCD)
137 * 138 *
138 */ 139 */
139 140
140 /* 141 /*
141 * 0x40 is the Power Management Unit's Force Mode Register. 142 * 0x40 is the Power Management Unit's Force Mode Register.
142 * Bit 6 enables Hyperspeed Mode (66/100 MHz core frequency) 143 * Bit 6 enables Hyperspeed Mode (66/100 MHz core frequency)
143 */ 144 */
144 145
145 local_irq_disable(); 146 local_irq_disable();
146 outb_p(0x40,REG_CSCIR); /* Disable hyperspeed mode */ 147 outb_p(0x40,REG_CSCIR); /* Disable hyperspeed mode */
147 outb_p(0x00,REG_CSCDR); 148 outb_p(0x00,REG_CSCDR);
148 local_irq_enable(); /* wait till internal pipelines and */ 149 local_irq_enable(); /* wait till internal pipelines and */
149 udelay(1000); /* buffers have cleaned up */ 150 udelay(1000); /* buffers have cleaned up */
@@ -166,10 +167,10 @@ static void elanfreq_set_cpu_state (unsigned int state) {
166 167
167/** 168/**
168 * elanfreq_validatespeed: test if frequency range is valid 169 * elanfreq_validatespeed: test if frequency range is valid
169 * @policy: the policy to validate 170 * @policy: the policy to validate
170 * 171 *
171 * This function checks if a given frequency range in kHz is valid 172 * This function checks if a given frequency range in kHz is valid
172 * for the hardware supported by the driver. 173 * for the hardware supported by the driver.
173 */ 174 */
174 175
175static int elanfreq_verify (struct cpufreq_policy *policy) 176static int elanfreq_verify (struct cpufreq_policy *policy)
@@ -177,11 +178,11 @@ static int elanfreq_verify (struct cpufreq_policy *policy)
177 return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]); 178 return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]);
178} 179}
179 180
180static int elanfreq_target (struct cpufreq_policy *policy, 181static int elanfreq_target (struct cpufreq_policy *policy,
181 unsigned int target_freq, 182 unsigned int target_freq,
182 unsigned int relation) 183 unsigned int relation)
183{ 184{
184 unsigned int newstate = 0; 185 unsigned int newstate = 0;
185 186
186 if (cpufreq_frequency_table_target(policy, &elanfreq_table[0], target_freq, relation, &newstate)) 187 if (cpufreq_frequency_table_target(policy, &elanfreq_table[0], target_freq, relation, &newstate))
187 return -EINVAL; 188 return -EINVAL;
@@ -212,7 +213,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
212 max_freq = elanfreq_get_cpu_frequency(0); 213 max_freq = elanfreq_get_cpu_frequency(0);
213 214
214 /* table init */ 215 /* table init */
215 for (i=0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) { 216 for (i=0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) {
216 if (elanfreq_table[i].frequency > max_freq) 217 if (elanfreq_table[i].frequency > max_freq)
217 elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID; 218 elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID;
218 } 219 }
@@ -226,8 +227,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
226 if (result) 227 if (result)
227 return (result); 228 return (result);
228 229
229 cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu); 230 cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu);
230
231 return 0; 231 return 0;
232} 232}
233 233
@@ -268,9 +268,9 @@ static struct freq_attr* elanfreq_attr[] = {
268 268
269 269
270static struct cpufreq_driver elanfreq_driver = { 270static struct cpufreq_driver elanfreq_driver = {
271 .get = elanfreq_get_cpu_frequency, 271 .get = elanfreq_get_cpu_frequency,
272 .verify = elanfreq_verify, 272 .verify = elanfreq_verify,
273 .target = elanfreq_target, 273 .target = elanfreq_target,
274 .init = elanfreq_cpu_init, 274 .init = elanfreq_cpu_init,
275 .exit = elanfreq_cpu_exit, 275 .exit = elanfreq_cpu_exit,
276 .name = "elanfreq", 276 .name = "elanfreq",
@@ -279,23 +279,21 @@ static struct cpufreq_driver elanfreq_driver = {
279}; 279};
280 280
281 281
282static int __init elanfreq_init(void) 282static int __init elanfreq_init(void)
283{ 283{
284 struct cpuinfo_x86 *c = cpu_data; 284 struct cpuinfo_x86 *c = cpu_data;
285 285
286 /* Test if we have the right hardware */ 286 /* Test if we have the right hardware */
287 if ((c->x86_vendor != X86_VENDOR_AMD) || 287 if ((c->x86_vendor != X86_VENDOR_AMD) ||
288 (c->x86 != 4) || (c->x86_model!=10)) 288 (c->x86 != 4) || (c->x86_model!=10)) {
289 {
290 printk(KERN_INFO "elanfreq: error: no Elan processor found!\n"); 289 printk(KERN_INFO "elanfreq: error: no Elan processor found!\n");
291 return -ENODEV; 290 return -ENODEV;
292 } 291 }
293
294 return cpufreq_register_driver(&elanfreq_driver); 292 return cpufreq_register_driver(&elanfreq_driver);
295} 293}
296 294
297 295
298static void __exit elanfreq_exit(void) 296static void __exit elanfreq_exit(void)
299{ 297{
300 cpufreq_unregister_driver(&elanfreq_driver); 298 cpufreq_unregister_driver(&elanfreq_driver);
301} 299}
@@ -309,4 +307,3 @@ MODULE_DESCRIPTION("cpufreq driver for AMD's Elan CPUs");
309 307
310module_init(elanfreq_init); 308module_init(elanfreq_init);
311module_exit(elanfreq_exit); 309module_exit(elanfreq_exit);
312
diff --git a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
index e86ea486c311..92afa3bc84f1 100644
--- a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
@@ -6,12 +6,12 @@
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation 9 * version 2 as published by the Free Software Foundation
10 * 10 *
11 * The author(s) of this software shall not be held liable for damages 11 * The author(s) of this software shall not be held liable for damages
12 * of any nature resulting due to the use of this software. This 12 * of any nature resulting due to the use of this software. This
13 * software is provided AS-IS with no warranties. 13 * software is provided AS-IS with no warranties.
14 * 14 *
15 * Theoritical note: 15 * Theoritical note:
16 * 16 *
17 * (see Geode(tm) CS5530 manual (rev.4.1) page.56) 17 * (see Geode(tm) CS5530 manual (rev.4.1) page.56)
@@ -21,18 +21,18 @@
21 * 21 *
22 * Suspend Modulation works by asserting and de-asserting the SUSP# pin 22 * Suspend Modulation works by asserting and de-asserting the SUSP# pin
23 * to CPU(GX1/GXLV) for configurable durations. When asserting SUSP# 23 * to CPU(GX1/GXLV) for configurable durations. When asserting SUSP#
24 * the CPU enters an idle state. GX1 stops its core clock when SUSP# is 24 * the CPU enters an idle state. GX1 stops its core clock when SUSP# is
25 * asserted then power consumption is reduced. 25 * asserted then power consumption is reduced.
26 * 26 *
27 * Suspend Modulation's OFF/ON duration are configurable 27 * Suspend Modulation's OFF/ON duration are configurable
28 * with 'Suspend Modulation OFF Count Register' 28 * with 'Suspend Modulation OFF Count Register'
29 * and 'Suspend Modulation ON Count Register'. 29 * and 'Suspend Modulation ON Count Register'.
30 * These registers are 8bit counters that represent the number of 30 * These registers are 8bit counters that represent the number of
31 * 32us intervals which the SUSP# pin is asserted(ON)/de-asserted(OFF) 31 * 32us intervals which the SUSP# pin is asserted(ON)/de-asserted(OFF)
32 * to the processor. 32 * to the processor.
33 * 33 *
34 * These counters define a ratio which is the effective frequency 34 * These counters define a ratio which is the effective frequency
35 * of operation of the system. 35 * of operation of the system.
36 * 36 *
37 * OFF Count 37 * OFF Count
38 * F_eff = Fgx * ---------------------- 38 * F_eff = Fgx * ----------------------
@@ -40,24 +40,24 @@
40 * 40 *
41 * 0 <= On Count, Off Count <= 255 41 * 0 <= On Count, Off Count <= 255
42 * 42 *
43 * From these limits, we can get register values 43 * From these limits, we can get register values
44 * 44 *
45 * off_duration + on_duration <= MAX_DURATION 45 * off_duration + on_duration <= MAX_DURATION
46 * on_duration = off_duration * (stock_freq - freq) / freq 46 * on_duration = off_duration * (stock_freq - freq) / freq
47 * 47 *
48 * off_duration = (freq * DURATION) / stock_freq 48 * off_duration = (freq * DURATION) / stock_freq
49 * on_duration = DURATION - off_duration 49 * on_duration = DURATION - off_duration
50 * 50 *
51 * 51 *
52 *--------------------------------------------------------------------------- 52 *---------------------------------------------------------------------------
53 * 53 *
54 * ChangeLog: 54 * ChangeLog:
55 * Dec. 12, 2003 Hiroshi Miura <miura@da-cha.org> 55 * Dec. 12, 2003 Hiroshi Miura <miura@da-cha.org>
56 * - fix on/off register mistake 56 * - fix on/off register mistake
57 * - fix cpu_khz calc when it stops cpu modulation. 57 * - fix cpu_khz calc when it stops cpu modulation.
58 * 58 *
59 * Dec. 11, 2002 Hiroshi Miura <miura@da-cha.org> 59 * Dec. 11, 2002 Hiroshi Miura <miura@da-cha.org>
60 * - rewrite for Cyrix MediaGX Cx5510/5520 and 60 * - rewrite for Cyrix MediaGX Cx5510/5520 and
61 * NatSemi Geode Cs5530(A). 61 * NatSemi Geode Cs5530(A).
62 * 62 *
63 * Jul. ??, 2002 Zwane Mwaikambo <zwane@commfireservices.com> 63 * Jul. ??, 2002 Zwane Mwaikambo <zwane@commfireservices.com>
@@ -74,40 +74,40 @@
74 ************************************************************************/ 74 ************************************************************************/
75 75
76#include <linux/kernel.h> 76#include <linux/kernel.h>
77#include <linux/module.h> 77#include <linux/module.h>
78#include <linux/init.h> 78#include <linux/init.h>
79#include <linux/smp.h> 79#include <linux/smp.h>
80#include <linux/cpufreq.h> 80#include <linux/cpufreq.h>
81#include <linux/pci.h> 81#include <linux/pci.h>
82#include <asm/processor.h> 82#include <asm/processor.h>
83#include <asm/errno.h> 83#include <asm/errno.h>
84 84
85/* PCI config registers, all at F0 */ 85/* PCI config registers, all at F0 */
86#define PCI_PMER1 0x80 /* power management enable register 1 */ 86#define PCI_PMER1 0x80 /* power management enable register 1 */
87#define PCI_PMER2 0x81 /* power management enable register 2 */ 87#define PCI_PMER2 0x81 /* power management enable register 2 */
88#define PCI_PMER3 0x82 /* power management enable register 3 */ 88#define PCI_PMER3 0x82 /* power management enable register 3 */
89#define PCI_IRQTC 0x8c /* irq speedup timer counter register:typical 2 to 4ms */ 89#define PCI_IRQTC 0x8c /* irq speedup timer counter register:typical 2 to 4ms */
90#define PCI_VIDTC 0x8d /* video speedup timer counter register: typical 50 to 100ms */ 90#define PCI_VIDTC 0x8d /* video speedup timer counter register: typical 50 to 100ms */
91#define PCI_MODOFF 0x94 /* suspend modulation OFF counter register, 1 = 32us */ 91#define PCI_MODOFF 0x94 /* suspend modulation OFF counter register, 1 = 32us */
92#define PCI_MODON 0x95 /* suspend modulation ON counter register */ 92#define PCI_MODON 0x95 /* suspend modulation ON counter register */
93#define PCI_SUSCFG 0x96 /* suspend configuration register */ 93#define PCI_SUSCFG 0x96 /* suspend configuration register */
94 94
95/* PMER1 bits */ 95/* PMER1 bits */
96#define GPM (1<<0) /* global power management */ 96#define GPM (1<<0) /* global power management */
97#define GIT (1<<1) /* globally enable PM device idle timers */ 97#define GIT (1<<1) /* globally enable PM device idle timers */
98#define GTR (1<<2) /* globally enable IO traps */ 98#define GTR (1<<2) /* globally enable IO traps */
99#define IRQ_SPDUP (1<<3) /* disable clock throttle during interrupt handling */ 99#define IRQ_SPDUP (1<<3) /* disable clock throttle during interrupt handling */
100#define VID_SPDUP (1<<4) /* disable clock throttle during vga video handling */ 100#define VID_SPDUP (1<<4) /* disable clock throttle during vga video handling */
101 101
102/* SUSCFG bits */ 102/* SUSCFG bits */
103#define SUSMOD (1<<0) /* enable/disable suspend modulation */ 103#define SUSMOD (1<<0) /* enable/disable suspend modulation */
104/* the belows support only with cs5530 (after rev.1.2)/cs5530A */ 104/* the belows support only with cs5530 (after rev.1.2)/cs5530A */
105#define SMISPDUP (1<<1) /* select how SMI re-enable suspend modulation: */ 105#define SMISPDUP (1<<1) /* select how SMI re-enable suspend modulation: */
106 /* IRQTC timer or read SMI speedup disable reg.(F1BAR[08-09h]) */ 106 /* IRQTC timer or read SMI speedup disable reg.(F1BAR[08-09h]) */
107#define SUSCFG (1<<2) /* enable powering down a GXLV processor. "Special 3Volt Suspend" mode */ 107#define SUSCFG (1<<2) /* enable powering down a GXLV processor. "Special 3Volt Suspend" mode */
108/* the belows support only with cs5530A */ 108/* the belows support only with cs5530A */
109#define PWRSVE_ISA (1<<3) /* stop ISA clock */ 109#define PWRSVE_ISA (1<<3) /* stop ISA clock */
110#define PWRSVE (1<<4) /* active idle */ 110#define PWRSVE (1<<4) /* active idle */
111 111
112struct gxfreq_params { 112struct gxfreq_params {
113 u8 on_duration; 113 u8 on_duration;
@@ -128,7 +128,7 @@ module_param (pci_busclk, int, 0444);
128 128
129/* maximum duration for which the cpu may be suspended 129/* maximum duration for which the cpu may be suspended
130 * (32us * MAX_DURATION). If no parameter is given, this defaults 130 * (32us * MAX_DURATION). If no parameter is given, this defaults
131 * to 255. 131 * to 255.
132 * Note that this leads to a maximum of 8 ms(!) where the CPU clock 132 * Note that this leads to a maximum of 8 ms(!) where the CPU clock
133 * is suspended -- processing power is just 0.39% of what it used to be, 133 * is suspended -- processing power is just 0.39% of what it used to be,
134 * though. 781.25 kHz(!) for a 200 MHz processor -- wow. */ 134 * though. 781.25 kHz(!) for a 200 MHz processor -- wow. */
@@ -144,17 +144,17 @@ module_param (max_duration, int, 0444);
144#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "gx-suspmod", msg) 144#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "gx-suspmod", msg)
145 145
146/** 146/**
147 * we can detect a core multipiler from dir0_lsb 147 * we can detect a core multipiler from dir0_lsb
148 * from GX1 datasheet p.56, 148 * from GX1 datasheet p.56,
149 * MULT[3:0]: 149 * MULT[3:0]:
150 * 0000 = SYSCLK multiplied by 4 (test only) 150 * 0000 = SYSCLK multiplied by 4 (test only)
151 * 0001 = SYSCLK multiplied by 10 151 * 0001 = SYSCLK multiplied by 10
152 * 0010 = SYSCLK multiplied by 4 152 * 0010 = SYSCLK multiplied by 4
153 * 0011 = SYSCLK multiplied by 6 153 * 0011 = SYSCLK multiplied by 6
154 * 0100 = SYSCLK multiplied by 9 154 * 0100 = SYSCLK multiplied by 9
155 * 0101 = SYSCLK multiplied by 5 155 * 0101 = SYSCLK multiplied by 5
156 * 0110 = SYSCLK multiplied by 7 156 * 0110 = SYSCLK multiplied by 7
157 * 0111 = SYSCLK multiplied by 8 157 * 0111 = SYSCLK multiplied by 8
158 * of 33.3MHz 158 * of 33.3MHz
159 **/ 159 **/
160static int gx_freq_mult[16] = { 160static int gx_freq_mult[16] = {
@@ -164,17 +164,17 @@ static int gx_freq_mult[16] = {
164 164
165 165
166/**************************************************************** 166/****************************************************************
167 * Low Level chipset interface * 167 * Low Level chipset interface *
168 ****************************************************************/ 168 ****************************************************************/
169static struct pci_device_id gx_chipset_tbl[] __initdata = { 169static struct pci_device_id gx_chipset_tbl[] __initdata = {
170 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, PCI_ANY_ID, PCI_ANY_ID }, 170 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, PCI_ANY_ID, PCI_ANY_ID },
171 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520, PCI_ANY_ID, PCI_ANY_ID }, 171 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520, PCI_ANY_ID, PCI_ANY_ID },
172 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510, PCI_ANY_ID, PCI_ANY_ID }, 172 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510, PCI_ANY_ID, PCI_ANY_ID },
173 { 0, }, 173 { 0, },
174}; 174};
175 175
176/** 176/**
177 * gx_detect_chipset: 177 * gx_detect_chipset:
178 * 178 *
179 **/ 179 **/
180static __init struct pci_dev *gx_detect_chipset(void) 180static __init struct pci_dev *gx_detect_chipset(void)
@@ -182,17 +182,16 @@ static __init struct pci_dev *gx_detect_chipset(void)
182 struct pci_dev *gx_pci = NULL; 182 struct pci_dev *gx_pci = NULL;
183 183
184 /* check if CPU is a MediaGX or a Geode. */ 184 /* check if CPU is a MediaGX or a Geode. */
185 if ((current_cpu_data.x86_vendor != X86_VENDOR_NSC) && 185 if ((current_cpu_data.x86_vendor != X86_VENDOR_NSC) &&
186 (current_cpu_data.x86_vendor != X86_VENDOR_CYRIX)) { 186 (current_cpu_data.x86_vendor != X86_VENDOR_CYRIX)) {
187 dprintk("error: no MediaGX/Geode processor found!\n"); 187 dprintk("error: no MediaGX/Geode processor found!\n");
188 return NULL; 188 return NULL;
189 } 189 }
190 190
191 /* detect which companion chip is used */ 191 /* detect which companion chip is used */
192 while ((gx_pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) { 192 while ((gx_pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) {
193 if ((pci_match_id(gx_chipset_tbl, gx_pci)) != NULL) { 193 if ((pci_match_id(gx_chipset_tbl, gx_pci)) != NULL)
194 return gx_pci; 194 return gx_pci;
195 }
196 } 195 }
197 196
198 dprintk("error: no supported chipset found!\n"); 197 dprintk("error: no supported chipset found!\n");
@@ -200,24 +199,24 @@ static __init struct pci_dev *gx_detect_chipset(void)
200} 199}
201 200
202/** 201/**
203 * gx_get_cpuspeed: 202 * gx_get_cpuspeed:
204 * 203 *
205 * Finds out at which efficient frequency the Cyrix MediaGX/NatSemi Geode CPU runs. 204 * Finds out at which efficient frequency the Cyrix MediaGX/NatSemi Geode CPU runs.
206 */ 205 */
207static unsigned int gx_get_cpuspeed(unsigned int cpu) 206static unsigned int gx_get_cpuspeed(unsigned int cpu)
208{ 207{
209 if ((gx_params->pci_suscfg & SUSMOD) == 0) 208 if ((gx_params->pci_suscfg & SUSMOD) == 0)
210 return stock_freq; 209 return stock_freq;
211 210
212 return (stock_freq * gx_params->off_duration) 211 return (stock_freq * gx_params->off_duration)
213 / (gx_params->on_duration + gx_params->off_duration); 212 / (gx_params->on_duration + gx_params->off_duration);
214} 213}
215 214
216/** 215/**
217 * gx_validate_speed: 216 * gx_validate_speed:
218 * determine current cpu speed 217 * determine current cpu speed
219 * 218 *
220**/ 219 **/
221 220
222static unsigned int gx_validate_speed(unsigned int khz, u8 *on_duration, u8 *off_duration) 221static unsigned int gx_validate_speed(unsigned int khz, u8 *on_duration, u8 *off_duration)
223{ 222{
@@ -230,7 +229,7 @@ static unsigned int gx_validate_speed(unsigned int khz, u8 *on_duration, u8 *off
230 *on_duration=0; 229 *on_duration=0;
231 230
232 for (i=max_duration; i>0; i--) { 231 for (i=max_duration; i>0; i--) {
233 tmp_off = ((khz * i) / stock_freq) & 0xff; 232 tmp_off = ((khz * i) / stock_freq) & 0xff;
234 tmp_on = i - tmp_off; 233 tmp_on = i - tmp_off;
235 tmp_freq = (stock_freq * tmp_off) / i; 234 tmp_freq = (stock_freq * tmp_off) / i;
236 /* if this relation is closer to khz, use this. If it's equal, 235 /* if this relation is closer to khz, use this. If it's equal,
@@ -247,18 +246,17 @@ static unsigned int gx_validate_speed(unsigned int khz, u8 *on_duration, u8 *off
247 246
248 247
249/** 248/**
250 * gx_set_cpuspeed: 249 * gx_set_cpuspeed:
251 * set cpu speed in khz. 250 * set cpu speed in khz.
252 **/ 251 **/
253 252
254static void gx_set_cpuspeed(unsigned int khz) 253static void gx_set_cpuspeed(unsigned int khz)
255{ 254{
256 u8 suscfg, pmer1; 255 u8 suscfg, pmer1;
257 unsigned int new_khz; 256 unsigned int new_khz;
258 unsigned long flags; 257 unsigned long flags;
259 struct cpufreq_freqs freqs; 258 struct cpufreq_freqs freqs;
260 259
261
262 freqs.cpu = 0; 260 freqs.cpu = 0;
263 freqs.old = gx_get_cpuspeed(0); 261 freqs.old = gx_get_cpuspeed(0);
264 262
@@ -303,18 +301,18 @@ static void gx_set_cpuspeed(unsigned int khz)
303 pci_write_config_byte(gx_params->cs55x0, PCI_MODOFF, gx_params->off_duration); 301 pci_write_config_byte(gx_params->cs55x0, PCI_MODOFF, gx_params->off_duration);
304 pci_write_config_byte(gx_params->cs55x0, PCI_MODON, gx_params->on_duration); 302 pci_write_config_byte(gx_params->cs55x0, PCI_MODON, gx_params->on_duration);
305 303
306 pci_write_config_byte(gx_params->cs55x0, PCI_SUSCFG, suscfg); 304 pci_write_config_byte(gx_params->cs55x0, PCI_SUSCFG, suscfg);
307 pci_read_config_byte(gx_params->cs55x0, PCI_SUSCFG, &suscfg); 305 pci_read_config_byte(gx_params->cs55x0, PCI_SUSCFG, &suscfg);
308 306
309 local_irq_restore(flags); 307 local_irq_restore(flags);
310 308
311 gx_params->pci_suscfg = suscfg; 309 gx_params->pci_suscfg = suscfg;
312 310
313 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 311 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
314 312
315 dprintk("suspend modulation w/ duration of ON:%d us, OFF:%d us\n", 313 dprintk("suspend modulation w/ duration of ON:%d us, OFF:%d us\n",
316 gx_params->on_duration * 32, gx_params->off_duration * 32); 314 gx_params->on_duration * 32, gx_params->off_duration * 32);
317 dprintk("suspend modulation w/ clock speed: %d kHz.\n", freqs.new); 315 dprintk("suspend modulation w/ clock speed: %d kHz.\n", freqs.new);
318} 316}
319 317
320/**************************************************************** 318/****************************************************************
@@ -322,10 +320,10 @@ static void gx_set_cpuspeed(unsigned int khz)
322 ****************************************************************/ 320 ****************************************************************/
323 321
324/* 322/*
325 * cpufreq_gx_verify: test if frequency range is valid 323 * cpufreq_gx_verify: test if frequency range is valid
326 * 324 *
327 * This function checks if a given frequency range in kHz is valid 325 * This function checks if a given frequency range in kHz is valid
328 * for the hardware supported by the driver. 326 * for the hardware supported by the driver.
329 */ 327 */
330 328
331static int cpufreq_gx_verify(struct cpufreq_policy *policy) 329static int cpufreq_gx_verify(struct cpufreq_policy *policy)
@@ -333,8 +331,8 @@ static int cpufreq_gx_verify(struct cpufreq_policy *policy)
333 unsigned int tmp_freq = 0; 331 unsigned int tmp_freq = 0;
334 u8 tmp1, tmp2; 332 u8 tmp1, tmp2;
335 333
336 if (!stock_freq || !policy) 334 if (!stock_freq || !policy)
337 return -EINVAL; 335 return -EINVAL;
338 336
339 policy->cpu = 0; 337 policy->cpu = 0;
340 cpufreq_verify_within_limits(policy, (stock_freq / max_duration), stock_freq); 338 cpufreq_verify_within_limits(policy, (stock_freq / max_duration), stock_freq);
@@ -342,14 +340,14 @@ static int cpufreq_gx_verify(struct cpufreq_policy *policy)
342 /* it needs to be assured that at least one supported frequency is 340 /* it needs to be assured that at least one supported frequency is
343 * within policy->min and policy->max. If it is not, policy->max 341 * within policy->min and policy->max. If it is not, policy->max
344 * needs to be increased until one freuqency is supported. 342 * needs to be increased until one freuqency is supported.
345 * policy->min may not be decreased, though. This way we guarantee a 343 * policy->min may not be decreased, though. This way we guarantee a
346 * specific processing capacity. 344 * specific processing capacity.
347 */ 345 */
348 tmp_freq = gx_validate_speed(policy->min, &tmp1, &tmp2); 346 tmp_freq = gx_validate_speed(policy->min, &tmp1, &tmp2);
349 if (tmp_freq < policy->min) 347 if (tmp_freq < policy->min)
350 tmp_freq += stock_freq / max_duration; 348 tmp_freq += stock_freq / max_duration;
351 policy->min = tmp_freq; 349 policy->min = tmp_freq;
352 if (policy->min > policy->max) 350 if (policy->min > policy->max)
353 policy->max = tmp_freq; 351 policy->max = tmp_freq;
354 tmp_freq = gx_validate_speed(policy->max, &tmp1, &tmp2); 352 tmp_freq = gx_validate_speed(policy->max, &tmp1, &tmp2);
355 if (tmp_freq > policy->max) 353 if (tmp_freq > policy->max)
@@ -358,12 +356,12 @@ static int cpufreq_gx_verify(struct cpufreq_policy *policy)
358 if (policy->max < policy->min) 356 if (policy->max < policy->min)
359 policy->max = policy->min; 357 policy->max = policy->min;
360 cpufreq_verify_within_limits(policy, (stock_freq / max_duration), stock_freq); 358 cpufreq_verify_within_limits(policy, (stock_freq / max_duration), stock_freq);
361 359
362 return 0; 360 return 0;
363} 361}
364 362
365/* 363/*
366 * cpufreq_gx_target: 364 * cpufreq_gx_target:
367 * 365 *
368 */ 366 */
369static int cpufreq_gx_target(struct cpufreq_policy *policy, 367static int cpufreq_gx_target(struct cpufreq_policy *policy,
@@ -373,8 +371,8 @@ static int cpufreq_gx_target(struct cpufreq_policy *policy,
373 u8 tmp1, tmp2; 371 u8 tmp1, tmp2;
374 unsigned int tmp_freq; 372 unsigned int tmp_freq;
375 373
376 if (!stock_freq || !policy) 374 if (!stock_freq || !policy)
377 return -EINVAL; 375 return -EINVAL;
378 376
379 policy->cpu = 0; 377 policy->cpu = 0;
380 378
@@ -431,7 +429,7 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
431 return 0; 429 return 0;
432} 430}
433 431
434/* 432/*
435 * cpufreq_gx_init: 433 * cpufreq_gx_init:
436 * MediaGX/Geode GX initialize cpufreq driver 434 * MediaGX/Geode GX initialize cpufreq driver
437 */ 435 */
@@ -452,7 +450,7 @@ static int __init cpufreq_gx_init(void)
452 u32 class_rev; 450 u32 class_rev;
453 451
454 /* Test if we have the right hardware */ 452 /* Test if we have the right hardware */
455 if ((gx_pci = gx_detect_chipset()) == NULL) 453 if ((gx_pci = gx_detect_chipset()) == NULL)
456 return -ENODEV; 454 return -ENODEV;
457 455
458 /* check whether module parameters are sane */ 456 /* check whether module parameters are sane */
@@ -461,10 +459,9 @@ static int __init cpufreq_gx_init(void)
461 459
462 dprintk("geode suspend modulation available.\n"); 460 dprintk("geode suspend modulation available.\n");
463 461
464 params = kmalloc(sizeof(struct gxfreq_params), GFP_KERNEL); 462 params = kzalloc(sizeof(struct gxfreq_params), GFP_KERNEL);
465 if (params == NULL) 463 if (params == NULL)
466 return -ENOMEM; 464 return -ENOMEM;
467 memset(params, 0, sizeof(struct gxfreq_params));
468 465
469 params->cs55x0 = gx_pci; 466 params->cs55x0 = gx_pci;
470 gx_params = params; 467 gx_params = params;
@@ -478,7 +475,7 @@ static int __init cpufreq_gx_init(void)
478 pci_read_config_dword(params->cs55x0, PCI_CLASS_REVISION, &class_rev); 475 pci_read_config_dword(params->cs55x0, PCI_CLASS_REVISION, &class_rev);
479 params->pci_rev = class_rev && 0xff; 476 params->pci_rev = class_rev && 0xff;
480 477
481 if ((ret = cpufreq_register_driver(&gx_suspmod_driver))) { 478 if ((ret = cpufreq_register_driver(&gx_suspmod_driver))) {
482 kfree(params); 479 kfree(params);
483 return ret; /* register error! */ 480 return ret; /* register error! */
484 } 481 }
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.h b/arch/i386/kernel/cpu/cpufreq/longhaul.h
index 2a495c162ec7..d3a95d77ee85 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.h
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.h
@@ -234,7 +234,7 @@ static int __initdata ezrat_eblcr[32] = {
234 234
235/* 235/*
236 * VIA C3 Nehemiah */ 236 * VIA C3 Nehemiah */
237 237
238static int __initdata nehemiah_a_clock_ratio[32] = { 238static int __initdata nehemiah_a_clock_ratio[32] = {
239 100, /* 0000 -> 10.0x */ 239 100, /* 0000 -> 10.0x */
240 160, /* 0001 -> 16.0x */ 240 160, /* 0001 -> 16.0x */
@@ -446,7 +446,7 @@ static int __initdata nehemiah_c_eblcr[32] = {
446 /* end of table */ 446 /* end of table */
447}; 447};
448 448
449/* 449/*
450 * Voltage scales. Div/Mod by 1000 to get actual voltage. 450 * Voltage scales. Div/Mod by 1000 to get actual voltage.
451 * Which scale to use depends on the VRM type in use. 451 * Which scale to use depends on the VRM type in use.
452 */ 452 */
diff --git a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
index cc73a7ae34bc..ab6504efd801 100644
--- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
@@ -14,7 +14,7 @@
14 * The author(s) of this software shall not be held liable for damages 14 * The author(s) of this software shall not be held liable for damages
15 * of any nature resulting due to the use of this software. This 15 * of any nature resulting due to the use of this software. This
16 * software is provided AS-IS with no warranties. 16 * software is provided AS-IS with no warranties.
17 * 17 *
18 * Date Errata Description 18 * Date Errata Description
19 * 20020525 N44, O17 12.5% or 25% DC causes lockup 19 * 20020525 N44, O17 12.5% or 25% DC causes lockup
20 * 20 *
@@ -22,7 +22,7 @@
22 22
23#include <linux/config.h> 23#include <linux/config.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/smp.h> 27#include <linux/smp.h>
28#include <linux/cpufreq.h> 28#include <linux/cpufreq.h>
@@ -30,7 +30,7 @@
30#include <linux/cpumask.h> 30#include <linux/cpumask.h>
31#include <linux/sched.h> /* current / set_cpus_allowed() */ 31#include <linux/sched.h> /* current / set_cpus_allowed() */
32 32
33#include <asm/processor.h> 33#include <asm/processor.h>
34#include <asm/msr.h> 34#include <asm/msr.h>
35#include <asm/timex.h> 35#include <asm/timex.h>
36 36
@@ -79,7 +79,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
79 } else { 79 } else {
80 dprintk("CPU#%d setting duty cycle to %d%%\n", 80 dprintk("CPU#%d setting duty cycle to %d%%\n",
81 cpu, ((125 * newstate) / 10)); 81 cpu, ((125 * newstate) / 10));
82 /* bits 63 - 5 : reserved 82 /* bits 63 - 5 : reserved
83 * bit 4 : enable/disable 83 * bit 4 : enable/disable
84 * bits 3-1 : duty cycle 84 * bits 3-1 : duty cycle
85 * bit 0 : reserved 85 * bit 0 : reserved
@@ -132,7 +132,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
132 } 132 }
133 133
134 /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software 134 /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
135 * Developer's Manual, Volume 3 135 * Developer's Manual, Volume 3
136 */ 136 */
137 cpus_allowed = current->cpus_allowed; 137 cpus_allowed = current->cpus_allowed;
138 138
@@ -206,7 +206,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
206 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4D); 206 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4D);
207} 207}
208 208
209 209
210 210
211static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) 211static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
212{ 212{
@@ -234,7 +234,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
234 dprintk("has errata -- disabling frequencies lower than 2ghz\n"); 234 dprintk("has errata -- disabling frequencies lower than 2ghz\n");
235 break; 235 break;
236 } 236 }
237 237
238 /* get max frequency */ 238 /* get max frequency */
239 stock_freq = cpufreq_p4_get_frequency(c); 239 stock_freq = cpufreq_p4_get_frequency(c);
240 if (!stock_freq) 240 if (!stock_freq)
@@ -244,13 +244,13 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
244 for (i=1; (p4clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) { 244 for (i=1; (p4clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) {
245 if ((i<2) && (has_N44_O17_errata[policy->cpu])) 245 if ((i<2) && (has_N44_O17_errata[policy->cpu]))
246 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID; 246 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID;
247 else if (has_N60_errata[policy->cpu] && p4clockmod_table[i].frequency < 2000000) 247 else if (has_N60_errata[policy->cpu] && ((stock_freq * i)/8) < 2000000)
248 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID; 248 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID;
249 else 249 else
250 p4clockmod_table[i].frequency = (stock_freq * i)/8; 250 p4clockmod_table[i].frequency = (stock_freq * i)/8;
251 } 251 }
252 cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu); 252 cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu);
253 253
254 /* cpuinfo and default policy values */ 254 /* cpuinfo and default policy values */
255 policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 255 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
256 policy->cpuinfo.transition_latency = 1000000; /* assumed */ 256 policy->cpuinfo.transition_latency = 1000000; /* assumed */
@@ -262,7 +262,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
262 262
263static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy) 263static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)
264{ 264{
265 cpufreq_frequency_table_put_attr(policy->cpu); 265 cpufreq_frequency_table_put_attr(policy->cpu);
266 return 0; 266 return 0;
267} 267}
268 268
@@ -298,7 +298,7 @@ static struct freq_attr* p4clockmod_attr[] = {
298}; 298};
299 299
300static struct cpufreq_driver p4clockmod_driver = { 300static struct cpufreq_driver p4clockmod_driver = {
301 .verify = cpufreq_p4_verify, 301 .verify = cpufreq_p4_verify,
302 .target = cpufreq_p4_target, 302 .target = cpufreq_p4_target,
303 .init = cpufreq_p4_cpu_init, 303 .init = cpufreq_p4_cpu_init,
304 .exit = cpufreq_p4_cpu_exit, 304 .exit = cpufreq_p4_cpu_exit,
@@ -310,12 +310,12 @@ static struct cpufreq_driver p4clockmod_driver = {
310 310
311 311
312static int __init cpufreq_p4_init(void) 312static int __init cpufreq_p4_init(void)
313{ 313{
314 struct cpuinfo_x86 *c = cpu_data; 314 struct cpuinfo_x86 *c = cpu_data;
315 int ret; 315 int ret;
316 316
317 /* 317 /*
318 * THERM_CONTROL is architectural for IA32 now, so 318 * THERM_CONTROL is architectural for IA32 now, so
319 * we can rely on the capability checks 319 * we can rely on the capability checks
320 */ 320 */
321 if (c->x86_vendor != X86_VENDOR_INTEL) 321 if (c->x86_vendor != X86_VENDOR_INTEL)
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k6.c b/arch/i386/kernel/cpu/cpufreq/powernow-k6.c
index 222f8cfe3c57..f89524051e4a 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k6.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k6.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/cpufreq.h> 13#include <linux/cpufreq.h>
14#include <linux/ioport.h> 14#include <linux/ioport.h>
@@ -50,7 +50,7 @@ static int powernow_k6_get_cpu_multiplier(void)
50{ 50{
51 u64 invalue = 0; 51 u64 invalue = 0;
52 u32 msrval; 52 u32 msrval;
53 53
54 msrval = POWERNOW_IOPORT + 0x1; 54 msrval = POWERNOW_IOPORT + 0x1;
55 wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ 55 wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
56 invalue=inl(POWERNOW_IOPORT + 0x8); 56 invalue=inl(POWERNOW_IOPORT + 0x8);
@@ -81,7 +81,7 @@ static void powernow_k6_set_state (unsigned int best_i)
81 freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); 81 freqs.old = busfreq * powernow_k6_get_cpu_multiplier();
82 freqs.new = busfreq * clock_ratio[best_i].index; 82 freqs.new = busfreq * clock_ratio[best_i].index;
83 freqs.cpu = 0; /* powernow-k6.c is UP only driver */ 83 freqs.cpu = 0; /* powernow-k6.c is UP only driver */
84 84
85 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 85 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
86 86
87 /* we now need to transform best_i to the BVC format, see AMD#23446 */ 87 /* we now need to transform best_i to the BVC format, see AMD#23446 */
@@ -152,7 +152,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
152 busfreq = cpu_khz / max_multiplier; 152 busfreq = cpu_khz / max_multiplier;
153 153
154 /* table init */ 154 /* table init */
155 for (i=0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { 155 for (i=0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
156 if (clock_ratio[i].index > max_multiplier) 156 if (clock_ratio[i].index > max_multiplier)
157 clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; 157 clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID;
158 else 158 else
@@ -182,7 +182,7 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
182 powernow_k6_set_state(i); 182 powernow_k6_set_state(i);
183 } 183 }
184 cpufreq_frequency_table_put_attr(policy->cpu); 184 cpufreq_frequency_table_put_attr(policy->cpu);
185 return 0; 185 return 0;
186} 186}
187 187
188static unsigned int powernow_k6_get(unsigned int cpu) 188static unsigned int powernow_k6_get(unsigned int cpu)
@@ -196,8 +196,8 @@ static struct freq_attr* powernow_k6_attr[] = {
196}; 196};
197 197
198static struct cpufreq_driver powernow_k6_driver = { 198static struct cpufreq_driver powernow_k6_driver = {
199 .verify = powernow_k6_verify, 199 .verify = powernow_k6_verify,
200 .target = powernow_k6_target, 200 .target = powernow_k6_target,
201 .init = powernow_k6_cpu_init, 201 .init = powernow_k6_cpu_init,
202 .exit = powernow_k6_cpu_exit, 202 .exit = powernow_k6_cpu_exit,
203 .get = powernow_k6_get, 203 .get = powernow_k6_get,
@@ -215,7 +215,7 @@ static struct cpufreq_driver powernow_k6_driver = {
215 * on success. 215 * on success.
216 */ 216 */
217static int __init powernow_k6_init(void) 217static int __init powernow_k6_init(void)
218{ 218{
219 struct cpuinfo_x86 *c = cpu_data; 219 struct cpuinfo_x86 *c = cpu_data;
220 220
221 if ((c->x86_vendor != X86_VENDOR_AMD) || (c->x86 != 5) || 221 if ((c->x86_vendor != X86_VENDOR_AMD) || (c->x86 != 5) ||
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
index edcd626001da..2bf4237cb94e 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
@@ -199,8 +199,8 @@ static int get_ranges (unsigned char *pst)
199 powernow_table[j].index |= (vid << 8); /* upper 8 bits */ 199 powernow_table[j].index |= (vid << 8); /* upper 8 bits */
200 200
201 dprintk (" FID: 0x%x (%d.%dx [%dMHz]) " 201 dprintk (" FID: 0x%x (%d.%dx [%dMHz]) "
202 "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, 202 "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
203 fid_codes[fid] % 10, speed/1000, vid, 203 fid_codes[fid] % 10, speed/1000, vid,
204 mobile_vid_table[vid]/1000, 204 mobile_vid_table[vid]/1000,
205 mobile_vid_table[vid]%1000); 205 mobile_vid_table[vid]%1000);
206 } 206 }
@@ -368,8 +368,8 @@ static int powernow_acpi_init(void)
368 } 368 }
369 369
370 dprintk (" FID: 0x%x (%d.%dx [%dMHz]) " 370 dprintk (" FID: 0x%x (%d.%dx [%dMHz]) "
371 "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, 371 "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
372 fid_codes[fid] % 10, speed/1000, vid, 372 fid_codes[fid] % 10, speed/1000, vid,
373 mobile_vid_table[vid]/1000, 373 mobile_vid_table[vid]/1000,
374 mobile_vid_table[vid]%1000); 374 mobile_vid_table[vid]%1000);
375 375
@@ -460,7 +460,7 @@ static int powernow_decode_bios (int maxfid, int startvid)
460 (maxfid==pst->maxfid) && (startvid==pst->startvid)) 460 (maxfid==pst->maxfid) && (startvid==pst->startvid))
461 { 461 {
462 dprintk ("PST:%d (@%p)\n", i, pst); 462 dprintk ("PST:%d (@%p)\n", i, pst);
463 dprintk (" cpuid: 0x%x fsb: %d maxFID: 0x%x startvid: 0x%x\n", 463 dprintk (" cpuid: 0x%x fsb: %d maxFID: 0x%x startvid: 0x%x\n",
464 pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid); 464 pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid);
465 465
466 ret = get_ranges ((char *) pst + sizeof (struct pst_s)); 466 ret = get_ranges ((char *) pst + sizeof (struct pst_s));
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index 3d5110b65cc3..e5bc06480ff9 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -45,7 +45,7 @@
45 45
46#define PFX "powernow-k8: " 46#define PFX "powernow-k8: "
47#define BFX PFX "BIOS error: " 47#define BFX PFX "BIOS error: "
48#define VERSION "version 1.60.0" 48#define VERSION "version 1.60.1"
49#include "powernow-k8.h" 49#include "powernow-k8.h"
50 50
51/* serialize freq changes */ 51/* serialize freq changes */
@@ -54,7 +54,7 @@ static DECLARE_MUTEX(fidvid_sem);
54static struct powernow_k8_data *powernow_data[NR_CPUS]; 54static struct powernow_k8_data *powernow_data[NR_CPUS];
55 55
56#ifndef CONFIG_SMP 56#ifndef CONFIG_SMP
57static cpumask_t cpu_core_map[1]; 57static cpumask_t cpu_core_map[1] = { CPU_MASK_ALL };
58#endif 58#endif
59 59
60/* Return a frequency in MHz, given an input fid */ 60/* Return a frequency in MHz, given an input fid */
@@ -83,11 +83,10 @@ static u32 find_millivolts_from_vid(struct powernow_k8_data *data, u32 vid)
83 */ 83 */
84static u32 convert_fid_to_vco_fid(u32 fid) 84static u32 convert_fid_to_vco_fid(u32 fid)
85{ 85{
86 if (fid < HI_FID_TABLE_BOTTOM) { 86 if (fid < HI_FID_TABLE_BOTTOM)
87 return 8 + (2 * fid); 87 return 8 + (2 * fid);
88 } else { 88 else
89 return fid; 89 return fid;
90 }
91} 90}
92 91
93/* 92/*
@@ -177,7 +176,7 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid)
177 if (i++ > 100) { 176 if (i++ > 100) {
178 printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n"); 177 printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n");
179 return 1; 178 return 1;
180 } 179 }
181 } while (query_current_values_with_pending_wait(data)); 180 } while (query_current_values_with_pending_wait(data));
182 181
183 count_off_irt(data); 182 count_off_irt(data);
@@ -474,8 +473,10 @@ static int check_supported_cpu(unsigned int cpu)
474 goto out; 473 goto out;
475 474
476 eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); 475 eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
476 if ((eax & CPUID_XFAM) != CPUID_XFAM_K8)
477 goto out;
478
477 if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || 479 if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) ||
478 ((eax & CPUID_XFAM) != CPUID_XFAM_K8) ||
479 ((eax & CPUID_XMOD) > CPUID_XMOD_REV_G)) { 480 ((eax & CPUID_XMOD) > CPUID_XMOD_REV_G)) {
480 printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax); 481 printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax);
481 goto out; 482 goto out;
@@ -780,9 +781,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
780 /* verify only 1 entry from the lo frequency table */ 781 /* verify only 1 entry from the lo frequency table */
781 if (fid < HI_FID_TABLE_BOTTOM) { 782 if (fid < HI_FID_TABLE_BOTTOM) {
782 if (cntlofreq) { 783 if (cntlofreq) {
783 /* if both entries are the same, ignore this 784 /* if both entries are the same, ignore this one ... */
784 * one...
785 */
786 if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) || 785 if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) ||
787 (powernow_table[i].index != powernow_table[cntlofreq].index)) { 786 (powernow_table[i].index != powernow_table[cntlofreq].index)) {
788 printk(KERN_ERR PFX "Too many lo freq table entries\n"); 787 printk(KERN_ERR PFX "Too many lo freq table entries\n");
@@ -854,7 +853,7 @@ static int transition_frequency(struct powernow_k8_data *data, unsigned int inde
854 dprintk("cpu %d transition to index %u\n", smp_processor_id(), index); 853 dprintk("cpu %d transition to index %u\n", smp_processor_id(), index);
855 854
856 /* fid are the lower 8 bits of the index we stored into 855 /* fid are the lower 8 bits of the index we stored into
857 * the cpufreq frequency table in find_psb_table, vid are 856 * the cpufreq frequency table in find_psb_table, vid are
858 * the upper 8 bits. 857 * the upper 8 bits.
859 */ 858 */
860 859
@@ -909,7 +908,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
909 u32 checkvid = data->currvid; 908 u32 checkvid = data->currvid;
910 unsigned int newstate; 909 unsigned int newstate;
911 int ret = -EIO; 910 int ret = -EIO;
912 int i;
913 911
914 /* only run on specific CPU from here on */ 912 /* only run on specific CPU from here on */
915 oldmask = current->cpus_allowed; 913 oldmask = current->cpus_allowed;
@@ -955,12 +953,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
955 up(&fidvid_sem); 953 up(&fidvid_sem);
956 goto err_out; 954 goto err_out;
957 } 955 }
958
959 /* Update all the fid/vids of our siblings */
960 for_each_cpu_mask(i, cpu_core_map[pol->cpu]) {
961 powernow_data[i]->currvid = data->currvid;
962 powernow_data[i]->currfid = data->currfid;
963 }
964 up(&fidvid_sem); 956 up(&fidvid_sem);
965 957
966 pol->cur = find_khz_freq_from_fid(data->currfid); 958 pol->cur = find_khz_freq_from_fid(data->currfid);
@@ -1048,7 +1040,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1048 pol->governor = CPUFREQ_DEFAULT_GOVERNOR; 1040 pol->governor = CPUFREQ_DEFAULT_GOVERNOR;
1049 pol->cpus = cpu_core_map[pol->cpu]; 1041 pol->cpus = cpu_core_map[pol->cpu];
1050 1042
1051 /* Take a crude guess here. 1043 /* Take a crude guess here.
1052 * That guess was in microseconds, so multiply with 1000 */ 1044 * That guess was in microseconds, so multiply with 1000 */
1053 pol->cpuinfo.transition_latency = (((data->rvo + 8) * data->vstable * VST_UNITS_20US) 1045 pol->cpuinfo.transition_latency = (((data->rvo + 8) * data->vstable * VST_UNITS_20US)
1054 + (3 * (1 << data->irt) * 10)) * 1000; 1046 + (3 * (1 << data->irt) * 10)) * 1000;
@@ -1070,9 +1062,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1070 printk("cpu_init done, current fid 0x%x, vid 0x%x\n", 1062 printk("cpu_init done, current fid 0x%x, vid 0x%x\n",
1071 data->currfid, data->currvid); 1063 data->currfid, data->currvid);
1072 1064
1073 for_each_cpu_mask(i, cpu_core_map[pol->cpu]) { 1065 for_each_cpu_mask(i, cpu_core_map[pol->cpu])
1074 powernow_data[i] = data; 1066 powernow_data[i] = data;
1075 }
1076 1067
1077 return 0; 1068 return 0;
1078 1069
@@ -1145,14 +1136,14 @@ static int __cpuinit powernowk8_init(void)
1145{ 1136{
1146 unsigned int i, supported_cpus = 0; 1137 unsigned int i, supported_cpus = 0;
1147 1138
1148 for_each_cpu(i) { 1139 for_each_online_cpu(i) {
1149 if (check_supported_cpu(i)) 1140 if (check_supported_cpu(i))
1150 supported_cpus++; 1141 supported_cpus++;
1151 } 1142 }
1152 1143
1153 if (supported_cpus == num_online_cpus()) { 1144 if (supported_cpus == num_online_cpus()) {
1154 printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron processors (" VERSION ")\n", 1145 printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron "
1155 supported_cpus); 1146 "processors (" VERSION ")\n", supported_cpus);
1156 return cpufreq_register_driver(&cpufreq_amd64_driver); 1147 return cpufreq_register_driver(&cpufreq_amd64_driver);
1157 } 1148 }
1158 1149
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
index d0de37d58e9a..00ea899c17e1 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
@@ -63,7 +63,7 @@ struct powernow_k8_data {
63#define MSR_C_LO_VID_SHIFT 8 63#define MSR_C_LO_VID_SHIFT 8
64 64
65/* Field definitions within the FID VID High Control MSR : */ 65/* Field definitions within the FID VID High Control MSR : */
66#define MSR_C_HI_STP_GNT_TO 0x000fffff 66#define MSR_C_HI_STP_GNT_TO 0x000fffff
67 67
68/* Field definitions within the FID VID Low Status MSR : */ 68/* Field definitions within the FID VID Low Status MSR : */
69#define MSR_S_LO_CHANGE_PENDING 0x80000000 /* cleared when completed */ 69#define MSR_S_LO_CHANGE_PENDING 0x80000000 /* cleared when completed */
@@ -123,7 +123,7 @@ struct powernow_k8_data {
123 * Most values of interest are enocoded in a single field of the _PSS 123 * Most values of interest are enocoded in a single field of the _PSS
124 * entries: the "control" value. 124 * entries: the "control" value.
125 */ 125 */
126 126
127#define IRT_SHIFT 30 127#define IRT_SHIFT 30
128#define RVO_SHIFT 28 128#define RVO_SHIFT 28
129#define EXT_TYPE_SHIFT 27 129#define EXT_TYPE_SHIFT 27
@@ -185,7 +185,7 @@ static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned
185#ifndef for_each_cpu_mask 185#ifndef for_each_cpu_mask
186#define for_each_cpu_mask(i,mask) for (i=0;i<1;i++) 186#define for_each_cpu_mask(i,mask) for (i=0;i<1;i++)
187#endif 187#endif
188 188
189#ifdef CONFIG_SMP 189#ifdef CONFIG_SMP
190static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[]) 190static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[])
191{ 191{
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index c173c0fa117a..b0ff9075708c 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -479,15 +479,13 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
479 unsigned l, h; 479 unsigned l, h;
480 int ret; 480 int ret;
481 int i; 481 int i;
482 struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
483 482
484 /* Only Intel makes Enhanced Speedstep-capable CPUs */ 483 /* Only Intel makes Enhanced Speedstep-capable CPUs */
485 if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST)) 484 if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST))
486 return -ENODEV; 485 return -ENODEV;
487 486
488 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { 487 if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
489 centrino_driver.flags |= CPUFREQ_CONST_LOOPS; 488 centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
490 }
491 489
492 if (centrino_cpu_init_acpi(policy)) { 490 if (centrino_cpu_init_acpi(policy)) {
493 if (policy->cpu != 0) 491 if (policy->cpu != 0)
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
index 7c47005a1805..4f46cac155c4 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
@@ -9,7 +9,7 @@
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/moduleparam.h> 13#include <linux/moduleparam.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/cpufreq.h> 15#include <linux/cpufreq.h>
@@ -36,8 +36,8 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
36 /* See table 14 of p3_ds.pdf and table 22 of 29834003.pdf */ 36 /* See table 14 of p3_ds.pdf and table 22 of 29834003.pdf */
37 struct { 37 struct {
38 unsigned int ratio; /* Frequency Multiplier (x10) */ 38 unsigned int ratio; /* Frequency Multiplier (x10) */
39 u8 bitmap; /* power on configuration bits 39 u8 bitmap; /* power on configuration bits
40 [27, 25:22] (in MSR 0x2a) */ 40 [27, 25:22] (in MSR 0x2a) */
41 } msr_decode_mult [] = { 41 } msr_decode_mult [] = {
42 { 30, 0x01 }, 42 { 30, 0x01 },
43 { 35, 0x05 }, 43 { 35, 0x05 },
@@ -58,9 +58,9 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
58 58
59 /* PIII(-M) FSB settings: see table b1-b of 24547206.pdf */ 59 /* PIII(-M) FSB settings: see table b1-b of 24547206.pdf */
60 struct { 60 struct {
61 unsigned int value; /* Front Side Bus speed in MHz */ 61 unsigned int value; /* Front Side Bus speed in MHz */
62 u8 bitmap; /* power on configuration bits [18: 19] 62 u8 bitmap; /* power on configuration bits [18: 19]
63 (in MSR 0x2a) */ 63 (in MSR 0x2a) */
64 } msr_decode_fsb [] = { 64 } msr_decode_fsb [] = {
65 { 66, 0x0 }, 65 { 66, 0x0 },
66 { 100, 0x2 }, 66 { 100, 0x2 },
@@ -68,8 +68,8 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
68 { 0, 0xff} 68 { 0, 0xff}
69 }; 69 };
70 70
71 u32 msr_lo, msr_tmp; 71 u32 msr_lo, msr_tmp;
72 int i = 0, j = 0; 72 int i = 0, j = 0;
73 73
74 /* read MSR 0x2a - we only need the low 32 bits */ 74 /* read MSR 0x2a - we only need the low 32 bits */
75 rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); 75 rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
@@ -106,7 +106,7 @@ static unsigned int pentium3_get_frequency (unsigned int processor)
106 106
107static unsigned int pentiumM_get_frequency(void) 107static unsigned int pentiumM_get_frequency(void)
108{ 108{
109 u32 msr_lo, msr_tmp; 109 u32 msr_lo, msr_tmp;
110 110
111 rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp); 111 rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
112 dprintk("PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp); 112 dprintk("PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
@@ -134,7 +134,7 @@ static unsigned int pentium4_get_frequency(void)
134 134
135 dprintk("P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi); 135 dprintk("P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi);
136 136
137 /* decode the FSB: see IA-32 Intel (C) Architecture Software 137 /* decode the FSB: see IA-32 Intel (C) Architecture Software
138 * Developer's Manual, Volume 3: System Prgramming Guide, 138 * Developer's Manual, Volume 3: System Prgramming Guide,
139 * revision #12 in Table B-1: MSRs in the Pentium 4 and 139 * revision #12 in Table B-1: MSRs in the Pentium 4 and
140 * Intel Xeon Processors, on page B-4 and B-5. 140 * Intel Xeon Processors, on page B-4 and B-5.
@@ -170,7 +170,7 @@ static unsigned int pentium4_get_frequency(void)
170 return (fsb * mult); 170 return (fsb * mult);
171} 171}
172 172
173 173
174unsigned int speedstep_get_processor_frequency(unsigned int processor) 174unsigned int speedstep_get_processor_frequency(unsigned int processor)
175{ 175{
176 switch (processor) { 176 switch (processor) {
@@ -198,11 +198,11 @@ EXPORT_SYMBOL_GPL(speedstep_get_processor_frequency);
198unsigned int speedstep_detect_processor (void) 198unsigned int speedstep_detect_processor (void)
199{ 199{
200 struct cpuinfo_x86 *c = cpu_data; 200 struct cpuinfo_x86 *c = cpu_data;
201 u32 ebx, msr_lo, msr_hi; 201 u32 ebx, msr_lo, msr_hi;
202 202
203 dprintk("x86: %x, model: %x\n", c->x86, c->x86_model); 203 dprintk("x86: %x, model: %x\n", c->x86, c->x86_model);
204 204
205 if ((c->x86_vendor != X86_VENDOR_INTEL) || 205 if ((c->x86_vendor != X86_VENDOR_INTEL) ||
206 ((c->x86 != 6) && (c->x86 != 0xF))) 206 ((c->x86 != 6) && (c->x86 != 0xF)))
207 return 0; 207 return 0;
208 208
@@ -218,15 +218,15 @@ unsigned int speedstep_detect_processor (void)
218 dprintk("ebx value is %x, x86_mask is %x\n", ebx, c->x86_mask); 218 dprintk("ebx value is %x, x86_mask is %x\n", ebx, c->x86_mask);
219 219
220 switch (c->x86_mask) { 220 switch (c->x86_mask) {
221 case 4: 221 case 4:
222 /* 222 /*
223 * B-stepping [M-P4-M] 223 * B-stepping [M-P4-M]
224 * sample has ebx = 0x0f, production has 0x0e. 224 * sample has ebx = 0x0f, production has 0x0e.
225 */ 225 */
226 if ((ebx == 0x0e) || (ebx == 0x0f)) 226 if ((ebx == 0x0e) || (ebx == 0x0f))
227 return SPEEDSTEP_PROCESSOR_P4M; 227 return SPEEDSTEP_PROCESSOR_P4M;
228 break; 228 break;
229 case 7: 229 case 7:
230 /* 230 /*
231 * C-stepping [M-P4-M] 231 * C-stepping [M-P4-M]
232 * needs to have ebx=0x0e, else it's a celeron: 232 * needs to have ebx=0x0e, else it's a celeron:
@@ -253,7 +253,7 @@ unsigned int speedstep_detect_processor (void)
253 * also, M-P4M HTs have ebx=0x8, too 253 * also, M-P4M HTs have ebx=0x8, too
254 * For now, they are distinguished by the model_id string 254 * For now, they are distinguished by the model_id string
255 */ 255 */
256 if ((ebx == 0x0e) || (strstr(c->x86_model_id,"Mobile Intel(R) Pentium(R) 4") != NULL)) 256 if ((ebx == 0x0e) || (strstr(c->x86_model_id,"Mobile Intel(R) Pentium(R) 4") != NULL))
257 return SPEEDSTEP_PROCESSOR_P4M; 257 return SPEEDSTEP_PROCESSOR_P4M;
258 break; 258 break;
259 default: 259 default:
@@ -264,8 +264,7 @@ unsigned int speedstep_detect_processor (void)
264 264
265 switch (c->x86_model) { 265 switch (c->x86_model) {
266 case 0x0B: /* Intel PIII [Tualatin] */ 266 case 0x0B: /* Intel PIII [Tualatin] */
267 /* cpuid_ebx(1) is 0x04 for desktop PIII, 267 /* cpuid_ebx(1) is 0x04 for desktop PIII, 0x06 for mobile PIII-M */
268 0x06 for mobile PIII-M */
269 ebx = cpuid_ebx(0x00000001); 268 ebx = cpuid_ebx(0x00000001);
270 dprintk("ebx is %x\n", ebx); 269 dprintk("ebx is %x\n", ebx);
271 270
@@ -275,9 +274,8 @@ unsigned int speedstep_detect_processor (void)
275 return 0; 274 return 0;
276 275
277 /* So far all PIII-M processors support SpeedStep. See 276 /* So far all PIII-M processors support SpeedStep. See
278 * Intel's 24540640.pdf of June 2003 277 * Intel's 24540640.pdf of June 2003
279 */ 278 */
280
281 return SPEEDSTEP_PROCESSOR_PIII_T; 279 return SPEEDSTEP_PROCESSOR_PIII_T;
282 280
283 case 0x08: /* Intel PIII [Coppermine] */ 281 case 0x08: /* Intel PIII [Coppermine] */
@@ -399,7 +397,7 @@ unsigned int speedstep_get_freqs(unsigned int processor,
399 } 397 }
400 } 398 }
401 399
402 out: 400out:
403 local_irq_restore(flags); 401 local_irq_restore(flags);
404 return (ret); 402 return (ret);
405} 403}
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
index 6a727fd3a77e..b735429c50b4 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
@@ -14,7 +14,7 @@
14 14
15#define SPEEDSTEP_PROCESSOR_PIII_C_EARLY 0x00000001 /* Coppermine core */ 15#define SPEEDSTEP_PROCESSOR_PIII_C_EARLY 0x00000001 /* Coppermine core */
16#define SPEEDSTEP_PROCESSOR_PIII_C 0x00000002 /* Coppermine core */ 16#define SPEEDSTEP_PROCESSOR_PIII_C 0x00000002 /* Coppermine core */
17#define SPEEDSTEP_PROCESSOR_PIII_T 0x00000003 /* Tualatin core */ 17#define SPEEDSTEP_PROCESSOR_PIII_T 0x00000003 /* Tualatin core */
18#define SPEEDSTEP_PROCESSOR_P4M 0x00000004 /* P4-M */ 18#define SPEEDSTEP_PROCESSOR_P4M 0x00000004 /* P4-M */
19 19
20/* the following processors are not speedstep-capable and are not auto-detected 20/* the following processors are not speedstep-capable and are not auto-detected
@@ -25,8 +25,8 @@
25 25
26/* speedstep states -- only two of them */ 26/* speedstep states -- only two of them */
27 27
28#define SPEEDSTEP_HIGH 0x00000000 28#define SPEEDSTEP_HIGH 0x00000000
29#define SPEEDSTEP_LOW 0x00000001 29#define SPEEDSTEP_LOW 0x00000001
30 30
31 31
32/* detect a speedstep-capable processor */ 32/* detect a speedstep-capable processor */
@@ -36,13 +36,13 @@ extern unsigned int speedstep_detect_processor (void);
36extern unsigned int speedstep_get_processor_frequency(unsigned int processor); 36extern unsigned int speedstep_get_processor_frequency(unsigned int processor);
37 37
38 38
39/* detect the low and high speeds of the processor. The callback 39/* detect the low and high speeds of the processor. The callback
40 * set_state"'s first argument is either SPEEDSTEP_HIGH or 40 * set_state"'s first argument is either SPEEDSTEP_HIGH or
41 * SPEEDSTEP_LOW; the second argument is zero so that no 41 * SPEEDSTEP_LOW; the second argument is zero so that no
42 * cpufreq_notify_transition calls are initiated. 42 * cpufreq_notify_transition calls are initiated.
43 */ 43 */
44extern unsigned int speedstep_get_freqs(unsigned int processor, 44extern unsigned int speedstep_get_freqs(unsigned int processor,
45 unsigned int *low_speed, 45 unsigned int *low_speed,
46 unsigned int *high_speed, 46 unsigned int *high_speed,
47 unsigned int *transition_latency, 47 unsigned int *transition_latency,
48 void (*set_state) (unsigned int state)); 48 void (*set_state) (unsigned int state));
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
index 28cc5d524afc..c28333d53646 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
@@ -13,8 +13,8 @@
13 *********************************************************************/ 13 *********************************************************************/
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
@@ -28,21 +28,21 @@
28 * 28 *
29 * These parameters are got from IST-SMI BIOS call. 29 * These parameters are got from IST-SMI BIOS call.
30 * If user gives it, these are used. 30 * If user gives it, these are used.
31 * 31 *
32 */ 32 */
33static int smi_port = 0; 33static int smi_port = 0;
34static int smi_cmd = 0; 34static int smi_cmd = 0;
35static unsigned int smi_sig = 0; 35static unsigned int smi_sig = 0;
36 36
37/* info about the processor */ 37/* info about the processor */
38static unsigned int speedstep_processor = 0; 38static unsigned int speedstep_processor = 0;
39 39
40/* 40/*
41 * There are only two frequency states for each processor. Values 41 * There are only two frequency states for each processor. Values
42 * are in kHz for the time being. 42 * are in kHz for the time being.
43 */ 43 */
44static struct cpufreq_frequency_table speedstep_freqs[] = { 44static struct cpufreq_frequency_table speedstep_freqs[] = {
45 {SPEEDSTEP_HIGH, 0}, 45 {SPEEDSTEP_HIGH, 0},
46 {SPEEDSTEP_LOW, 0}, 46 {SPEEDSTEP_LOW, 0},
47 {0, CPUFREQ_TABLE_END}, 47 {0, CPUFREQ_TABLE_END},
48}; 48};
@@ -75,7 +75,9 @@ static int speedstep_smi_ownership (void)
75 __asm__ __volatile__( 75 __asm__ __volatile__(
76 "out %%al, (%%dx)\n" 76 "out %%al, (%%dx)\n"
77 : "=D" (result) 77 : "=D" (result)
78 : "a" (command), "b" (function), "c" (0), "d" (smi_port), "D" (0), "S" (magic) 78 : "a" (command), "b" (function), "c" (0), "d" (smi_port),
79 "D" (0), "S" (magic)
80 : "memory"
79 ); 81 );
80 82
81 dprintk("result is %x\n", result); 83 dprintk("result is %x\n", result);
@@ -123,7 +125,7 @@ static int speedstep_smi_get_freqs (unsigned int *low, unsigned int *high)
123 *low = low_mhz * 1000; 125 *low = low_mhz * 1000;
124 126
125 return result; 127 return result;
126} 128}
127 129
128/** 130/**
129 * speedstep_get_state - set the SpeedStep state 131 * speedstep_get_state - set the SpeedStep state
@@ -204,7 +206,7 @@ static void speedstep_set_state (unsigned int state)
204 * speedstep_target - set a new CPUFreq policy 206 * speedstep_target - set a new CPUFreq policy
205 * @policy: new policy 207 * @policy: new policy
206 * @target_freq: new freq 208 * @target_freq: new freq
207 * @relation: 209 * @relation:
208 * 210 *
209 * Sets a new CPUFreq policy/freq. 211 * Sets a new CPUFreq policy/freq.
210 */ 212 */
@@ -283,7 +285,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
283 state = speedstep_get_state(); 285 state = speedstep_get_state();
284 speed = speedstep_freqs[state].frequency; 286 speed = speedstep_freqs[state].frequency;
285 287
286 dprintk("currently at %s speed setting - %i MHz\n", 288 dprintk("currently at %s speed setting - %i MHz\n",
287 (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) ? "low" : "high", 289 (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) ? "low" : "high",
288 (speed / 1000)); 290 (speed / 1000));
289 291
@@ -296,7 +298,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
296 if (result) 298 if (result)
297 return (result); 299 return (result);
298 300
299 cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu); 301 cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu);
300 302
301 return 0; 303 return 0;
302} 304}
@@ -332,8 +334,8 @@ static struct freq_attr* speedstep_attr[] = {
332 334
333static struct cpufreq_driver speedstep_driver = { 335static struct cpufreq_driver speedstep_driver = {
334 .name = "speedstep-smi", 336 .name = "speedstep-smi",
335 .verify = speedstep_verify, 337 .verify = speedstep_verify,
336 .target = speedstep_target, 338 .target = speedstep_target,
337 .init = speedstep_cpu_init, 339 .init = speedstep_cpu_init,
338 .exit = speedstep_cpu_exit, 340 .exit = speedstep_cpu_exit,
339 .get = speedstep_get, 341 .get = speedstep_get,
@@ -370,13 +372,12 @@ static int __init speedstep_init(void)
370 return -ENODEV; 372 return -ENODEV;
371 } 373 }
372 374
373 dprintk("signature:0x%.8lx, command:0x%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n", 375 dprintk("signature:0x%.8lx, command:0x%.8lx, event:0x%.8lx, perf_level:0x%.8lx.\n",
374 ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level); 376 ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level);
375 377
376 378 /* Error if no IST-SMI BIOS or no PARM
377 /* Error if no IST-SMI BIOS or no PARM
378 sig= 'ISGE' aka 'Intel Speedstep Gate E' */ 379 sig= 'ISGE' aka 'Intel Speedstep Gate E' */
379 if ((ist_info.signature != 0x47534943) && ( 380 if ((ist_info.signature != 0x47534943) && (
380 (smi_port == 0) || (smi_cmd == 0))) 381 (smi_port == 0) || (smi_cmd == 0)))
381 return -ENODEV; 382 return -ENODEV;
382 383
@@ -386,17 +387,15 @@ static int __init speedstep_init(void)
386 smi_sig = ist_info.signature; 387 smi_sig = ist_info.signature;
387 388
388 /* setup smi_port from MODLULE_PARM or BIOS */ 389 /* setup smi_port from MODLULE_PARM or BIOS */
389 if ((smi_port > 0xff) || (smi_port < 0)) { 390 if ((smi_port > 0xff) || (smi_port < 0))
390 return -EINVAL; 391 return -EINVAL;
391 } else if (smi_port == 0) { 392 else if (smi_port == 0)
392 smi_port = ist_info.command & 0xff; 393 smi_port = ist_info.command & 0xff;
393 }
394 394
395 if ((smi_cmd > 0xff) || (smi_cmd < 0)) { 395 if ((smi_cmd > 0xff) || (smi_cmd < 0))
396 return -EINVAL; 396 return -EINVAL;
397 } else if (smi_cmd == 0) { 397 else if (smi_cmd == 0)
398 smi_cmd = (ist_info.command >> 16) & 0xff; 398 smi_cmd = (ist_info.command >> 16) & 0xff;
399 }
400 399
401 return cpufreq_register_driver(&speedstep_driver); 400 return cpufreq_register_driver(&speedstep_driver);
402} 401}
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 5cfbd8011698..f94cdb7aca50 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -45,7 +45,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
46 46
47 /* Intel-defined (#2) */ 47 /* Intel-defined (#2) */
48 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", NULL, "est", 48 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
49 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL, 49 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
50 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 50 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
51 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 51 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index 6a93d75db431..ebc8dc116c43 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -5,6 +5,7 @@
5#include <linux/dmi.h> 5#include <linux/dmi.h>
6#include <linux/bootmem.h> 6#include <linux/bootmem.h>
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <asm/dmi.h>
8 9
9static char * __init dmi_string(struct dmi_header *dm, u8 s) 10static char * __init dmi_string(struct dmi_header *dm, u8 s)
10{ 11{
@@ -106,7 +107,7 @@ static void __init dmi_save_devices(struct dmi_header *dm)
106 struct dmi_device *dev; 107 struct dmi_device *dev;
107 108
108 for (i = 0; i < count; i++) { 109 for (i = 0; i < count; i++) {
109 char *d = ((char *) dm) + (i * 2); 110 char *d = (char *)(dm + 1) + (i * 2);
110 111
111 /* Skip disabled device */ 112 /* Skip disabled device */
112 if ((*d & 0x80) == 0) 113 if ((*d & 0x80) == 0)
@@ -299,3 +300,33 @@ struct dmi_device * dmi_find_device(int type, const char *name,
299 return NULL; 300 return NULL;
300} 301}
301EXPORT_SYMBOL(dmi_find_device); 302EXPORT_SYMBOL(dmi_find_device);
303
304/**
305 * dmi_get_year - Return year of a DMI date
306 * @field: data index (like dmi_get_system_info)
307 *
308 * Returns -1 when the field doesn't exist. 0 when it is broken.
309 */
310int dmi_get_year(int field)
311{
312 int year;
313 char *s = dmi_get_system_info(field);
314
315 if (!s)
316 return -1;
317 if (*s == '\0')
318 return 0;
319 s = strrchr(s, '/');
320 if (!s)
321 return 0;
322
323 s += 1;
324 year = simple_strtoul(s, NULL, 0);
325 if (year && year < 100) { /* 2-digit year */
326 year += 1900;
327 if (year < 1996) /* no dates < spec 1.0 */
328 year += 100;
329 }
330
331 return year;
332}
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 5390b521aca0..55bc365b8753 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -202,8 +202,6 @@ static inline void mark_microcode_update (int cpu_num, microcode_header_t *mc_he
202 } else if (mc_header->rev == uci->rev) { 202 } else if (mc_header->rev == uci->rev) {
203 /* notify the caller of success on this cpu */ 203 /* notify the caller of success on this cpu */
204 uci->err = MC_SUCCESS; 204 uci->err = MC_SUCCESS;
205 printk(KERN_ERR "microcode: CPU%d already at revision"
206 " 0x%x (current=0x%x)\n", cpu_num, mc_header->rev, uci->rev);
207 goto out; 205 goto out;
208 } 206 }
209 207
@@ -369,7 +367,6 @@ static void do_update_one (void * unused)
369 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; 367 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
370 368
371 if (uci->mc == NULL) { 369 if (uci->mc == NULL) {
372 printk(KERN_INFO "microcode: No new microcode data for CPU%d\n", cpu_num);
373 return; 370 return;
374 } 371 }
375 372
@@ -511,7 +508,6 @@ static int __init microcode_init (void)
511static void __exit microcode_exit (void) 508static void __exit microcode_exit (void)
512{ 509{
513 misc_deregister(&microcode_dev); 510 misc_deregister(&microcode_dev);
514 printk(KERN_INFO "IA-32 Microcode Update Driver v" MICROCODE_VERSION " unregistered\n");
515} 511}
516 512
517module_init(microcode_init) 513module_init(microcode_init)
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 4c470e99a742..82371d83bfa9 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -1003,7 +1003,6 @@ void cpu_exit_clear(void)
1003 1003
1004 cpu_clear(cpu, cpu_callout_map); 1004 cpu_clear(cpu, cpu_callout_map);
1005 cpu_clear(cpu, cpu_callin_map); 1005 cpu_clear(cpu, cpu_callin_map);
1006 cpu_clear(cpu, cpu_present_map);
1007 1006
1008 cpu_clear(cpu, smp_commenced_mask); 1007 cpu_clear(cpu, smp_commenced_mask);
1009 unmap_cpu_to_logical_apicid(cpu); 1008 unmap_cpu_to_logical_apicid(cpu);
@@ -1015,31 +1014,20 @@ struct warm_boot_cpu_info {
1015 int cpu; 1014 int cpu;
1016}; 1015};
1017 1016
1018static void __devinit do_warm_boot_cpu(void *p) 1017static void __cpuinit do_warm_boot_cpu(void *p)
1019{ 1018{
1020 struct warm_boot_cpu_info *info = p; 1019 struct warm_boot_cpu_info *info = p;
1021 do_boot_cpu(info->apicid, info->cpu); 1020 do_boot_cpu(info->apicid, info->cpu);
1022 complete(info->complete); 1021 complete(info->complete);
1023} 1022}
1024 1023
1025int __devinit smp_prepare_cpu(int cpu) 1024static int __cpuinit __smp_prepare_cpu(int cpu)
1026{ 1025{
1027 DECLARE_COMPLETION(done); 1026 DECLARE_COMPLETION(done);
1028 struct warm_boot_cpu_info info; 1027 struct warm_boot_cpu_info info;
1029 struct work_struct task; 1028 struct work_struct task;
1030 int apicid, ret; 1029 int apicid, ret;
1031 1030
1032 lock_cpu_hotplug();
1033
1034 /*
1035 * On x86, CPU0 is never offlined. Trying to bring up an
1036 * already-booted CPU will hang. So check for that case.
1037 */
1038 if (cpu_online(cpu)) {
1039 ret = -EINVAL;
1040 goto exit;
1041 }
1042
1043 apicid = x86_cpu_to_apicid[cpu]; 1031 apicid = x86_cpu_to_apicid[cpu];
1044 if (apicid == BAD_APICID) { 1032 if (apicid == BAD_APICID) {
1045 ret = -ENODEV; 1033 ret = -ENODEV;
@@ -1064,7 +1052,6 @@ int __devinit smp_prepare_cpu(int cpu)
1064 zap_low_mappings(); 1052 zap_low_mappings();
1065 ret = 0; 1053 ret = 0;
1066exit: 1054exit:
1067 unlock_cpu_hotplug();
1068 return ret; 1055 return ret;
1069} 1056}
1070#endif 1057#endif
@@ -1392,6 +1379,22 @@ void __cpu_die(unsigned int cpu)
1392 1379
1393int __devinit __cpu_up(unsigned int cpu) 1380int __devinit __cpu_up(unsigned int cpu)
1394{ 1381{
1382#ifdef CONFIG_HOTPLUG_CPU
1383 int ret=0;
1384
1385 /*
1386 * We do warm boot only on cpus that had booted earlier
1387 * Otherwise cold boot is all handled from smp_boot_cpus().
1388 * cpu_callin_map is set during AP kickstart process. Its reset
1389 * when a cpu is taken offline from cpu_exit_clear().
1390 */
1391 if (!cpu_isset(cpu, cpu_callin_map))
1392 ret = __smp_prepare_cpu(cpu);
1393
1394 if (ret)
1395 return -EIO;
1396#endif
1397
1395 /* In case one didn't come up */ 1398 /* In case one didn't come up */
1396 if (!cpu_isset(cpu, cpu_callin_map)) { 1399 if (!cpu_isset(cpu, cpu_callin_map)) {
1397 printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu); 1400 printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu);
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index 3f21c6f6466d..8831303a473f 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -7,6 +7,7 @@
7#include <asm-generic/vmlinux.lds.h> 7#include <asm-generic/vmlinux.lds.h>
8#include <asm/thread_info.h> 8#include <asm/thread_info.h>
9#include <asm/page.h> 9#include <asm/page.h>
10#include <asm/cache.h>
10 11
11OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 12OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
12OUTPUT_ARCH(i386) 13OUTPUT_ARCH(i386)
@@ -135,7 +136,7 @@ SECTIONS
135 __initramfs_start = .; 136 __initramfs_start = .;
136 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) } 137 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
137 __initramfs_end = .; 138 __initramfs_end = .;
138 . = ALIGN(32); 139 . = ALIGN(L1_CACHE_BYTES);
139 __per_cpu_start = .; 140 __per_cpu_start = .;
140 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) } 141 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
141 __per_cpu_end = .; 142 __per_cpu_end = .;
diff --git a/arch/i386/mach-visws/reboot.c b/arch/i386/mach-visws/reboot.c
index 5d73e042ed0a..99332abfad42 100644
--- a/arch/i386/mach-visws/reboot.c
+++ b/arch/i386/mach-visws/reboot.c
@@ -1,7 +1,6 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/smp.h> 2#include <linux/smp.h>
3#include <linux/delay.h> 3#include <linux/delay.h>
4#include <linux/platform.h>
5 4
6#include <asm/io.h> 5#include <asm/io.h>
7#include "piix4.h" 6#include "piix4.h"
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index ff7ae6b664e8..10b6b9e7716b 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -252,6 +252,15 @@ config NR_CPUS
252 than 64 will cause the use of a CPU mask array, causing a small 252 than 64 will cause the use of a CPU mask array, causing a small
253 performance hit. 253 performance hit.
254 254
255config IA64_NR_NODES
256 int "Maximum number of NODEs (256-1024)" if (IA64_SGI_SN2 || IA64_GENERIC)
257 range 256 1024
258 depends on IA64_SGI_SN2 || IA64_GENERIC
259 default "256"
260 help
261 This option specifies the maximum number of nodes in your SSI system.
262 If in doubt, use the default.
263
255config HOTPLUG_CPU 264config HOTPLUG_CPU
256 bool "Support for hot-pluggable CPUs (EXPERIMENTAL)" 265 bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
257 depends on SMP && EXPERIMENTAL 266 depends on SMP && EXPERIMENTAL
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index f722e1a25948..80ea7506fa1a 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# ia64/Makefile 2# ia64/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -62,7 +65,7 @@ drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/
62 65
63boot := arch/ia64/hp/sim/boot 66boot := arch/ia64/hp/sim/boot
64 67
65.PHONY: boot compressed check 68PHONY += boot compressed check
66 69
67all: compressed unwcheck 70all: compressed unwcheck
68 71
diff --git a/arch/ia64/configs/gensparse_defconfig b/arch/ia64/configs/gensparse_defconfig
index 744fd2f79f61..0d29aa2066b3 100644
--- a/arch/ia64/configs/gensparse_defconfig
+++ b/arch/ia64/configs/gensparse_defconfig
@@ -116,6 +116,7 @@ CONFIG_IOSAPIC=y
116CONFIG_FORCE_MAX_ZONEORDER=17 116CONFIG_FORCE_MAX_ZONEORDER=17
117CONFIG_SMP=y 117CONFIG_SMP=y
118CONFIG_NR_CPUS=512 118CONFIG_NR_CPUS=512
119CONFIG_IA64_NR_NODES=256
119CONFIG_HOTPLUG_CPU=y 120CONFIG_HOTPLUG_CPU=y
120# CONFIG_SCHED_SMT is not set 121# CONFIG_SCHED_SMT is not set
121# CONFIG_PREEMPT is not set 122# CONFIG_PREEMPT is not set
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index 8206752161bb..a718034d68d0 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -116,6 +116,7 @@ CONFIG_IA64_SGI_SN_XP=m
116CONFIG_FORCE_MAX_ZONEORDER=17 116CONFIG_FORCE_MAX_ZONEORDER=17
117CONFIG_SMP=y 117CONFIG_SMP=y
118CONFIG_NR_CPUS=1024 118CONFIG_NR_CPUS=1024
119CONFIG_IA64_NR_NODES=256
119# CONFIG_HOTPLUG_CPU is not set 120# CONFIG_HOTPLUG_CPU is not set
120CONFIG_SCHED_SMT=y 121CONFIG_SCHED_SMT=y
121CONFIG_PREEMPT=y 122CONFIG_PREEMPT=y
diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig
index 3e767288a745..6cba55da572a 100644
--- a/arch/ia64/defconfig
+++ b/arch/ia64/defconfig
@@ -116,6 +116,7 @@ CONFIG_IOSAPIC=y
116CONFIG_FORCE_MAX_ZONEORDER=17 116CONFIG_FORCE_MAX_ZONEORDER=17
117CONFIG_SMP=y 117CONFIG_SMP=y
118CONFIG_NR_CPUS=512 118CONFIG_NR_CPUS=512
119CONFIG_IA64_NR_NODES=256
119CONFIG_HOTPLUG_CPU=y 120CONFIG_HOTPLUG_CPU=y
120# CONFIG_SCHED_SMT is not set 121# CONFIG_SCHED_SMT is not set
121# CONFIG_PREEMPT is not set 122# CONFIG_PREEMPT is not set
diff --git a/arch/ia64/dig/setup.c b/arch/ia64/dig/setup.c
index c9104bfff667..38aa9c108857 100644
--- a/arch/ia64/dig/setup.c
+++ b/arch/ia64/dig/setup.c
@@ -69,8 +69,3 @@ dig_setup (char **cmdline_p)
69 screen_info.orig_video_isVGA = 1; /* XXX fake */ 69 screen_info.orig_video_isVGA = 1; /* XXX fake */
70 screen_info.orig_video_ega_bx = 3; /* XXX fake */ 70 screen_info.orig_video_ega_bx = 3; /* XXX fake */
71} 71}
72
73void __init
74dig_irq_init (void)
75{
76}
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 70dba1f0e2ee..13e739e4c84d 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)
1166asmlinkage unsigned long 1166asmlinkage unsigned long
1167sys32_alarm (unsigned int seconds) 1167sys32_alarm (unsigned int seconds)
1168{ 1168{
1169 struct itimerval it_new, it_old; 1169 return alarm_setitimer(seconds);
1170 unsigned int oldalarm;
1171
1172 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
1173 it_new.it_value.tv_sec = seconds;
1174 it_new.it_value.tv_usec = 0;
1175 do_setitimer(ITIMER_REAL, &it_new, &it_old);
1176 oldalarm = it_old.it_value.tv_sec;
1177 /* ehhh.. We can't return 0 if we have an alarm pending.. */
1178 /* And we'd better return too much than too little anyway */
1179 if (it_old.it_value.tv_usec)
1180 oldalarm++;
1181 return oldalarm;
1182} 1170}
1183 1171
1184/* Translations due to time_t size differences. Which affects all 1172/* Translations due to time_t size differences. Which affects all
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 4722ec51c70c..a4e218ce2edb 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -420,6 +420,26 @@ int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS];
420int __initdata nid_to_pxm_map[MAX_NUMNODES]; 420int __initdata nid_to_pxm_map[MAX_NUMNODES];
421static struct acpi_table_slit __initdata *slit_table; 421static struct acpi_table_slit __initdata *slit_table;
422 422
423static int get_processor_proximity_domain(struct acpi_table_processor_affinity *pa)
424{
425 int pxm;
426
427 pxm = pa->proximity_domain;
428 if (ia64_platform_is("sn2"))
429 pxm += pa->reserved[0] << 8;
430 return pxm;
431}
432
433static int get_memory_proximity_domain(struct acpi_table_memory_affinity *ma)
434{
435 int pxm;
436
437 pxm = ma->proximity_domain;
438 if (ia64_platform_is("sn2"))
439 pxm += ma->reserved1[0] << 8;
440 return pxm;
441}
442
423/* 443/*
424 * ACPI 2.0 SLIT (System Locality Information Table) 444 * ACPI 2.0 SLIT (System Locality Information Table)
425 * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf 445 * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf
@@ -443,13 +463,20 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
443void __init 463void __init
444acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa) 464acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
445{ 465{
466 int pxm;
467
468 if (!pa->flags.enabled)
469 return;
470
471 pxm = get_processor_proximity_domain(pa);
472
446 /* record this node in proximity bitmap */ 473 /* record this node in proximity bitmap */
447 pxm_bit_set(pa->proximity_domain); 474 pxm_bit_set(pxm);
448 475
449 node_cpuid[srat_num_cpus].phys_id = 476 node_cpuid[srat_num_cpus].phys_id =
450 (pa->apic_id << 8) | (pa->lsapic_eid); 477 (pa->apic_id << 8) | (pa->lsapic_eid);
451 /* nid should be overridden as logical node id later */ 478 /* nid should be overridden as logical node id later */
452 node_cpuid[srat_num_cpus].nid = pa->proximity_domain; 479 node_cpuid[srat_num_cpus].nid = pxm;
453 srat_num_cpus++; 480 srat_num_cpus++;
454} 481}
455 482
@@ -457,10 +484,10 @@ void __init
457acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma) 484acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
458{ 485{
459 unsigned long paddr, size; 486 unsigned long paddr, size;
460 u8 pxm; 487 int pxm;
461 struct node_memblk_s *p, *q, *pend; 488 struct node_memblk_s *p, *q, *pend;
462 489
463 pxm = ma->proximity_domain; 490 pxm = get_memory_proximity_domain(ma);
464 491
465 /* fill node memory chunk structure */ 492 /* fill node memory chunk structure */
466 paddr = ma->base_addr_hi; 493 paddr = ma->base_addr_hi;
diff --git a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
index dcd906fe5749..829a43cab797 100644
--- a/arch/ia64/kernel/ivt.S
+++ b/arch/ia64/kernel/ivt.S
@@ -865,6 +865,7 @@ ENTRY(interrupt)
865 ;; 865 ;;
866 SAVE_REST 866 SAVE_REST
867 ;; 867 ;;
868 MCA_RECOVER_RANGE(interrupt)
868 alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group 869 alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group
869 mov out0=cr.ivr // pass cr.ivr as first arg 870 mov out0=cr.ivr // pass cr.ivr as first arg
870 add out1=16,sp // pass pointer to pt_regs as second arg 871 add out1=16,sp // pass pointer to pt_regs as second arg
diff --git a/arch/ia64/kernel/machvec.c b/arch/ia64/kernel/machvec.c
index c3a04ee7f4f6..4b0b71d5aef4 100644
--- a/arch/ia64/kernel/machvec.c
+++ b/arch/ia64/kernel/machvec.c
@@ -14,7 +14,15 @@
14struct ia64_machine_vector ia64_mv; 14struct ia64_machine_vector ia64_mv;
15EXPORT_SYMBOL(ia64_mv); 15EXPORT_SYMBOL(ia64_mv);
16 16
17static struct ia64_machine_vector * 17static __initdata const char *mvec_name;
18static __init int setup_mvec(char *s)
19{
20 mvec_name = s;
21 return 0;
22}
23early_param("machvec", setup_mvec);
24
25static struct ia64_machine_vector * __init
18lookup_machvec (const char *name) 26lookup_machvec (const char *name)
19{ 27{
20 extern struct ia64_machine_vector machvec_start[]; 28 extern struct ia64_machine_vector machvec_start[];
@@ -33,10 +41,13 @@ machvec_init (const char *name)
33{ 41{
34 struct ia64_machine_vector *mv; 42 struct ia64_machine_vector *mv;
35 43
44 if (!name)
45 name = mvec_name ? mvec_name : acpi_get_sysname();
36 mv = lookup_machvec(name); 46 mv = lookup_machvec(name);
37 if (!mv) { 47 if (!mv)
38 panic("generic kernel failed to find machine vector for platform %s!", name); 48 panic("generic kernel failed to find machine vector for"
39 } 49 " platform %s!", name);
50
40 ia64_mv = *mv; 51 ia64_mv = *mv;
41 printk(KERN_INFO "booting generic kernel on platform %s\n", name); 52 printk(KERN_INFO "booting generic kernel on platform %s\n", name);
42} 53}
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index b57e723f194c..87ff7fe33cfb 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -83,6 +83,7 @@
83#include <asm/irq.h> 83#include <asm/irq.h>
84#include <asm/hw_irq.h> 84#include <asm/hw_irq.h>
85 85
86#include "mca_drv.h"
86#include "entry.h" 87#include "entry.h"
87 88
88#if defined(IA64_MCA_DEBUG_INFO) 89#if defined(IA64_MCA_DEBUG_INFO)
@@ -133,7 +134,7 @@ static int cpe_poll_enabled = 1;
133 134
134extern void salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe); 135extern void salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe);
135 136
136static int mca_init; 137static int mca_init __initdata;
137 138
138 139
139static void inline 140static void inline
@@ -184,7 +185,7 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
184 * Inputs : info_type (SAL_INFO_TYPE_{MCA,INIT,CMC,CPE}) 185 * Inputs : info_type (SAL_INFO_TYPE_{MCA,INIT,CMC,CPE})
185 * Outputs : None 186 * Outputs : None
186 */ 187 */
187static void 188static void __init
188ia64_log_init(int sal_info_type) 189ia64_log_init(int sal_info_type)
189{ 190{
190 u64 max_size = 0; 191 u64 max_size = 0;
@@ -281,6 +282,50 @@ ia64_mca_log_sal_error_record(int sal_info_type)
281 ia64_sal_clear_state_info(sal_info_type); 282 ia64_sal_clear_state_info(sal_info_type);
282} 283}
283 284
285/*
286 * search_mca_table
287 * See if the MCA surfaced in an instruction range
288 * that has been tagged as recoverable.
289 *
290 * Inputs
291 * first First address range to check
292 * last Last address range to check
293 * ip Instruction pointer, address we are looking for
294 *
295 * Return value:
296 * 1 on Success (in the table)/ 0 on Failure (not in the table)
297 */
298int
299search_mca_table (const struct mca_table_entry *first,
300 const struct mca_table_entry *last,
301 unsigned long ip)
302{
303 const struct mca_table_entry *curr;
304 u64 curr_start, curr_end;
305
306 curr = first;
307 while (curr <= last) {
308 curr_start = (u64) &curr->start_addr + curr->start_addr;
309 curr_end = (u64) &curr->end_addr + curr->end_addr;
310
311 if ((ip >= curr_start) && (ip <= curr_end)) {
312 return 1;
313 }
314 curr++;
315 }
316 return 0;
317}
318
319/* Given an address, look for it in the mca tables. */
320int mca_recover_range(unsigned long addr)
321{
322 extern struct mca_table_entry __start___mca_table[];
323 extern struct mca_table_entry __stop___mca_table[];
324
325 return search_mca_table(__start___mca_table, __stop___mca_table-1, addr);
326}
327EXPORT_SYMBOL_GPL(mca_recover_range);
328
284#ifdef CONFIG_ACPI 329#ifdef CONFIG_ACPI
285 330
286int cpe_vector = -1; 331int cpe_vector = -1;
@@ -355,7 +400,7 @@ ia64_mca_cpe_int_handler (int cpe_irq, void *arg, struct pt_regs *ptregs)
355 * Outputs 400 * Outputs
356 * None 401 * None
357 */ 402 */
358static void 403static void __init
359ia64_mca_register_cpev (int cpev) 404ia64_mca_register_cpev (int cpev)
360{ 405{
361 /* Register the CPE interrupt vector with SAL */ 406 /* Register the CPE interrupt vector with SAL */
@@ -386,7 +431,7 @@ ia64_mca_register_cpev (int cpev)
386 * Outputs 431 * Outputs
387 * None 432 * None
388 */ 433 */
389void 434void __cpuinit
390ia64_mca_cmc_vector_setup (void) 435ia64_mca_cmc_vector_setup (void)
391{ 436{
392 cmcv_reg_t cmcv; 437 cmcv_reg_t cmcv;
@@ -747,31 +792,34 @@ ia64_mca_modify_original_stack(struct pt_regs *regs,
747 ia64_mca_modify_comm(previous_current); 792 ia64_mca_modify_comm(previous_current);
748 goto no_mod; 793 goto no_mod;
749 } 794 }
750 if (r13 != sos->prev_IA64_KR_CURRENT) { 795
751 msg = "inconsistent previous current and r13"; 796 if (!mca_recover_range(ms->pmsa_iip)) {
752 goto no_mod; 797 if (r13 != sos->prev_IA64_KR_CURRENT) {
753 } 798 msg = "inconsistent previous current and r13";
754 if ((r12 - r13) >= KERNEL_STACK_SIZE) { 799 goto no_mod;
755 msg = "inconsistent r12 and r13"; 800 }
756 goto no_mod; 801 if ((r12 - r13) >= KERNEL_STACK_SIZE) {
757 } 802 msg = "inconsistent r12 and r13";
758 if ((ar_bspstore - r13) >= KERNEL_STACK_SIZE) { 803 goto no_mod;
759 msg = "inconsistent ar.bspstore and r13"; 804 }
760 goto no_mod; 805 if ((ar_bspstore - r13) >= KERNEL_STACK_SIZE) {
761 } 806 msg = "inconsistent ar.bspstore and r13";
762 va.p = old_bspstore; 807 goto no_mod;
763 if (va.f.reg < 5) { 808 }
764 msg = "old_bspstore is in the wrong region"; 809 va.p = old_bspstore;
765 goto no_mod; 810 if (va.f.reg < 5) {
766 } 811 msg = "old_bspstore is in the wrong region";
767 if ((ar_bsp - r13) >= KERNEL_STACK_SIZE) { 812 goto no_mod;
768 msg = "inconsistent ar.bsp and r13"; 813 }
769 goto no_mod; 814 if ((ar_bsp - r13) >= KERNEL_STACK_SIZE) {
770 } 815 msg = "inconsistent ar.bsp and r13";
771 size += (ia64_rse_skip_regs(old_bspstore, slots) - old_bspstore) * 8; 816 goto no_mod;
772 if (ar_bspstore + size > r12) { 817 }
773 msg = "no room for blocked state"; 818 size += (ia64_rse_skip_regs(old_bspstore, slots) - old_bspstore) * 8;
774 goto no_mod; 819 if (ar_bspstore + size > r12) {
820 msg = "no room for blocked state";
821 goto no_mod;
822 }
775 } 823 }
776 824
777 ia64_mca_modify_comm(previous_current); 825 ia64_mca_modify_comm(previous_current);
@@ -1443,7 +1491,7 @@ static struct irqaction mca_cpep_irqaction = {
1443 * format most of the fields. 1491 * format most of the fields.
1444 */ 1492 */
1445 1493
1446static void 1494static void __cpuinit
1447format_mca_init_stack(void *mca_data, unsigned long offset, 1495format_mca_init_stack(void *mca_data, unsigned long offset,
1448 const char *type, int cpu) 1496 const char *type, int cpu)
1449{ 1497{
@@ -1467,7 +1515,7 @@ format_mca_init_stack(void *mca_data, unsigned long offset,
1467 1515
1468/* Do per-CPU MCA-related initialization. */ 1516/* Do per-CPU MCA-related initialization. */
1469 1517
1470void __devinit 1518void __cpuinit
1471ia64_mca_cpu_init(void *cpu_data) 1519ia64_mca_cpu_init(void *cpu_data)
1472{ 1520{
1473 void *pal_vaddr; 1521 void *pal_vaddr;
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index e883d85906db..37c88eb55873 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -6,6 +6,7 @@
6 * Copyright (C) Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com) 6 * Copyright (C) Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com)
7 * Copyright (C) 2005 Silicon Graphics, Inc 7 * Copyright (C) 2005 Silicon Graphics, Inc
8 * Copyright (C) 2005 Keith Owens <kaos@sgi.com> 8 * Copyright (C) 2005 Keith Owens <kaos@sgi.com>
9 * Copyright (C) 2006 Russ Anderson <rja@sgi.com>
9 */ 10 */
10#include <linux/config.h> 11#include <linux/config.h>
11#include <linux/types.h> 12#include <linux/types.h>
@@ -121,11 +122,12 @@ mca_page_isolate(unsigned long paddr)
121 */ 122 */
122 123
123void 124void
124mca_handler_bh(unsigned long paddr) 125mca_handler_bh(unsigned long paddr, void *iip, unsigned long ipsr)
125{ 126{
126 printk(KERN_ERR 127 printk(KERN_ERR "OS_MCA: process [cpu %d, pid: %d, uid: %d, "
127 "OS_MCA: process [pid: %d](%s) encounters MCA (paddr=%lx)\n", 128 "iip: %p, psr: 0x%lx,paddr: 0x%lx](%s) encounters MCA.\n",
128 current->pid, current->comm, paddr); 129 raw_smp_processor_id(), current->pid, current->uid,
130 iip, ipsr, paddr, current->comm);
129 131
130 spin_lock(&mca_bh_lock); 132 spin_lock(&mca_bh_lock);
131 switch (mca_page_isolate(paddr)) { 133 switch (mca_page_isolate(paddr)) {
@@ -442,21 +444,26 @@ recover_from_read_error(slidx_table_t *slidx,
442 if (!peidx_bottom(peidx) || !(peidx_bottom(peidx)->valid.minstate)) 444 if (!peidx_bottom(peidx) || !(peidx_bottom(peidx)->valid.minstate))
443 return 0; 445 return 0;
444 psr1 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_ipsr); 446 psr1 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_ipsr);
447 psr2 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_xpsr);
445 448
446 /* 449 /*
447 * Check the privilege level of interrupted context. 450 * Check the privilege level of interrupted context.
448 * If it is user-mode, then terminate affected process. 451 * If it is user-mode, then terminate affected process.
449 */ 452 */
450 if (psr1->cpl != 0) { 453
454 pmsa = sos->pal_min_state;
455 if (psr1->cpl != 0 ||
456 ((psr2->cpl != 0) && mca_recover_range(pmsa->pmsa_iip))) {
451 smei = peidx_bus_check(peidx, 0); 457 smei = peidx_bus_check(peidx, 0);
452 if (smei->valid.target_identifier) { 458 if (smei->valid.target_identifier) {
453 /* 459 /*
454 * setup for resume to bottom half of MCA, 460 * setup for resume to bottom half of MCA,
455 * "mca_handler_bhhook" 461 * "mca_handler_bhhook"
456 */ 462 */
457 pmsa = sos->pal_min_state; 463 /* pass to bhhook as argument (gr8, ...) */
458 /* pass to bhhook as 1st argument (gr8) */
459 pmsa->pmsa_gr[8-1] = smei->target_identifier; 464 pmsa->pmsa_gr[8-1] = smei->target_identifier;
465 pmsa->pmsa_gr[9-1] = pmsa->pmsa_iip;
466 pmsa->pmsa_gr[10-1] = pmsa->pmsa_ipsr;
460 /* set interrupted return address (but no use) */ 467 /* set interrupted return address (but no use) */
461 pmsa->pmsa_br0 = pmsa->pmsa_iip; 468 pmsa->pmsa_br0 = pmsa->pmsa_iip;
462 /* change resume address to bottom half */ 469 /* change resume address to bottom half */
@@ -466,6 +473,7 @@ recover_from_read_error(slidx_table_t *slidx,
466 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr; 473 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr;
467 psr2->cpl = 0; 474 psr2->cpl = 0;
468 psr2->ri = 0; 475 psr2->ri = 0;
476 psr2->bn = 1;
469 psr2->i = 0; 477 psr2->i = 0;
470 478
471 return 1; 479 return 1;
diff --git a/arch/ia64/kernel/mca_drv.h b/arch/ia64/kernel/mca_drv.h
index e2f6fa1e0ef6..31a2e52bb16f 100644
--- a/arch/ia64/kernel/mca_drv.h
+++ b/arch/ia64/kernel/mca_drv.h
@@ -111,3 +111,10 @@ typedef struct slidx_table {
111 slidx_foreach_entry(__pos, &((slidx)->sec)) { __count++; }\ 111 slidx_foreach_entry(__pos, &((slidx)->sec)) { __count++; }\
112 __count; }) 112 __count; })
113 113
114struct mca_table_entry {
115 int start_addr; /* location-relative starting address of MCA recoverable range */
116 int end_addr; /* location-relative ending address of MCA recoverable range */
117};
118
119extern const struct mca_table_entry *search_mca_tables (unsigned long addr);
120extern int mca_recover_range(unsigned long);
diff --git a/arch/ia64/kernel/mca_drv_asm.S b/arch/ia64/kernel/mca_drv_asm.S
index 3f298ee4d00c..e6a580d354b9 100644
--- a/arch/ia64/kernel/mca_drv_asm.S
+++ b/arch/ia64/kernel/mca_drv_asm.S
@@ -14,15 +14,12 @@
14 14
15GLOBAL_ENTRY(mca_handler_bhhook) 15GLOBAL_ENTRY(mca_handler_bhhook)
16 invala // clear RSE ? 16 invala // clear RSE ?
17 ;;
18 cover 17 cover
19 ;; 18 ;;
20 clrrrb 19 clrrrb
21 ;; 20 ;;
22 alloc r16=ar.pfs,0,2,1,0 // make a new frame 21 alloc r16=ar.pfs,0,2,3,0 // make a new frame
23 ;;
24 mov ar.rsc=0 22 mov ar.rsc=0
25 ;;
26 mov r13=IA64_KR(CURRENT) // current task pointer 23 mov r13=IA64_KR(CURRENT) // current task pointer
27 ;; 24 ;;
28 mov r2=r13 25 mov r2=r13
@@ -30,7 +27,6 @@ GLOBAL_ENTRY(mca_handler_bhhook)
30 addl r22=IA64_RBS_OFFSET,r2 27 addl r22=IA64_RBS_OFFSET,r2
31 ;; 28 ;;
32 mov ar.bspstore=r22 29 mov ar.bspstore=r22
33 ;;
34 addl sp=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r2 30 addl sp=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r2
35 ;; 31 ;;
36 adds r2=IA64_TASK_THREAD_ON_USTACK_OFFSET,r13 32 adds r2=IA64_TASK_THREAD_ON_USTACK_OFFSET,r13
@@ -40,12 +36,12 @@ GLOBAL_ENTRY(mca_handler_bhhook)
40 movl loc1=mca_handler_bh // recovery C function 36 movl loc1=mca_handler_bh // recovery C function
41 ;; 37 ;;
42 mov out0=r8 // poisoned address 38 mov out0=r8 // poisoned address
39 mov out1=r9 // iip
40 mov out2=r10 // psr
43 mov b6=loc1 41 mov b6=loc1
44 ;; 42 ;;
45 mov loc1=rp 43 mov loc1=rp
46 ;; 44 ssm psr.i | psr.ic
47 ssm psr.i
48 ;;
49 br.call.sptk.many rp=b6 // does not return ... 45 br.call.sptk.many rp=b6 // does not return ...
50 ;; 46 ;;
51 mov ar.pfs=loc0 47 mov ar.pfs=loc0
@@ -53,5 +49,4 @@ GLOBAL_ENTRY(mca_handler_bhhook)
53 ;; 49 ;;
54 mov r8=r0 50 mov r8=r0
55 br.ret.sptk.many rp 51 br.ret.sptk.many rp
56 ;;
57END(mca_handler_bhhook) 52END(mca_handler_bhhook)
diff --git a/arch/ia64/kernel/numa.c b/arch/ia64/kernel/numa.c
index a68ce6678092..0766493d4d00 100644
--- a/arch/ia64/kernel/numa.c
+++ b/arch/ia64/kernel/numa.c
@@ -25,7 +25,7 @@
25#include <asm/processor.h> 25#include <asm/processor.h>
26#include <asm/smp.h> 26#include <asm/smp.h>
27 27
28u8 cpu_to_node_map[NR_CPUS] __cacheline_aligned; 28u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
29EXPORT_SYMBOL(cpu_to_node_map); 29EXPORT_SYMBOL(cpu_to_node_map);
30 30
31cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned; 31cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
diff --git a/arch/ia64/kernel/patch.c b/arch/ia64/kernel/patch.c
index 6a4ac7d70b35..bc11bb096f58 100644
--- a/arch/ia64/kernel/patch.c
+++ b/arch/ia64/kernel/patch.c
@@ -115,7 +115,7 @@ ia64_patch_vtop (unsigned long start, unsigned long end)
115 ia64_srlz_i(); 115 ia64_srlz_i();
116} 116}
117 117
118void 118void __init
119ia64_patch_mckinley_e9 (unsigned long start, unsigned long end) 119ia64_patch_mckinley_e9 (unsigned long start, unsigned long end)
120{ 120{
121 static int first_time = 1; 121 static int first_time = 1;
@@ -149,7 +149,7 @@ ia64_patch_mckinley_e9 (unsigned long start, unsigned long end)
149 ia64_srlz_i(); 149 ia64_srlz_i();
150} 150}
151 151
152static void 152static void __init
153patch_fsyscall_table (unsigned long start, unsigned long end) 153patch_fsyscall_table (unsigned long start, unsigned long end)
154{ 154{
155 extern unsigned long fsyscall_table[NR_syscalls]; 155 extern unsigned long fsyscall_table[NR_syscalls];
@@ -166,7 +166,7 @@ patch_fsyscall_table (unsigned long start, unsigned long end)
166 ia64_srlz_i(); 166 ia64_srlz_i();
167} 167}
168 168
169static void 169static void __init
170patch_brl_fsys_bubble_down (unsigned long start, unsigned long end) 170patch_brl_fsys_bubble_down (unsigned long start, unsigned long end)
171{ 171{
172 extern char fsys_bubble_down[]; 172 extern char fsys_bubble_down[];
@@ -184,7 +184,7 @@ patch_brl_fsys_bubble_down (unsigned long start, unsigned long end)
184 ia64_srlz_i(); 184 ia64_srlz_i();
185} 185}
186 186
187void 187void __init
188ia64_patch_gate (void) 188ia64_patch_gate (void)
189{ 189{
190# define START(name) ((unsigned long) __start_gate_##name##_patchlist) 190# define START(name) ((unsigned long) __start_gate_##name##_patchlist)
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 3258e09278d0..eb388e271b2b 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -41,7 +41,6 @@
41#include <linux/serial_core.h> 41#include <linux/serial_core.h>
42#include <linux/efi.h> 42#include <linux/efi.h>
43#include <linux/initrd.h> 43#include <linux/initrd.h>
44#include <linux/platform.h>
45#include <linux/pm.h> 44#include <linux/pm.h>
46#include <linux/cpufreq.h> 45#include <linux/cpufreq.h>
47 46
@@ -131,8 +130,8 @@ EXPORT_SYMBOL(ia64_max_iommu_merge_mask);
131/* 130/*
132 * We use a special marker for the end of memory and it uses the extra (+1) slot 131 * We use a special marker for the end of memory and it uses the extra (+1) slot
133 */ 132 */
134struct rsvd_region rsvd_region[IA64_MAX_RSVD_REGIONS + 1]; 133struct rsvd_region rsvd_region[IA64_MAX_RSVD_REGIONS + 1] __initdata;
135int num_rsvd_regions; 134int num_rsvd_regions __initdata;
136 135
137 136
138/* 137/*
@@ -141,7 +140,7 @@ int num_rsvd_regions;
141 * caller-specified function is called with the memory ranges that remain after filtering. 140 * caller-specified function is called with the memory ranges that remain after filtering.
142 * This routine does not assume the incoming segments are sorted. 141 * This routine does not assume the incoming segments are sorted.
143 */ 142 */
144int 143int __init
145filter_rsvd_memory (unsigned long start, unsigned long end, void *arg) 144filter_rsvd_memory (unsigned long start, unsigned long end, void *arg)
146{ 145{
147 unsigned long range_start, range_end, prev_start; 146 unsigned long range_start, range_end, prev_start;
@@ -177,7 +176,7 @@ filter_rsvd_memory (unsigned long start, unsigned long end, void *arg)
177 return 0; 176 return 0;
178} 177}
179 178
180static void 179static void __init
181sort_regions (struct rsvd_region *rsvd_region, int max) 180sort_regions (struct rsvd_region *rsvd_region, int max)
182{ 181{
183 int j; 182 int j;
@@ -218,7 +217,7 @@ __initcall(register_memory);
218 * initrd, etc. There are currently %IA64_MAX_RSVD_REGIONS defined, 217 * initrd, etc. There are currently %IA64_MAX_RSVD_REGIONS defined,
219 * see include/asm-ia64/meminit.h if you need to define more. 218 * see include/asm-ia64/meminit.h if you need to define more.
220 */ 219 */
221void 220void __init
222reserve_memory (void) 221reserve_memory (void)
223{ 222{
224 int n = 0; 223 int n = 0;
@@ -270,7 +269,7 @@ reserve_memory (void)
270 * Grab the initrd start and end from the boot parameter struct given us by 269 * Grab the initrd start and end from the boot parameter struct given us by
271 * the boot loader. 270 * the boot loader.
272 */ 271 */
273void 272void __init
274find_initrd (void) 273find_initrd (void)
275{ 274{
276#ifdef CONFIG_BLK_DEV_INITRD 275#ifdef CONFIG_BLK_DEV_INITRD
@@ -362,7 +361,7 @@ mark_bsp_online (void)
362} 361}
363 362
364#ifdef CONFIG_SMP 363#ifdef CONFIG_SMP
365static void 364static void __init
366check_for_logical_procs (void) 365check_for_logical_procs (void)
367{ 366{
368 pal_logical_to_physical_t info; 367 pal_logical_to_physical_t info;
@@ -389,6 +388,14 @@ check_for_logical_procs (void)
389} 388}
390#endif 389#endif
391 390
391static __initdata int nomca;
392static __init int setup_nomca(char *s)
393{
394 nomca = 1;
395 return 0;
396}
397early_param("nomca", setup_nomca);
398
392void __init 399void __init
393setup_arch (char **cmdline_p) 400setup_arch (char **cmdline_p)
394{ 401{
@@ -402,35 +409,15 @@ setup_arch (char **cmdline_p)
402 efi_init(); 409 efi_init();
403 io_port_init(); 410 io_port_init();
404 411
412 parse_early_param();
413
405#ifdef CONFIG_IA64_GENERIC 414#ifdef CONFIG_IA64_GENERIC
406 { 415 machvec_init(NULL);
407 const char *mvec_name = strstr (*cmdline_p, "machvec=");
408 char str[64];
409
410 if (mvec_name) {
411 const char *end;
412 size_t len;
413
414 mvec_name += 8;
415 end = strchr (mvec_name, ' ');
416 if (end)
417 len = end - mvec_name;
418 else
419 len = strlen (mvec_name);
420 len = min(len, sizeof (str) - 1);
421 strncpy (str, mvec_name, len);
422 str[len] = '\0';
423 mvec_name = str;
424 } else
425 mvec_name = acpi_get_sysname();
426 machvec_init(mvec_name);
427 }
428#endif 416#endif
429 417
430 if (early_console_setup(*cmdline_p) == 0) 418 if (early_console_setup(*cmdline_p) == 0)
431 mark_bsp_online(); 419 mark_bsp_online();
432 420
433 parse_early_param();
434#ifdef CONFIG_ACPI 421#ifdef CONFIG_ACPI
435 /* Initialize the ACPI boot-time table parser */ 422 /* Initialize the ACPI boot-time table parser */
436 acpi_table_init(); 423 acpi_table_init();
@@ -493,7 +480,7 @@ setup_arch (char **cmdline_p)
493#endif 480#endif
494 481
495 /* enable IA-64 Machine Check Abort Handling unless disabled */ 482 /* enable IA-64 Machine Check Abort Handling unless disabled */
496 if (!strstr(saved_command_line, "nomca")) 483 if (!nomca)
497 ia64_mca_init(); 484 ia64_mca_init();
498 485
499 platform_setup(cmdline_p); 486 platform_setup(cmdline_p);
@@ -623,7 +610,7 @@ struct seq_operations cpuinfo_op = {
623 .show = show_cpuinfo 610 .show = show_cpuinfo
624}; 611};
625 612
626void 613static void __cpuinit
627identify_cpu (struct cpuinfo_ia64 *c) 614identify_cpu (struct cpuinfo_ia64 *c)
628{ 615{
629 union { 616 union {
@@ -700,7 +687,7 @@ setup_per_cpu_areas (void)
700 * In addition, the minimum of the i-cache stride sizes is calculated for 687 * In addition, the minimum of the i-cache stride sizes is calculated for
701 * "flush_icache_range()". 688 * "flush_icache_range()".
702 */ 689 */
703static void 690static void __cpuinit
704get_max_cacheline_size (void) 691get_max_cacheline_size (void)
705{ 692{
706 unsigned long line_size, max = 1; 693 unsigned long line_size, max = 1;
@@ -763,10 +750,10 @@ get_max_cacheline_size (void)
763 * cpu_init() initializes state that is per-CPU. This function acts 750 * cpu_init() initializes state that is per-CPU. This function acts
764 * as a 'CPU state barrier', nothing should get across. 751 * as a 'CPU state barrier', nothing should get across.
765 */ 752 */
766void 753void __cpuinit
767cpu_init (void) 754cpu_init (void)
768{ 755{
769 extern void __devinit ia64_mmu_init (void *); 756 extern void __cpuinit ia64_mmu_init (void *);
770 unsigned long num_phys_stacked; 757 unsigned long num_phys_stacked;
771 pal_vm_info_2_u_t vmi; 758 pal_vm_info_2_u_t vmi;
772 unsigned int max_ctx; 759 unsigned int max_ctx;
@@ -894,7 +881,7 @@ void sched_cacheflush(void)
894 ia64_sal_cache_flush(3); 881 ia64_sal_cache_flush(3);
895} 882}
896 883
897void 884void __init
898check_bugs (void) 885check_bugs (void)
899{ 886{
900 ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles, 887 ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index c4b633b36dab..44e9547878ac 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -624,32 +624,8 @@ void __devinit smp_prepare_boot_cpu(void)
624 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 624 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
625} 625}
626 626
627/*
628 * mt_info[] is a temporary store for all info returned by
629 * PAL_LOGICAL_TO_PHYSICAL, to be copied into cpuinfo_ia64 when the
630 * specific cpu comes.
631 */
632static struct {
633 __u32 socket_id;
634 __u16 core_id;
635 __u16 thread_id;
636 __u16 proc_fixed_addr;
637 __u8 valid;
638} mt_info[NR_CPUS] __devinitdata;
639
640#ifdef CONFIG_HOTPLUG_CPU 627#ifdef CONFIG_HOTPLUG_CPU
641static inline void 628static inline void
642remove_from_mtinfo(int cpu)
643{
644 int i;
645
646 for_each_cpu(i)
647 if (mt_info[i].valid && mt_info[i].socket_id ==
648 cpu_data(cpu)->socket_id)
649 mt_info[i].valid = 0;
650}
651
652static inline void
653clear_cpu_sibling_map(int cpu) 629clear_cpu_sibling_map(int cpu)
654{ 630{
655 int i; 631 int i;
@@ -678,12 +654,6 @@ remove_siblinginfo(int cpu)
678 654
679 /* remove it from all sibling map's */ 655 /* remove it from all sibling map's */
680 clear_cpu_sibling_map(cpu); 656 clear_cpu_sibling_map(cpu);
681
682 /* if this cpu is the last in the core group, remove all its info
683 * from mt_info structure
684 */
685 if (last)
686 remove_from_mtinfo(cpu);
687} 657}
688 658
689extern void fixup_irqs(void); 659extern void fixup_irqs(void);
@@ -878,40 +848,6 @@ init_smp_config(void)
878 ia64_sal_strerror(sal_ret)); 848 ia64_sal_strerror(sal_ret));
879} 849}
880 850
881static inline int __devinit
882check_for_mtinfo_index(void)
883{
884 int i;
885
886 for_each_cpu(i)
887 if (!mt_info[i].valid)
888 return i;
889
890 return -1;
891}
892
893/*
894 * Search the mt_info to find out if this socket's cid/tid information is
895 * cached or not. If the socket exists, fill in the core_id and thread_id
896 * in cpuinfo
897 */
898static int __devinit
899check_for_new_socket(__u16 logical_address, struct cpuinfo_ia64 *c)
900{
901 int i;
902 __u32 sid = c->socket_id;
903
904 for_each_cpu(i) {
905 if (mt_info[i].valid && mt_info[i].proc_fixed_addr == logical_address
906 && mt_info[i].socket_id == sid) {
907 c->core_id = mt_info[i].core_id;
908 c->thread_id = mt_info[i].thread_id;
909 return 1; /* not a new socket */
910 }
911 }
912 return 0;
913}
914
915/* 851/*
916 * identify_siblings(cpu) gets called from identify_cpu. This populates the 852 * identify_siblings(cpu) gets called from identify_cpu. This populates the
917 * information related to logical execution units in per_cpu_data structure. 853 * information related to logical execution units in per_cpu_data structure.
@@ -921,14 +857,12 @@ identify_siblings(struct cpuinfo_ia64 *c)
921{ 857{
922 s64 status; 858 s64 status;
923 u16 pltid; 859 u16 pltid;
924 u64 proc_fixed_addr;
925 int count, i;
926 pal_logical_to_physical_t info; 860 pal_logical_to_physical_t info;
927 861
928 if (smp_num_cpucores == 1 && smp_num_siblings == 1) 862 if (smp_num_cpucores == 1 && smp_num_siblings == 1)
929 return; 863 return;
930 864
931 if ((status = ia64_pal_logical_to_phys(0, &info)) != PAL_STATUS_SUCCESS) { 865 if ((status = ia64_pal_logical_to_phys(-1, &info)) != PAL_STATUS_SUCCESS) {
932 printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n", 866 printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n",
933 status); 867 status);
934 return; 868 return;
@@ -937,47 +871,12 @@ identify_siblings(struct cpuinfo_ia64 *c)
937 printk(KERN_ERR "ia64_sal_pltid failed with %ld\n", status); 871 printk(KERN_ERR "ia64_sal_pltid failed with %ld\n", status);
938 return; 872 return;
939 } 873 }
940 if ((status = ia64_pal_fixed_addr(&proc_fixed_addr)) != PAL_STATUS_SUCCESS) {
941 printk(KERN_ERR "ia64_pal_fixed_addr failed with %ld\n", status);
942 return;
943 }
944 874
945 c->socket_id = (pltid << 8) | info.overview_ppid; 875 c->socket_id = (pltid << 8) | info.overview_ppid;
946 c->cores_per_socket = info.overview_cpp; 876 c->cores_per_socket = info.overview_cpp;
947 c->threads_per_core = info.overview_tpc; 877 c->threads_per_core = info.overview_tpc;
948 count = c->num_log = info.overview_num_log; 878 c->num_log = info.overview_num_log;
949 879
950 /* If the thread and core id information is already cached, then 880 c->core_id = info.log1_cid;
951 * we will simply update cpu_info and return. Otherwise, we will 881 c->thread_id = info.log1_tid;
952 * do the PAL calls and cache core and thread id's of all the siblings.
953 */
954 if (check_for_new_socket(proc_fixed_addr, c))
955 return;
956
957 for (i = 0; i < count; i++) {
958 int index;
959
960 if (i && (status = ia64_pal_logical_to_phys(i, &info))
961 != PAL_STATUS_SUCCESS) {
962 printk(KERN_ERR "ia64_pal_logical_to_phys failed"
963 " with %ld\n", status);
964 return;
965 }
966 if (info.log2_la == proc_fixed_addr) {
967 c->core_id = info.log1_cid;
968 c->thread_id = info.log1_tid;
969 }
970
971 index = check_for_mtinfo_index();
972 /* We will not do the mt_info caching optimization in this case.
973 */
974 if (index < 0)
975 continue;
976
977 mt_info[index].valid = 1;
978 mt_info[index].socket_id = c->socket_id;
979 mt_info[index].core_id = info.log1_cid;
980 mt_info[index].thread_id = info.log1_tid;
981 mt_info[index].proc_fixed_addr = info.log2_la;
982 }
983} 882}
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 73af6267d2ef..0b9e56dd7f05 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -70,34 +70,9 @@ SECTIONS
70 __stop___ex_table = .; 70 __stop___ex_table = .;
71 } 71 }
72 72
73 .data.patch.vtop : AT(ADDR(.data.patch.vtop) - LOAD_OFFSET)
74 {
75 __start___vtop_patchlist = .;
76 *(.data.patch.vtop)
77 __end___vtop_patchlist = .;
78 }
79
80 .data.patch.mckinley_e9 : AT(ADDR(.data.patch.mckinley_e9) - LOAD_OFFSET)
81 {
82 __start___mckinley_e9_bundles = .;
83 *(.data.patch.mckinley_e9)
84 __end___mckinley_e9_bundles = .;
85 }
86
87 /* Global data */ 73 /* Global data */
88 _data = .; 74 _data = .;
89 75
90#if defined(CONFIG_IA64_GENERIC)
91 /* Machine Vector */
92 . = ALIGN(16);
93 .machvec : AT(ADDR(.machvec) - LOAD_OFFSET)
94 {
95 machvec_start = .;
96 *(.machvec)
97 machvec_end = .;
98 }
99#endif
100
101 /* Unwind info & table: */ 76 /* Unwind info & table: */
102 . = ALIGN(8); 77 . = ALIGN(8);
103 .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - LOAD_OFFSET) 78 .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - LOAD_OFFSET)
@@ -154,6 +129,41 @@ SECTIONS
154 *(.initcall7.init) 129 *(.initcall7.init)
155 __initcall_end = .; 130 __initcall_end = .;
156 } 131 }
132
133 /* MCA table */
134 . = ALIGN(16);
135 __mca_table : AT(ADDR(__mca_table) - LOAD_OFFSET)
136 {
137 __start___mca_table = .;
138 *(__mca_table)
139 __stop___mca_table = .;
140 }
141
142 .data.patch.vtop : AT(ADDR(.data.patch.vtop) - LOAD_OFFSET)
143 {
144 __start___vtop_patchlist = .;
145 *(.data.patch.vtop)
146 __end___vtop_patchlist = .;
147 }
148
149 .data.patch.mckinley_e9 : AT(ADDR(.data.patch.mckinley_e9) - LOAD_OFFSET)
150 {
151 __start___mckinley_e9_bundles = .;
152 *(.data.patch.mckinley_e9)
153 __end___mckinley_e9_bundles = .;
154 }
155
156#if defined(CONFIG_IA64_GENERIC)
157 /* Machine Vector */
158 . = ALIGN(16);
159 .machvec : AT(ADDR(.machvec) - LOAD_OFFSET)
160 {
161 machvec_start = .;
162 *(.machvec)
163 machvec_end = .;
164 }
165#endif
166
157 __con_initcall_start = .; 167 __con_initcall_start = .;
158 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) 168 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET)
159 { *(.con_initcall.init) } 169 { *(.con_initcall.init) }
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 9855ba318094..84fd1c14c8a9 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -97,7 +97,7 @@ find_max_pfn (unsigned long start, unsigned long end, void *arg)
97 * Find a place to put the bootmap and return its starting address in 97 * Find a place to put the bootmap and return its starting address in
98 * bootmap_start. This address must be page-aligned. 98 * bootmap_start. This address must be page-aligned.
99 */ 99 */
100int 100static int __init
101find_bootmap_location (unsigned long start, unsigned long end, void *arg) 101find_bootmap_location (unsigned long start, unsigned long end, void *arg)
102{ 102{
103 unsigned long needed = *(unsigned long *)arg; 103 unsigned long needed = *(unsigned long *)arg;
@@ -141,7 +141,7 @@ find_bootmap_location (unsigned long start, unsigned long end, void *arg)
141 * Walk the EFI memory map and find usable memory for the system, taking 141 * Walk the EFI memory map and find usable memory for the system, taking
142 * into account reserved areas. 142 * into account reserved areas.
143 */ 143 */
144void 144void __init
145find_memory (void) 145find_memory (void)
146{ 146{
147 unsigned long bootmap_size; 147 unsigned long bootmap_size;
@@ -176,7 +176,7 @@ find_memory (void)
176 * 176 *
177 * Allocate and setup per-cpu data areas. 177 * Allocate and setup per-cpu data areas.
178 */ 178 */
179void * 179void * __cpuinit
180per_cpu_init (void) 180per_cpu_init (void)
181{ 181{
182 void *cpu_data; 182 void *cpu_data;
@@ -228,7 +228,7 @@ count_dma_pages (u64 start, u64 end, void *arg)
228 * Set up the page tables. 228 * Set up the page tables.
229 */ 229 */
230 230
231void 231void __init
232paging_init (void) 232paging_init (void)
233{ 233{
234 unsigned long max_dma; 234 unsigned long max_dma;
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 573d5cc63e2b..2f5e44862e91 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -525,7 +525,7 @@ void __init find_memory(void)
525 * find_pernode_space() does most of this already, we just need to set 525 * find_pernode_space() does most of this already, we just need to set
526 * local_per_cpu_offset 526 * local_per_cpu_offset
527 */ 527 */
528void *per_cpu_init(void) 528void __cpuinit *per_cpu_init(void)
529{ 529{
530 int cpu; 530 int cpu;
531 static int first_time = 1; 531 static int first_time = 1;
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 9dbc7dadd165..8d506710fdbd 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -113,8 +113,7 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb,
113 unsigned long floor, unsigned long ceiling) 113 unsigned long floor, unsigned long ceiling)
114{ 114{
115 /* 115 /*
116 * This is called only when is_hugepage_only_range(addr,), 116 * This is called to free hugetlb page tables.
117 * and it follows that is_hugepage_only_range(end,) also.
118 * 117 *
119 * The offset of these addresses from the base of the hugetlb 118 * The offset of these addresses from the base of the hugetlb
120 * region must be scaled down by HPAGE_SIZE/PAGE_SIZE so that 119 * region must be scaled down by HPAGE_SIZE/PAGE_SIZE so that
@@ -126,9 +125,9 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb,
126 125
127 addr = htlbpage_to_page(addr); 126 addr = htlbpage_to_page(addr);
128 end = htlbpage_to_page(end); 127 end = htlbpage_to_page(end);
129 if (is_hugepage_only_range(tlb->mm, floor, HPAGE_SIZE)) 128 if (REGION_NUMBER(floor) == RGN_HPAGE)
130 floor = htlbpage_to_page(floor); 129 floor = htlbpage_to_page(floor);
131 if (is_hugepage_only_range(tlb->mm, ceiling, HPAGE_SIZE)) 130 if (REGION_NUMBER(ceiling) == RGN_HPAGE)
132 ceiling = htlbpage_to_page(ceiling); 131 ceiling = htlbpage_to_page(ceiling);
133 132
134 free_pgd_range(tlb, addr, end, floor, ceiling); 133 free_pgd_range(tlb, addr, end, floor, ceiling);
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 08d94e6bfa18..ff4f31fcd330 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -206,7 +206,7 @@ free_initmem (void)
206 (__init_end - __init_begin) >> 10); 206 (__init_end - __init_begin) >> 10);
207} 207}
208 208
209void 209void __init
210free_initrd_mem (unsigned long start, unsigned long end) 210free_initrd_mem (unsigned long start, unsigned long end)
211{ 211{
212 struct page *page; 212 struct page *page;
@@ -261,7 +261,7 @@ free_initrd_mem (unsigned long start, unsigned long end)
261/* 261/*
262 * This installs a clean page in the kernel's page table. 262 * This installs a clean page in the kernel's page table.
263 */ 263 */
264struct page * 264static struct page * __init
265put_kernel_page (struct page *page, unsigned long address, pgprot_t pgprot) 265put_kernel_page (struct page *page, unsigned long address, pgprot_t pgprot)
266{ 266{
267 pgd_t *pgd; 267 pgd_t *pgd;
@@ -294,7 +294,7 @@ put_kernel_page (struct page *page, unsigned long address, pgprot_t pgprot)
294 return page; 294 return page;
295} 295}
296 296
297static void 297static void __init
298setup_gate (void) 298setup_gate (void)
299{ 299{
300 struct page *page; 300 struct page *page;
@@ -411,7 +411,7 @@ ia64_mmu_init (void *my_cpu_data)
411 411
412#ifdef CONFIG_VIRTUAL_MEM_MAP 412#ifdef CONFIG_VIRTUAL_MEM_MAP
413 413
414int 414int __init
415create_mem_map_page_table (u64 start, u64 end, void *arg) 415create_mem_map_page_table (u64 start, u64 end, void *arg)
416{ 416{
417 unsigned long address, start_page, end_page; 417 unsigned long address, start_page, end_page;
@@ -519,7 +519,7 @@ ia64_pfn_valid (unsigned long pfn)
519} 519}
520EXPORT_SYMBOL(ia64_pfn_valid); 520EXPORT_SYMBOL(ia64_pfn_valid);
521 521
522int 522int __init
523find_largest_hole (u64 start, u64 end, void *arg) 523find_largest_hole (u64 start, u64 end, void *arg)
524{ 524{
525 u64 *max_gap = arg; 525 u64 *max_gap = arg;
@@ -535,7 +535,7 @@ find_largest_hole (u64 start, u64 end, void *arg)
535} 535}
536#endif /* CONFIG_VIRTUAL_MEM_MAP */ 536#endif /* CONFIG_VIRTUAL_MEM_MAP */
537 537
538static int 538static int __init
539count_reserved_pages (u64 start, u64 end, void *arg) 539count_reserved_pages (u64 start, u64 end, void *arg)
540{ 540{
541 unsigned long num_reserved = 0; 541 unsigned long num_reserved = 0;
@@ -556,7 +556,7 @@ count_reserved_pages (u64 start, u64 end, void *arg)
556 * purposes. 556 * purposes.
557 */ 557 */
558 558
559static int nolwsys; 559static int nolwsys __initdata;
560 560
561static int __init 561static int __init
562nolwsys_setup (char *s) 562nolwsys_setup (char *s)
@@ -567,7 +567,7 @@ nolwsys_setup (char *s)
567 567
568__setup("nolwsys", nolwsys_setup); 568__setup("nolwsys", nolwsys_setup);
569 569
570void 570void __init
571mem_init (void) 571mem_init (void)
572{ 572{
573 long reserved_pages, codesize, datasize, initsize; 573 long reserved_pages, codesize, datasize, initsize;
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index 1f11db470d90..e952ef4f6d91 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)
36 nodepda_t *tmp_nodepda; 36 nodepda_t *tmp_nodepda;
37 37
38 if (nasid_to_cnodeid(nasid) == -1) 38 if (nasid_to_cnodeid(nasid) == -1)
39 return (struct bteinfo_s *)NULL;; 39 return (struct bteinfo_s *)NULL;
40 40
41 tmp_nodepda = NODEPDA(nasid_to_cnodeid(nasid)); 41 tmp_nodepda = NODEPDA(nasid_to_cnodeid(nasid));
42 return &tmp_nodepda->bte_if[interface]; 42 return &tmp_nodepda->bte_if[interface];
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index dfb3f2902379..5101ac462643 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -13,6 +13,8 @@
13#include <asm/sn/sn_feature_sets.h> 13#include <asm/sn/sn_feature_sets.h>
14#include <asm/sn/geo.h> 14#include <asm/sn/geo.h>
15#include <asm/sn/io.h> 15#include <asm/sn/io.h>
16#include <asm/sn/l1.h>
17#include <asm/sn/module.h>
16#include <asm/sn/pcibr_provider.h> 18#include <asm/sn/pcibr_provider.h>
17#include <asm/sn/pcibus_provider_defs.h> 19#include <asm/sn/pcibus_provider_defs.h>
18#include <asm/sn/pcidev.h> 20#include <asm/sn/pcidev.h>
@@ -710,9 +712,36 @@ cnodeid_get_geoid(cnodeid_t cnode)
710 return hubdev->hdi_geoid; 712 return hubdev->hdi_geoid;
711} 713}
712 714
715void sn_generate_path(struct pci_bus *pci_bus, char *address)
716{
717 nasid_t nasid;
718 cnodeid_t cnode;
719 geoid_t geoid;
720 moduleid_t moduleid;
721 u16 bricktype;
722
723 nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
724 cnode = nasid_to_cnodeid(nasid);
725 geoid = cnodeid_get_geoid(cnode);
726 moduleid = geo_module(geoid);
727
728 sprintf(address, "module_%c%c%c%c%.2d",
729 '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
730 '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
731 '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
732 MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid));
733
734 /* Tollhouse requires slot id to be displayed */
735 bricktype = MODULE_GET_BTYPE(moduleid);
736 if ((bricktype == L1_BRICKTYPE_191010) ||
737 (bricktype == L1_BRICKTYPE_1932))
738 sprintf(address, "%s^%d", address, geo_slot(geoid));
739}
740
713subsys_initcall(sn_pci_init); 741subsys_initcall(sn_pci_init);
714EXPORT_SYMBOL(sn_pci_fixup_slot); 742EXPORT_SYMBOL(sn_pci_fixup_slot);
715EXPORT_SYMBOL(sn_pci_unfixup_slot); 743EXPORT_SYMBOL(sn_pci_unfixup_slot);
716EXPORT_SYMBOL(sn_pci_controller_fixup); 744EXPORT_SYMBOL(sn_pci_controller_fixup);
717EXPORT_SYMBOL(sn_bus_store_sysdata); 745EXPORT_SYMBOL(sn_bus_store_sysdata);
718EXPORT_SYMBOL(sn_bus_free_sysdata); 746EXPORT_SYMBOL(sn_bus_free_sysdata);
747EXPORT_SYMBOL(sn_generate_path);
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index c373113d073a..c265e02f5036 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -350,9 +350,6 @@ static void force_interrupt(int irq)
350static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info) 350static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
351{ 351{
352 u64 regval; 352 u64 regval;
353 int irr_reg_num;
354 int irr_bit;
355 u64 irr_reg;
356 struct pcidev_info *pcidev_info; 353 struct pcidev_info *pcidev_info;
357 struct pcibus_info *pcibus_info; 354 struct pcibus_info *pcibus_info;
358 355
@@ -373,23 +370,7 @@ static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
373 pdi_pcibus_info; 370 pdi_pcibus_info;
374 regval = pcireg_intr_status_get(pcibus_info); 371 regval = pcireg_intr_status_get(pcibus_info);
375 372
376 irr_reg_num = irq_to_vector(irq) / 64; 373 if (!ia64_get_irr(irq_to_vector(irq))) {
377 irr_bit = irq_to_vector(irq) % 64;
378 switch (irr_reg_num) {
379 case 0:
380 irr_reg = ia64_getreg(_IA64_REG_CR_IRR0);
381 break;
382 case 1:
383 irr_reg = ia64_getreg(_IA64_REG_CR_IRR1);
384 break;
385 case 2:
386 irr_reg = ia64_getreg(_IA64_REG_CR_IRR2);
387 break;
388 case 3:
389 irr_reg = ia64_getreg(_IA64_REG_CR_IRR3);
390 break;
391 }
392 if (!test_bit(irr_bit, &irr_reg)) {
393 if (!test_bit(irq, pda->sn_in_service_ivecs)) { 374 if (!test_bit(irq, pda->sn_in_service_ivecs)) {
394 regval &= 0xff; 375 regval &= 0xff;
395 if (sn_irq_info->irq_int_bit & regval & 376 if (sn_irq_info->irq_int_bit & regval &
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index 99cb28e74295..feaf1a6e8101 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -369,9 +369,15 @@ static void tio_corelet_reset(nasid_t nasid, int corelet)
369 369
370static int is_fpga_tio(int nasid, int *bt) 370static int is_fpga_tio(int nasid, int *bt)
371{ 371{
372 int ioboard_type; 372 u16 ioboard_type;
373 s64 rc;
373 374
374 ioboard_type = ia64_sn_sysctl_ioboard_get(nasid); 375 rc = ia64_sn_sysctl_ioboard_get(nasid, &ioboard_type);
376 if (rc) {
377 printk(KERN_WARNING "ia64_sn_sysctl_ioboard_get failed: %ld\n",
378 rc);
379 return 0;
380 }
375 381
376 switch (ioboard_type) { 382 switch (ioboard_type) {
377 case L1_BRICKTYPE_SA: 383 case L1_BRICKTYPE_SA:
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
index 98f716bd92f0..ab1211ef0176 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
@@ -74,6 +74,22 @@ static int sal_pcibr_error_interrupt(struct pcibus_info *soft)
74 return (int)ret_stuff.v0; 74 return (int)ret_stuff.v0;
75} 75}
76 76
77u16 sn_ioboard_to_pci_bus(struct pci_bus *pci_bus)
78{
79 s64 rc;
80 u16 ioboard;
81 nasid_t nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
82
83 rc = ia64_sn_sysctl_ioboard_get(nasid, &ioboard);
84 if (rc) {
85 printk(KERN_WARNING "ia64_sn_sysctl_ioboard_get failed: %ld\n",
86 rc);
87 return 0;
88 }
89
90 return ioboard;
91}
92
77/* 93/*
78 * PCI Bridge Error interrupt handler. Gets invoked whenever a PCI 94 * PCI Bridge Error interrupt handler. Gets invoked whenever a PCI
79 * bridge sends an error interrupt. 95 * bridge sends an error interrupt.
@@ -255,3 +271,4 @@ pcibr_init_provider(void)
255 271
256EXPORT_SYMBOL_GPL(sal_pcibr_slot_enable); 272EXPORT_SYMBOL_GPL(sal_pcibr_slot_enable);
257EXPORT_SYMBOL_GPL(sal_pcibr_slot_disable); 273EXPORT_SYMBOL_GPL(sal_pcibr_slot_disable);
274EXPORT_SYMBOL_GPL(sn_ioboard_to_pci_bus);
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index 7571a4025529..be0176912968 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)
377 struct tioca_dmamap *ca_dmamap; 377 struct tioca_dmamap *ca_dmamap;
378 void *map; 378 void *map;
379 unsigned long flags; 379 unsigned long flags;
380 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);; 380 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);
381 381
382 tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info; 382 tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info;
383 tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private; 383 tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private;
diff --git a/arch/m32r/Kconfig.debug b/arch/m32r/Kconfig.debug
index bbf711bab69e..2e1019ddbb22 100644
--- a/arch/m32r/Kconfig.debug
+++ b/arch/m32r/Kconfig.debug
@@ -19,7 +19,7 @@ config DEBUG_STACK_USAGE
19 This option will slow down process creation somewhat. 19 This option will slow down process creation somewhat.
20 20
21config DEBUG_PAGEALLOC 21config DEBUG_PAGEALLOC
22 bool "Page alloc debugging" 22 bool "Debug page memory allocations"
23 depends on DEBUG_KERNEL && BROKEN 23 depends on DEBUG_KERNEL && BROKEN
24 help 24 help
25 Unmap pages from the kernel linear mapping after free_pages(). 25 Unmap pages from the kernel linear mapping after free_pages().
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 4b3c90ba926c..f219c47d334f 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# m32r/Makefile 2# m32r/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4 7
5LDFLAGS := 8LDFLAGS :=
6OBJCOPYFLAGS := -O binary -R .note -R .comment -S 9OBJCOPYFLAGS := -O binary -R .note -R .comment -S
@@ -39,7 +42,7 @@ drivers-$(CONFIG_OPROFILE) += arch/m32r/oprofile/
39 42
40boot := arch/m32r/boot 43boot := arch/m32r/boot
41 44
42.PHONY: zImage 45PHONY += zImage
43 46
44all: zImage 47all: zImage
45 48
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 2d8ad0727b6b..33648efb772e 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)
77/* 77/*
78 * The idle loop on an m68k.. 78 * The idle loop on an m68k..
79 */ 79 */
80void default_idle(void) 80static void default_idle(void)
81{ 81{
82 if (!need_resched()) 82 if (!need_resched())
83#if defined(MACH_ATARI_ONLY) && !defined(CONFIG_HADES) 83#if defined(MACH_ATARI_ONLY) && !defined(CONFIG_HADES)
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 63c117dae0c3..f861755ec88b 100644
--- a/arch/m68knommu/kernel/process.c
+++ b/arch/m68knommu/kernel/process.c
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(pm_power_off);
51/* 51/*
52 * The idle loop on an m68knommu.. 52 * The idle loop on an m68knommu..
53 */ 53 */
54void default_idle(void) 54static void default_idle(void)
55{ 55{
56 local_irq_disable(); 56 local_irq_disable();
57 while (!need_resched()) { 57 while (!need_resched()) {
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
index 0fc3730a294f..5407b784cd01 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)
645 645
646asmlinkage unsigned int irix_alarm(unsigned int seconds) 646asmlinkage unsigned int irix_alarm(unsigned int seconds)
647{ 647{
648 struct itimerval it_new, it_old; 648 return alarm_setitimer(seconds);
649 unsigned int oldalarm;
650
651 if (!seconds) {
652 getitimer_real(&it_old);
653 del_timer(&current->real_timer);
654 } else {
655 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
656 it_new.it_value.tv_sec = seconds;
657 it_new.it_value.tv_usec = 0;
658 do_setitimer(ITIMER_REAL, &it_new, &it_old);
659 }
660 oldalarm = it_old.it_value.tv_sec;
661 /*
662 * ehhh.. We can't return 0 if we have an alarm pending ...
663 * And we'd better return too much than too little anyway
664 */
665 if (it_old.it_value.tv_usec)
666 oldalarm++;
667
668 return oldalarm;
669} 649}
670 650
671asmlinkage int irix_pause(void) 651asmlinkage int irix_pause(void)
diff --git a/arch/mips/mm/dma-ip32.c b/arch/mips/mm/dma-ip32.c
index a7e3072ff78d..ec54ed0d26ff 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,
138 BUG(); 138 BUG();
139 } 139 }
140 140
141 addr = virt_to_phys(ptr)&RAM_OFFSET_MASK;; 141 addr = virt_to_phys(ptr)&RAM_OFFSET_MASK;
142 if(dev == NULL) 142 if(dev == NULL)
143 addr+=CRIME_HI_MEM_BASE; 143 addr+=CRIME_HI_MEM_BASE;
144 return (dma_addr_t)addr; 144 return (dma_addr_t)addr;
@@ -179,7 +179,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
179 addr = (unsigned long) page_address(sg->page)+sg->offset; 179 addr = (unsigned long) page_address(sg->page)+sg->offset;
180 if (addr) 180 if (addr)
181 __dma_sync(addr, sg->length, direction); 181 __dma_sync(addr, sg->length, direction);
182 addr = __pa(addr)&RAM_OFFSET_MASK;; 182 addr = __pa(addr)&RAM_OFFSET_MASK;
183 if(dev == NULL) 183 if(dev == NULL)
184 addr += CRIME_HI_MEM_BASE; 184 addr += CRIME_HI_MEM_BASE;
185 sg->dma_address = (dma_addr_t)addr; 185 sg->dma_address = (dma_addr_t)addr;
@@ -199,7 +199,7 @@ dma_addr_t dma_map_page(struct device *dev, struct page *page,
199 199
200 addr = (unsigned long) page_address(page) + offset; 200 addr = (unsigned long) page_address(page) + offset;
201 dma_cache_wback_inv(addr, size); 201 dma_cache_wback_inv(addr, size);
202 addr = __pa(addr)&RAM_OFFSET_MASK;; 202 addr = __pa(addr)&RAM_OFFSET_MASK;
203 if(dev == NULL) 203 if(dev == NULL)
204 addr += CRIME_HI_MEM_BASE; 204 addr += CRIME_HI_MEM_BASE;
205 205
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index e8dea4177113..0b485ef4be89 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -54,11 +54,6 @@
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/unwind.h> 55#include <asm/unwind.h>
56 56
57void default_idle(void)
58{
59 barrier();
60}
61
62/* 57/*
63 * The idle thread. There's no useful work to be 58 * The idle thread. There's no useful work to be
64 * done, so just try to conserve power and have a 59 * done, so just try to conserve power and have a
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a3fc7a23158f..829e017b8a54 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -150,7 +150,7 @@ CPPFLAGS_vmlinux.lds := -Upowerpc
150 150
151BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin 151BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin
152 152
153.PHONY: $(BOOT_TARGETS) 153PHONY += $(BOOT_TARGETS)
154 154
155boot := arch/$(ARCH)/boot 155boot := arch/$(ARCH)/boot
156 156
diff --git a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
index 49eb2a7e65c0..a892356d5c3b 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;
126*/ 126*/
127static volatile cbd_t *rx_base, *rx_cur, *tx_base, *tx_cur; 127static volatile cbd_t *rx_base, *rx_cur, *tx_base, *tx_cur;
128 128
129MODULE_PARM(catchRadius, "i"); 129module_param(catchRadius, int, 0);
130MODULE_PARM(numBufs, "i"); 130module_param(numBufs, int, 0);
131MODULE_PARM(bufSize, "i"); 131module_param(bufSize, int, 0);
132MODULE_PARM(numreadBufs, "i"); 132module_param(numreadBufs, int, 0);
133MODULE_PARM(readbufSize, "i"); 133module_param(readbufSize, int, 0);
134 134
135#define arraysize(x) (sizeof(x)/sizeof(*(x))) 135#define arraysize(x) (sizeof(x)/sizeof(*(x)))
136#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff)) 136#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 98e940beeb3b..9fbdf54ba2be 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -82,7 +82,7 @@ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
82 82
83BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm 83BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm
84 84
85.PHONY: $(BOOT_TARGETS) 85PHONY += $(BOOT_TARGETS)
86 86
87all: uImage zImage 87all: uImage zImage
88 88
diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile
index f565699a9fe0..84eec0bef93c 100644
--- a/arch/ppc/boot/Makefile
+++ b/arch/ppc/boot/Makefile
@@ -1,3 +1,9 @@
1#
2# arch/ppc/boot/Makefile
3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
1# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
2# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
3# for more details. 9# for more details.
@@ -22,7 +28,7 @@ subdir- += simple openfirmware
22 28
23hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) 29hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
24 30
25.PHONY: $(BOOT_TARGETS) $(bootdir-y) 31PHONY += $(BOOT_TARGETS) $(bootdir-y)
26 32
27$(BOOT_TARGETS): $(bootdir-y) 33$(BOOT_TARGETS): $(bootdir-y)
28 34
diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
index 2a411ec2e650..66b739743759 100644
--- a/arch/ppc/boot/openfirmware/Makefile
+++ b/arch/ppc/boot/openfirmware/Makefile
@@ -1,5 +1,8 @@
1# Makefile for making bootable images on various OpenFirmware machines. 1# Makefile for making bootable images on various OpenFirmware machines.
2# 2#
3# This file is included by the global makefile so that you can add your own
4# architecture-specific flags and dependencies.
5#
3# Paul Mackerras January 1997 6# Paul Mackerras January 1997
4# XCOFF bootable images for PowerMacs 7# XCOFF bootable images for PowerMacs
5# Geert Uytterhoeven September 1997 8# Geert Uytterhoeven September 1997
@@ -86,7 +89,7 @@ $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
86 89
87# The targets used on the make command-line 90# The targets used on the make command-line
88 91
89.PHONY: zImage zImage.initrd 92PHONY += zImage zImage.initrd
90zImage: $(images)/zImage.chrp \ 93zImage: $(images)/zImage.chrp \
91 $(images)/zImage.chrp-rs6k 94 $(images)/zImage.chrp-rs6k
92 @echo ' kernel: $@ is ready ($<)' 95 @echo ' kernel: $@ is ready ($<)'
@@ -96,7 +99,7 @@ zImage.initrd: $(images)/zImage.initrd.chrp \
96 99
97TFTPIMAGE := /tftpboot/zImage 100TFTPIMAGE := /tftpboot/zImage
98 101
99.PHONY: znetboot znetboot.initrd 102PHONY += znetboot znetboot.initrd
100znetboot: $(images)/zImage.chrp 103znetboot: $(images)/zImage.chrp
101 cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) 104 cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
102 @echo ' kernel: $@ is ready ($<)' 105 @echo ' kernel: $@ is ready ($<)'
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
index e70b34ee6275..79b7089d7500 100644
--- a/arch/ppc/syslib/ppc85xx_setup.c
+++ b/arch/ppc/syslib/ppc85xx_setup.c
@@ -235,7 +235,7 @@ mpc85xx_setup_pci2(struct pci_controller *hose)
235 (__ilog2(MPC85XX_PCI2_UPPER_MEM - MPC85XX_PCI2_LOWER_MEM + 1) - 1); 235 (__ilog2(MPC85XX_PCI2_UPPER_MEM - MPC85XX_PCI2_LOWER_MEM + 1) - 1);
236 236
237 /* Setup outbound IO windows @ MPC85XX_PCI2_IO_BASE */ 237 /* Setup outbound IO windows @ MPC85XX_PCI2_IO_BASE */
238 pci->potar2 = (MPC85XX_PCI2_LOWER_IO >> 12) & 0x000fffff;; 238 pci->potar2 = (MPC85XX_PCI2_LOWER_IO >> 12) & 0x000fffff;
239 pci->potear2 = 0x00000000; 239 pci->potear2 = 0x00000000;
240 pci->powbar2 = (MPC85XX_PCI2_IO_BASE >> 12) & 0x000fffff; 240 pci->powbar2 = (MPC85XX_PCI2_IO_BASE >> 12) & 0x000fffff;
241 /* Enable, IO R/W */ 241 /* Enable, IO R/W */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index b7ca5bf9acfc..2b7364ed23bc 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -460,6 +460,8 @@ config PCMCIA
460 460
461source "drivers/base/Kconfig" 461source "drivers/base/Kconfig"
462 462
463source "drivers/connector/Kconfig"
464
463source "drivers/scsi/Kconfig" 465source "drivers/scsi/Kconfig"
464 466
465source "drivers/s390/Kconfig" 467source "drivers/s390/Kconfig"
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index d06a8d71c71d..54d35c130907 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)
531 P_ERROR("ctl_nr %i already in use!\n", ops->ctl_nr); 531 P_ERROR("ctl_nr %i already in use!\n", ops->ctl_nr);
532 return -EBUSY; 532 return -EBUSY;
533 } 533 }
534 ops->ctl_table = kmalloc(4*sizeof(struct ctl_table), GFP_KERNEL); 534 ops->ctl_table = kzalloc(4*sizeof(struct ctl_table), GFP_KERNEL);
535 if (ops->ctl_table == NULL) { 535 if (ops->ctl_table == NULL) {
536 P_ERROR("Not enough memory for %s ctl_table!\n", ops->name); 536 P_ERROR("Not enough memory for %s ctl_table!\n", ops->name);
537 return -ENOMEM; 537 return -ENOMEM;
538 } 538 }
539 memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table));
540 539
541 spin_lock(&appldata_ops_lock); 540 spin_lock(&appldata_ops_lock);
542 list_for_each(lh, &appldata_ops_list) { 541 list_for_each(lh, &appldata_ops_list) {
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 896d39d0e4ce..06a3fbc12536 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)
204 goto fail_malloc_areas2; 204 goto fail_malloc_areas2;
205 } 205 }
206 for(j = 0; j < pages_per_area; j++) { 206 for(j = 0; j < pages_per_area; j++) {
207 areas[i][j] = (debug_entry_t*)kmalloc(PAGE_SIZE, 207 areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
208 GFP_KERNEL);
209 if(!areas[i][j]) { 208 if(!areas[i][j]) {
210 for(j--; j >=0 ; j--) { 209 for(j--; j >=0 ; j--) {
211 kfree(areas[i][j]); 210 kfree(areas[i][j]);
212 } 211 }
213 kfree(areas[i]); 212 kfree(areas[i]);
214 goto fail_malloc_areas2; 213 goto fail_malloc_areas2;
215 } else {
216 memset(areas[i][j],0,PAGE_SIZE);
217 } 214 }
218 } 215 }
219 } 216 }
@@ -249,14 +246,12 @@ debug_info_alloc(char *name, int pages_per_area, int nr_areas, int buf_size,
249 rc = (debug_info_t*) kmalloc(sizeof(debug_info_t), GFP_KERNEL); 246 rc = (debug_info_t*) kmalloc(sizeof(debug_info_t), GFP_KERNEL);
250 if(!rc) 247 if(!rc)
251 goto fail_malloc_rc; 248 goto fail_malloc_rc;
252 rc->active_entries = (int*)kmalloc(nr_areas * sizeof(int), GFP_KERNEL); 249 rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
253 if(!rc->active_entries) 250 if(!rc->active_entries)
254 goto fail_malloc_active_entries; 251 goto fail_malloc_active_entries;
255 memset(rc->active_entries, 0, nr_areas * sizeof(int)); 252 rc->active_pages = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
256 rc->active_pages = (int*)kmalloc(nr_areas * sizeof(int), GFP_KERNEL);
257 if(!rc->active_pages) 253 if(!rc->active_pages)
258 goto fail_malloc_active_pages; 254 goto fail_malloc_active_pages;
259 memset(rc->active_pages, 0, nr_areas * sizeof(int));
260 if((mode == ALL_AREAS) && (pages_per_area != 0)){ 255 if((mode == ALL_AREAS) && (pages_per_area != 0)){
261 rc->areas = debug_areas_alloc(pages_per_area, nr_areas); 256 rc->areas = debug_areas_alloc(pages_per_area, nr_areas);
262 if(!rc->areas) 257 if(!rc->areas)
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index da6fbae8df91..99182a415fe7 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -103,7 +103,7 @@ extern void s390_handle_mcck(void);
103/* 103/*
104 * The idle loop on a S390... 104 * The idle loop on a S390...
105 */ 105 */
106void default_idle(void) 106static void default_idle(void)
107{ 107{
108 int cpu, rc; 108 int cpu, rc;
109 109
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 24f62f16c0e5..0a04e4a564b2 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -78,8 +78,6 @@ extern int _text,_etext, _edata, _end;
78 78
79#include <asm/setup.h> 79#include <asm/setup.h>
80 80
81static char command_line[COMMAND_LINE_SIZE] = { 0, };
82
83static struct resource code_resource = { 81static struct resource code_resource = {
84 .name = "Kernel code", 82 .name = "Kernel code",
85 .start = (unsigned long) &_text, 83 .start = (unsigned long) &_text,
@@ -335,63 +333,38 @@ add_memory_hole(unsigned long start, unsigned long end)
335 } 333 }
336} 334}
337 335
338static void __init 336static int __init early_parse_mem(char *p)
339parse_cmdline_early(char **cmdline_p) 337{
338 memory_end = memparse(p, &p);
339 return 0;
340}
341early_param("mem", early_parse_mem);
342
343/*
344 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
345 */
346static int __init early_parse_ipldelay(char *p)
340{ 347{
341 char c = ' ', cn, *to = command_line, *from = COMMAND_LINE;
342 unsigned long delay = 0; 348 unsigned long delay = 0;
343 349
344 /* Save unparsed command line copy for /proc/cmdline */ 350 delay = simple_strtoul(p, &p, 0);
345 memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
346 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
347 351
348 for (;;) { 352 switch (*p) {
349 /* 353 case 's':
350 * "mem=XXX[kKmM]" sets memsize 354 case 'S':
351 */ 355 delay *= 1000000;
352 if (c == ' ' && strncmp(from, "mem=", 4) == 0) { 356 break;
353 memory_end = simple_strtoul(from+4, &from, 0); 357 case 'm':
354 if ( *from == 'K' || *from == 'k' ) { 358 case 'M':
355 memory_end = memory_end << 10; 359 delay *= 60 * 1000000;
356 from++;
357 } else if ( *from == 'M' || *from == 'm' ) {
358 memory_end = memory_end << 20;
359 from++;
360 }
361 }
362 /*
363 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
364 */
365 if (c == ' ' && strncmp(from, "ipldelay=", 9) == 0) {
366 delay = simple_strtoul(from+9, &from, 0);
367 if (*from == 's' || *from == 'S') {
368 delay = delay*1000000;
369 from++;
370 } else if (*from == 'm' || *from == 'M') {
371 delay = delay*60*1000000;
372 from++;
373 }
374 /* now wait for the requested amount of time */
375 udelay(delay);
376 }
377 cn = *(from++);
378 if (!cn)
379 break;
380 if (cn == '\n')
381 cn = ' '; /* replace newlines with space */
382 if (cn == 0x0d)
383 cn = ' '; /* replace 0x0d with space */
384 if (cn == ' ' && c == ' ')
385 continue; /* remove additional spaces */
386 c = cn;
387 if (to - command_line >= COMMAND_LINE_SIZE)
388 break;
389 *(to++) = c;
390 } 360 }
391 if (c == ' ' && to > command_line) to--; 361
392 *to = '\0'; 362 /* now wait for the requested amount of time */
393 *cmdline_p = command_line; 363 udelay(delay);
364
365 return 0;
394} 366}
367early_param("ipldelay", early_parse_ipldelay);
395 368
396static void __init 369static void __init
397setup_lowcore(void) 370setup_lowcore(void)
@@ -580,9 +553,26 @@ setup_arch(char **cmdline_p)
580 "We are running native (64 bit mode)\n"); 553 "We are running native (64 bit mode)\n");
581#endif /* CONFIG_64BIT */ 554#endif /* CONFIG_64BIT */
582 555
556 /* Save unparsed command line copy for /proc/cmdline */
557 strlcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
558
559 *cmdline_p = COMMAND_LINE;
560 *(*cmdline_p + COMMAND_LINE_SIZE - 1) = '\0';
561
583 ROOT_DEV = Root_RAM0; 562 ROOT_DEV = Root_RAM0;
563
564 init_mm.start_code = PAGE_OFFSET;
565 init_mm.end_code = (unsigned long) &_etext;
566 init_mm.end_data = (unsigned long) &_edata;
567 init_mm.brk = (unsigned long) &_end;
568
569 memory_end = memory_size;
570
571 parse_early_param();
572
584#ifndef CONFIG_64BIT 573#ifndef CONFIG_64BIT
585 memory_end = memory_size & ~0x400000UL; /* align memory end to 4MB */ 574 memory_end &= ~0x400000UL;
575
586 /* 576 /*
587 * We need some free virtual space to be able to do vmalloc. 577 * We need some free virtual space to be able to do vmalloc.
588 * On a machine with 2GB memory we make sure that we have at 578 * On a machine with 2GB memory we make sure that we have at
@@ -591,17 +581,9 @@ setup_arch(char **cmdline_p)
591 if (memory_end > 1920*1024*1024) 581 if (memory_end > 1920*1024*1024)
592 memory_end = 1920*1024*1024; 582 memory_end = 1920*1024*1024;
593#else /* CONFIG_64BIT */ 583#else /* CONFIG_64BIT */
594 memory_end = memory_size & ~0x200000UL; /* detected in head.s */ 584 memory_end &= ~0x200000UL;
595#endif /* CONFIG_64BIT */ 585#endif /* CONFIG_64BIT */
596 586
597 init_mm.start_code = PAGE_OFFSET;
598 init_mm.end_code = (unsigned long) &_etext;
599 init_mm.end_data = (unsigned long) &_edata;
600 init_mm.brk = (unsigned long) &_end;
601
602 parse_cmdline_early(cmdline_p);
603 parse_early_param();
604
605 setup_memory(); 587 setup_memory();
606 setup_resources(); 588 setup_resources();
607 setup_lowcore(); 589 setup_lowcore();
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index d52d6d211d9f..2b8841f85534 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -665,7 +665,9 @@ __cpu_up(unsigned int cpu)
665 cpu_lowcore->current_task = (unsigned long) idle; 665 cpu_lowcore->current_task = (unsigned long) idle;
666 cpu_lowcore->cpu_data.cpu_nr = cpu; 666 cpu_lowcore->cpu_data.cpu_nr = cpu;
667 eieio(); 667 eieio();
668 signal_processor(cpu,sigp_restart); 668
669 while (signal_processor(cpu,sigp_restart) == sigp_busy)
670 udelay(10);
669 671
670 while (!cpu_online(cpu)) 672 while (!cpu_online(cpu))
671 cpu_relax(); 673 cpu_relax();
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index b075ab499d05..51596f429235 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -339,19 +339,19 @@ static struct ctl_table cmm_table[] = {
339 { 339 {
340 .ctl_name = VM_CMM_PAGES, 340 .ctl_name = VM_CMM_PAGES,
341 .procname = "cmm_pages", 341 .procname = "cmm_pages",
342 .mode = 0600, 342 .mode = 0644,
343 .proc_handler = &cmm_pages_handler, 343 .proc_handler = &cmm_pages_handler,
344 }, 344 },
345 { 345 {
346 .ctl_name = VM_CMM_TIMED_PAGES, 346 .ctl_name = VM_CMM_TIMED_PAGES,
347 .procname = "cmm_timed_pages", 347 .procname = "cmm_timed_pages",
348 .mode = 0600, 348 .mode = 0644,
349 .proc_handler = &cmm_pages_handler, 349 .proc_handler = &cmm_pages_handler,
350 }, 350 },
351 { 351 {
352 .ctl_name = VM_CMM_TIMEOUT, 352 .ctl_name = VM_CMM_TIMEOUT,
353 .procname = "cmm_timeout", 353 .procname = "cmm_timeout",
354 .mode = 0600, 354 .mode = 0644,
355 .proc_handler = &cmm_timeout_handler, 355 .proc_handler = &cmm_timeout_handler,
356 }, 356 },
357 { .ctl_name = 0 } 357 { .ctl_name = 0 }
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 08c9515c4806..c72e17a96eed 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
172 172
173archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach 173archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
174 174
175.PHONY: maketools FORCE 175PHONY += maketools FORCE
176maketools: include/linux/version.h FORCE 176maketools: include/linux/version.h FORCE
177 $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h 177 $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
178 178
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 9fd1723e6219..22dc9c21201d 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -19,7 +19,6 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/ptrace.h> 21#include <linux/ptrace.h>
22#include <linux/platform.h>
23#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
24#include <linux/kexec.h> 23#include <linux/kexec.h>
25 24
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index f944b58cdfe7..7c58fc1a39c4 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -23,7 +23,6 @@ menu "General machine setup"
23 23
24config SMP 24config SMP
25 bool "Symmetric multi-processing support (does not work on sun4/sun4c)" 25 bool "Symmetric multi-processing support (does not work on sun4/sun4c)"
26 depends on BROKEN
27 ---help--- 26 ---help---
28 This enables support for systems with more than one CPU. If you have 27 This enables support for systems with more than one CPU. If you have
29 a system with only one CPU, say N. If you have a system with more 28 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 4c60a6ef54a9..aac8af5aae51 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 *)) =
154struct irqaction static_irqaction[MAX_STATIC_ALLOC]; 154struct irqaction static_irqaction[MAX_STATIC_ALLOC];
155int static_irq_count; 155int static_irq_count;
156 156
157struct irqaction *irq_action[NR_IRQS] = { 157struct {
158 [0 ... (NR_IRQS-1)] = NULL 158 struct irqaction *action;
159}; 159 int flags;
160} sparc_irq[NR_IRQS];
161#define SPARC_IRQ_INPROGRESS 1
160 162
161/* Used to protect the IRQ action lists */ 163/* Used to protect the IRQ action lists */
162DEFINE_SPINLOCK(irq_action_lock); 164DEFINE_SPINLOCK(irq_action_lock);
@@ -177,7 +179,7 @@ int show_interrupts(struct seq_file *p, void *v)
177 } 179 }
178 spin_lock_irqsave(&irq_action_lock, flags); 180 spin_lock_irqsave(&irq_action_lock, flags);
179 if (i < NR_IRQS) { 181 if (i < NR_IRQS) {
180 action = *(i + irq_action); 182 action = sparc_irq[i].action;
181 if (!action) 183 if (!action)
182 goto out_unlock; 184 goto out_unlock;
183 seq_printf(p, "%3d: ", i); 185 seq_printf(p, "%3d: ", i);
@@ -186,7 +188,7 @@ int show_interrupts(struct seq_file *p, void *v)
186#else 188#else
187 for_each_online_cpu(j) { 189 for_each_online_cpu(j) {
188 seq_printf(p, "%10u ", 190 seq_printf(p, "%10u ",
189 kstat_cpu(cpu_logical_map(j)).irqs[i]); 191 kstat_cpu(j).irqs[i]);
190 } 192 }
191#endif 193#endif
192 seq_printf(p, " %c %s", 194 seq_printf(p, " %c %s",
@@ -207,7 +209,7 @@ out_unlock:
207void free_irq(unsigned int irq, void *dev_id) 209void free_irq(unsigned int irq, void *dev_id)
208{ 210{
209 struct irqaction * action; 211 struct irqaction * action;
210 struct irqaction * tmp = NULL; 212 struct irqaction **actionp;
211 unsigned long flags; 213 unsigned long flags;
212 unsigned int cpu_irq; 214 unsigned int cpu_irq;
213 215
@@ -225,7 +227,8 @@ void free_irq(unsigned int irq, void *dev_id)
225 227
226 spin_lock_irqsave(&irq_action_lock, flags); 228 spin_lock_irqsave(&irq_action_lock, flags);
227 229
228 action = *(cpu_irq + irq_action); 230 actionp = &sparc_irq[cpu_irq].action;
231 action = *actionp;
229 232
230 if (!action->handler) { 233 if (!action->handler) {
231 printk("Trying to free free IRQ%d\n",irq); 234 printk("Trying to free free IRQ%d\n",irq);
@@ -235,7 +238,7 @@ void free_irq(unsigned int irq, void *dev_id)
235 for (; action; action = action->next) { 238 for (; action; action = action->next) {
236 if (action->dev_id == dev_id) 239 if (action->dev_id == dev_id)
237 break; 240 break;
238 tmp = action; 241 actionp = &action->next;
239 } 242 }
240 if (!action) { 243 if (!action) {
241 printk("Trying to free free shared IRQ%d\n",irq); 244 printk("Trying to free free shared IRQ%d\n",irq);
@@ -254,11 +257,8 @@ void free_irq(unsigned int irq, void *dev_id)
254 irq, action->name); 257 irq, action->name);
255 goto out_unlock; 258 goto out_unlock;
256 } 259 }
257 260
258 if (action && tmp) 261 *actionp = action->next;
259 tmp->next = action->next;
260 else
261 *(cpu_irq + irq_action) = action->next;
262 262
263 spin_unlock_irqrestore(&irq_action_lock, flags); 263 spin_unlock_irqrestore(&irq_action_lock, flags);
264 264
@@ -268,7 +268,7 @@ void free_irq(unsigned int irq, void *dev_id)
268 268
269 kfree(action); 269 kfree(action);
270 270
271 if (!(*(cpu_irq + irq_action))) 271 if (!sparc_irq[cpu_irq].action)
272 disable_irq(irq); 272 disable_irq(irq);
273 273
274out_unlock: 274out_unlock:
@@ -287,8 +287,11 @@ EXPORT_SYMBOL(free_irq);
287#ifdef CONFIG_SMP 287#ifdef CONFIG_SMP
288void synchronize_irq(unsigned int irq) 288void synchronize_irq(unsigned int irq)
289{ 289{
290 printk("synchronize_irq says: implement me!\n"); 290 unsigned int cpu_irq;
291 BUG(); 291
292 cpu_irq = irq & (NR_IRQS - 1);
293 while (sparc_irq[cpu_irq].flags & SPARC_IRQ_INPROGRESS)
294 cpu_relax();
292} 295}
293#endif /* SMP */ 296#endif /* SMP */
294 297
@@ -299,7 +302,7 @@ void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs)
299 unsigned int cpu_irq; 302 unsigned int cpu_irq;
300 303
301 cpu_irq = irq & (NR_IRQS - 1); 304 cpu_irq = irq & (NR_IRQS - 1);
302 action = *(cpu_irq + irq_action); 305 action = sparc_irq[cpu_irq].action;
303 306
304 printk("IO device interrupt, irq = %d\n", irq); 307 printk("IO device interrupt, irq = %d\n", irq);
305 printk("PC = %08lx NPC = %08lx FP=%08lx\n", regs->pc, 308 printk("PC = %08lx NPC = %08lx FP=%08lx\n", regs->pc,
@@ -330,7 +333,8 @@ void handler_irq(int irq, struct pt_regs * regs)
330 if(irq < 10) 333 if(irq < 10)
331 smp4m_irq_rotate(cpu); 334 smp4m_irq_rotate(cpu);
332#endif 335#endif
333 action = *(irq + irq_action); 336 action = sparc_irq[irq].action;
337 sparc_irq[irq].flags |= SPARC_IRQ_INPROGRESS;
334 kstat_cpu(cpu).irqs[irq]++; 338 kstat_cpu(cpu).irqs[irq]++;
335 do { 339 do {
336 if (!action || !action->handler) 340 if (!action || !action->handler)
@@ -338,6 +342,7 @@ void handler_irq(int irq, struct pt_regs * regs)
338 action->handler(irq, action->dev_id, regs); 342 action->handler(irq, action->dev_id, regs);
339 action = action->next; 343 action = action->next;
340 } while (action); 344 } while (action);
345 sparc_irq[irq].flags &= ~SPARC_IRQ_INPROGRESS;
341 enable_pil_irq(irq); 346 enable_pil_irq(irq);
342 irq_exit(); 347 irq_exit();
343} 348}
@@ -389,7 +394,7 @@ int request_fast_irq(unsigned int irq,
389 394
390 spin_lock_irqsave(&irq_action_lock, flags); 395 spin_lock_irqsave(&irq_action_lock, flags);
391 396
392 action = *(cpu_irq + irq_action); 397 action = sparc_irq[cpu_irq].action;
393 if(action) { 398 if(action) {
394 if(action->flags & SA_SHIRQ) 399 if(action->flags & SA_SHIRQ)
395 panic("Trying to register fast irq when already shared.\n"); 400 panic("Trying to register fast irq when already shared.\n");
@@ -452,7 +457,7 @@ int request_fast_irq(unsigned int irq,
452 action->dev_id = NULL; 457 action->dev_id = NULL;
453 action->next = NULL; 458 action->next = NULL;
454 459
455 *(cpu_irq + irq_action) = action; 460 sparc_irq[cpu_irq].action = action;
456 461
457 enable_irq(irq); 462 enable_irq(irq);
458 463
@@ -467,7 +472,7 @@ int request_irq(unsigned int irq,
467 irqreturn_t (*handler)(int, void *, struct pt_regs *), 472 irqreturn_t (*handler)(int, void *, struct pt_regs *),
468 unsigned long irqflags, const char * devname, void *dev_id) 473 unsigned long irqflags, const char * devname, void *dev_id)
469{ 474{
470 struct irqaction * action, *tmp = NULL; 475 struct irqaction * action, **actionp;
471 unsigned long flags; 476 unsigned long flags;
472 unsigned int cpu_irq; 477 unsigned int cpu_irq;
473 int ret; 478 int ret;
@@ -490,20 +495,20 @@ int request_irq(unsigned int irq,
490 495
491 spin_lock_irqsave(&irq_action_lock, flags); 496 spin_lock_irqsave(&irq_action_lock, flags);
492 497
493 action = *(cpu_irq + irq_action); 498 actionp = &sparc_irq[cpu_irq].action;
499 action = *actionp;
494 if (action) { 500 if (action) {
495 if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) { 501 if (!(action->flags & SA_SHIRQ) || !(irqflags & SA_SHIRQ)) {
496 for (tmp = action; tmp->next; tmp = tmp->next);
497 } else {
498 ret = -EBUSY; 502 ret = -EBUSY;
499 goto out_unlock; 503 goto out_unlock;
500 } 504 }
501 if ((action->flags & SA_INTERRUPT) ^ (irqflags & SA_INTERRUPT)) { 505 if ((action->flags & SA_INTERRUPT) != (irqflags & SA_INTERRUPT)) {
502 printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq); 506 printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
503 ret = -EBUSY; 507 ret = -EBUSY;
504 goto out_unlock; 508 goto out_unlock;
505 } 509 }
506 action = NULL; /* Or else! */ 510 for ( ; action; action = *actionp)
511 actionp = &action->next;
507 } 512 }
508 513
509 /* If this is flagged as statically allocated then we use our 514 /* If this is flagged as statically allocated then we use our
@@ -532,10 +537,7 @@ int request_irq(unsigned int irq,
532 action->next = NULL; 537 action->next = NULL;
533 action->dev_id = dev_id; 538 action->dev_id = dev_id;
534 539
535 if (tmp) 540 *actionp = action;
536 tmp->next = action;
537 else
538 *(cpu_irq + irq_action) = action;
539 541
540 enable_irq(irq); 542 enable_irq(irq);
541 543
diff --git a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
index ea5682ce7031..2be812115197 100644
--- a/arch/sparc/kernel/smp.c
+++ b/arch/sparc/kernel/smp.c
@@ -45,6 +45,7 @@ volatile int __cpu_logical_map[NR_CPUS];
45 45
46cpumask_t cpu_online_map = CPU_MASK_NONE; 46cpumask_t cpu_online_map = CPU_MASK_NONE;
47cpumask_t phys_cpu_present_map = CPU_MASK_NONE; 47cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
48cpumask_t smp_commenced_mask = CPU_MASK_NONE;
48 49
49/* The only guaranteed locking primitive available on all Sparc 50/* The only guaranteed locking primitive available on all Sparc
50 * processors is 'ldstub [%reg + immediate], %dest_reg' which atomically 51 * processors is 'ldstub [%reg + immediate], %dest_reg' which atomically
@@ -57,11 +58,6 @@ cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
57/* Used to make bitops atomic */ 58/* Used to make bitops atomic */
58unsigned char bitops_spinlock = 0; 59unsigned char bitops_spinlock = 0;
59 60
60volatile unsigned long ipi_count;
61
62volatile int smp_process_available=0;
63volatile int smp_commenced = 0;
64
65void __init smp_store_cpu_info(int id) 61void __init smp_store_cpu_info(int id)
66{ 62{
67 int cpu_node; 63 int cpu_node;
@@ -79,6 +75,22 @@ void __init smp_store_cpu_info(int id)
79 75
80void __init smp_cpus_done(unsigned int max_cpus) 76void __init smp_cpus_done(unsigned int max_cpus)
81{ 77{
78 extern void smp4m_smp_done(void);
79 unsigned long bogosum = 0;
80 int cpu, num;
81
82 for (cpu = 0, num = 0; cpu < NR_CPUS; cpu++)
83 if (cpu_online(cpu)) {
84 num++;
85 bogosum += cpu_data(cpu).udelay_val;
86 }
87
88 printk("Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
89 num, bogosum/(500000/HZ),
90 (bogosum/(5000/HZ))%100);
91
92 BUG_ON(sparc_cpu_model != sun4m);
93 smp4m_smp_done();
82} 94}
83 95
84void cpu_panic(void) 96void cpu_panic(void)
@@ -89,17 +101,6 @@ void cpu_panic(void)
89 101
90struct linux_prom_registers smp_penguin_ctable __initdata = { 0 }; 102struct linux_prom_registers smp_penguin_ctable __initdata = { 0 };
91 103
92void __init smp_boot_cpus(void)
93{
94 extern void smp4m_boot_cpus(void);
95 extern void smp4d_boot_cpus(void);
96
97 if (sparc_cpu_model == sun4m)
98 smp4m_boot_cpus();
99 else
100 smp4d_boot_cpus();
101}
102
103void smp_send_reschedule(int cpu) 104void smp_send_reschedule(int cpu)
104{ 105{
105 /* See sparc64 */ 106 /* See sparc64 */
@@ -252,20 +253,61 @@ int setup_profiling_timer(unsigned int multiplier)
252 return 0; 253 return 0;
253} 254}
254 255
255void __init smp_prepare_cpus(unsigned int maxcpus) 256void __init smp_prepare_cpus(unsigned int max_cpus)
256{ 257{
258 extern void smp4m_boot_cpus(void);
259 int i, cpuid, ncpus, extra;
260
261 BUG_ON(sparc_cpu_model != sun4m);
262 printk("Entering SMP Mode...\n");
263
264 ncpus = 1;
265 extra = 0;
266 for (i = 0; !cpu_find_by_instance(i, NULL, &cpuid); i++) {
267 if (cpuid == boot_cpu_id)
268 continue;
269 if (cpuid < NR_CPUS && ncpus++ < max_cpus)
270 cpu_set(cpuid, phys_cpu_present_map);
271 else
272 extra++;
273 }
274 if (max_cpus >= NR_CPUS && extra)
275 printk("Warning: NR_CPUS is too low to start all cpus\n");
276
277 smp_store_cpu_info(boot_cpu_id);
278
279 smp4m_boot_cpus();
257} 280}
258 281
259void __devinit smp_prepare_boot_cpu(void) 282void __devinit smp_prepare_boot_cpu(void)
260{ 283{
261 current_thread_info()->cpu = hard_smp_processor_id(); 284 int cpuid = hard_smp_processor_id();
262 cpu_set(smp_processor_id(), cpu_online_map); 285
263 cpu_set(smp_processor_id(), phys_cpu_present_map); 286 if (cpuid >= NR_CPUS) {
287 prom_printf("Serious problem, boot cpu id >= NR_CPUS\n");
288 prom_halt();
289 }
290 if (cpuid != 0)
291 printk("boot cpu id != 0, this could work but is untested\n");
292
293 current_thread_info()->cpu = cpuid;
294 cpu_set(cpuid, cpu_online_map);
295 cpu_set(cpuid, phys_cpu_present_map);
264} 296}
265 297
266int __devinit __cpu_up(unsigned int cpu) 298int __devinit __cpu_up(unsigned int cpu)
267{ 299{
268 panic("smp doesn't work\n"); 300 extern int smp4m_boot_one_cpu(int);
301 int ret;
302
303 ret = smp4m_boot_one_cpu(cpu);
304
305 if (!ret) {
306 cpu_set(cpu, smp_commenced_mask);
307 while (!cpu_online(cpu))
308 mb();
309 }
310 return ret;
269} 311}
270 312
271void smp_bogo(struct seq_file *m) 313void smp_bogo(struct seq_file *m)
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 19b25399d7e4..2c21d7907635 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);
136/* IRQ implementation. */ 136/* IRQ implementation. */
137EXPORT_SYMBOL(synchronize_irq); 137EXPORT_SYMBOL(synchronize_irq);
138 138
139/* Misc SMP information */
140EXPORT_SYMBOL(__cpu_number_map);
141EXPORT_SYMBOL(__cpu_logical_map);
142
143/* CPU online map and active count. */ 139/* CPU online map and active count. */
144EXPORT_SYMBOL(cpu_online_map); 140EXPORT_SYMBOL(cpu_online_map);
145EXPORT_SYMBOL(phys_cpu_present_map); 141EXPORT_SYMBOL(phys_cpu_present_map);
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index cea7fc6fc6e5..ca656d9bd6fd 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -54,7 +54,7 @@ unsigned char cpu_leds[32];
54unsigned char sbus_tid[32]; 54unsigned char sbus_tid[32];
55#endif 55#endif
56 56
57extern struct irqaction *irq_action[]; 57static struct irqaction *irq_action[NR_IRQS];
58extern spinlock_t irq_action_lock; 58extern spinlock_t irq_action_lock;
59 59
60struct sbus_action { 60struct sbus_action {
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 41bb9596be48..b141b7ee6717 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;
46extern int smp_num_cpus; 46extern int smp_num_cpus;
47static int smp_highest_cpu; 47static int smp_highest_cpu;
48extern volatile unsigned long cpu_callin_map[NR_CPUS]; 48extern volatile unsigned long cpu_callin_map[NR_CPUS];
49extern struct cpuinfo_sparc cpu_data[NR_CPUS]; 49extern cpuinfo_sparc cpu_data[NR_CPUS];
50extern unsigned char boot_cpu_id; 50extern unsigned char boot_cpu_id;
51extern int smp_activated; 51extern int smp_activated;
52extern volatile int __cpu_number_map[NR_CPUS]; 52extern volatile int __cpu_number_map[NR_CPUS];
53extern volatile int __cpu_logical_map[NR_CPUS]; 53extern volatile int __cpu_logical_map[NR_CPUS];
54extern volatile unsigned long ipi_count; 54extern volatile unsigned long ipi_count;
55extern volatile int smp_process_available; 55extern volatile int smp_process_available;
56extern volatile int smp_commenced; 56
57extern cpumask_t smp_commenced_mask;
58
57extern int __smp4d_processor_id(void); 59extern int __smp4d_processor_id(void);
58 60
59/* #define SMP_DEBUG */ 61/* #define SMP_DEBUG */
@@ -136,7 +138,7 @@ void __init smp4d_callin(void)
136 138
137 local_irq_enable(); /* We don't allow PIL 14 yet */ 139 local_irq_enable(); /* We don't allow PIL 14 yet */
138 140
139 while(!smp_commenced) 141 while (!cpu_isset(cpuid, smp_commenced_mask))
140 barrier(); 142 barrier();
141 143
142 spin_lock_irqsave(&sun4d_imsk_lock, flags); 144 spin_lock_irqsave(&sun4d_imsk_lock, flags);
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index 1dde312eebda..70b375a4c2c2 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;
40extern void calibrate_delay(void); 40extern void calibrate_delay(void);
41 41
42extern volatile int smp_processors_ready; 42extern volatile int smp_processors_ready;
43extern int smp_num_cpus;
44extern volatile unsigned long cpu_callin_map[NR_CPUS]; 43extern volatile unsigned long cpu_callin_map[NR_CPUS];
45extern unsigned char boot_cpu_id; 44extern unsigned char boot_cpu_id;
46extern int smp_activated; 45
47extern volatile int __cpu_number_map[NR_CPUS]; 46extern cpumask_t smp_commenced_mask;
48extern volatile int __cpu_logical_map[NR_CPUS]; 47
49extern volatile unsigned long ipi_count;
50extern volatile int smp_process_available;
51extern volatile int smp_commenced;
52extern int __smp4m_processor_id(void); 48extern int __smp4m_processor_id(void);
53 49
54/*#define SMP_DEBUG*/ 50/*#define SMP_DEBUG*/
@@ -77,8 +73,6 @@ void __init smp4m_callin(void)
77 local_flush_cache_all(); 73 local_flush_cache_all();
78 local_flush_tlb_all(); 74 local_flush_tlb_all();
79 75
80 set_irq_udt(boot_cpu_id);
81
82 /* Get our local ticker going. */ 76 /* Get our local ticker going. */
83 smp_setup_percpu_timer(); 77 smp_setup_percpu_timer();
84 78
@@ -95,8 +89,9 @@ void __init smp4m_callin(void)
95 * to call the scheduler code. 89 * to call the scheduler code.
96 */ 90 */
97 /* Allow master to continue. */ 91 /* Allow master to continue. */
98 swap((unsigned long *)&cpu_callin_map[cpuid], 1); 92 swap(&cpu_callin_map[cpuid], 1);
99 93
94 /* XXX: What's up with all the flushes? */
100 local_flush_cache_all(); 95 local_flush_cache_all();
101 local_flush_tlb_all(); 96 local_flush_tlb_all();
102 97
@@ -111,13 +106,14 @@ void __init smp4m_callin(void)
111 atomic_inc(&init_mm.mm_count); 106 atomic_inc(&init_mm.mm_count);
112 current->active_mm = &init_mm; 107 current->active_mm = &init_mm;
113 108
114 while(!smp_commenced) 109 while (!cpu_isset(cpuid, smp_commenced_mask))
115 barrier(); 110 mb();
116
117 local_flush_cache_all();
118 local_flush_tlb_all();
119 111
120 local_irq_enable(); 112 local_irq_enable();
113
114 cpu_set(cpuid, cpu_online_map);
115 /* last one in gets all the interrupts (for testing) */
116 set_irq_udt(boot_cpu_id);
121} 117}
122 118
123extern void init_IRQ(void); 119extern void init_IRQ(void);
@@ -134,102 +130,76 @@ extern unsigned long trapbase_cpu3[];
134 130
135void __init smp4m_boot_cpus(void) 131void __init smp4m_boot_cpus(void)
136{ 132{
137 int cpucount = 0; 133 smp_setup_percpu_timer();
138 int i, mid; 134 local_flush_cache_all();
135}
139 136
140 printk("Entering SMP Mode...\n"); 137int smp4m_boot_one_cpu(int i)
138{
139 extern unsigned long sun4m_cpu_startup;
140 unsigned long *entry = &sun4m_cpu_startup;
141 struct task_struct *p;
142 int timeout;
143 int cpu_node;
141 144
142 local_irq_enable(); 145 cpu_find_by_mid(i, &cpu_node);
143 cpus_clear(cpu_present_map); 146
147 /* Cook up an idler for this guy. */
148 p = fork_idle(i);
149 current_set[i] = task_thread_info(p);
150 /* See trampoline.S for details... */
151 entry += ((i-1) * 3);
144 152
145 for (i = 0; !cpu_find_by_instance(i, NULL, &mid); i++) 153 /*
146 cpu_set(mid, cpu_present_map); 154 * Initialize the contexts table
155 * Since the call to prom_startcpu() trashes the structure,
156 * we need to re-initialize it for each cpu
157 */
158 smp_penguin_ctable.which_io = 0;
159 smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
160 smp_penguin_ctable.reg_size = 0;
147 161
148 for(i=0; i < NR_CPUS; i++) { 162 /* whirrr, whirrr, whirrrrrrrrr... */
149 __cpu_number_map[i] = -1; 163 printk("Starting CPU %d at %p\n", i, entry);
150 __cpu_logical_map[i] = -1; 164 local_flush_cache_all();
165 prom_startcpu(cpu_node,
166 &smp_penguin_ctable, 0, (char *)entry);
167
168 /* wheee... it's going... */
169 for(timeout = 0; timeout < 10000; timeout++) {
170 if(cpu_callin_map[i])
171 break;
172 udelay(200);
151 } 173 }
152 174
153 __cpu_number_map[boot_cpu_id] = 0; 175 if (!(cpu_callin_map[i])) {
154 __cpu_logical_map[0] = boot_cpu_id; 176 printk("Processor %d is stuck.\n", i);
155 current_thread_info()->cpu = boot_cpu_id; 177 return -ENODEV;
178 }
156 179
157 smp_store_cpu_info(boot_cpu_id);
158 set_irq_udt(boot_cpu_id);
159 smp_setup_percpu_timer();
160 local_flush_cache_all(); 180 local_flush_cache_all();
161 if(cpu_find_by_instance(1, NULL, NULL)) 181 return 0;
162 return; /* Not an MP box. */ 182}
163 for(i = 0; i < NR_CPUS; i++) { 183
164 if(i == boot_cpu_id) 184void __init smp4m_smp_done(void)
165 continue; 185{
166 186 int i, first;
167 if (cpu_isset(i, cpu_present_map)) { 187 int *prev;
168 extern unsigned long sun4m_cpu_startup; 188
169 unsigned long *entry = &sun4m_cpu_startup; 189 /* setup cpu list for irq rotation */
170 struct task_struct *p; 190 first = 0;
171 int timeout; 191 prev = &first;
172 192 for (i = 0; i < NR_CPUS; i++) {
173 /* Cook up an idler for this guy. */ 193 if (cpu_online(i)) {
174 p = fork_idle(i); 194 *prev = i;
175 cpucount++; 195 prev = &cpu_data(i).next;
176 current_set[i] = task_thread_info(p);
177 /* See trampoline.S for details... */
178 entry += ((i-1) * 3);
179
180 /*
181 * Initialize the contexts table
182 * Since the call to prom_startcpu() trashes the structure,
183 * we need to re-initialize it for each cpu
184 */
185 smp_penguin_ctable.which_io = 0;
186 smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
187 smp_penguin_ctable.reg_size = 0;
188
189 /* whirrr, whirrr, whirrrrrrrrr... */
190 printk("Starting CPU %d at %p\n", i, entry);
191 local_flush_cache_all();
192 prom_startcpu(cpu_data(i).prom_node,
193 &smp_penguin_ctable, 0, (char *)entry);
194
195 /* wheee... it's going... */
196 for(timeout = 0; timeout < 10000; timeout++) {
197 if(cpu_callin_map[i])
198 break;
199 udelay(200);
200 }
201 if(cpu_callin_map[i]) {
202 /* Another "Red Snapper". */
203 __cpu_number_map[i] = i;
204 __cpu_logical_map[i] = i;
205 } else {
206 cpucount--;
207 printk("Processor %d is stuck.\n", i);
208 }
209 }
210 if(!(cpu_callin_map[i])) {
211 cpu_clear(i, cpu_present_map);
212 __cpu_number_map[i] = -1;
213 } 196 }
214 } 197 }
198 *prev = first;
215 local_flush_cache_all(); 199 local_flush_cache_all();
216 if(cpucount == 0) {
217 printk("Error: only one Processor found.\n");
218 cpu_present_map = cpumask_of_cpu(smp_processor_id());
219 } else {
220 unsigned long bogosum = 0;
221 for_each_present_cpu(i)
222 bogosum += cpu_data(i).udelay_val;
223 printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n",
224 cpucount + 1,
225 bogosum/(500000/HZ),
226 (bogosum/(5000/HZ))%100);
227 smp_activated = 1;
228 smp_num_cpus = cpucount + 1;
229 }
230 200
231 /* Free unneeded trap tables */ 201 /* Free unneeded trap tables */
232 if (!cpu_isset(i, cpu_present_map)) { 202 if (!cpu_isset(1, cpu_present_map)) {
233 ClearPageReserved(virt_to_page(trapbase_cpu1)); 203 ClearPageReserved(virt_to_page(trapbase_cpu1));
234 init_page_count(virt_to_page(trapbase_cpu1)); 204 init_page_count(virt_to_page(trapbase_cpu1));
235 free_page((unsigned long)trapbase_cpu1); 205 free_page((unsigned long)trapbase_cpu1);
@@ -263,6 +233,9 @@ void __init smp4m_boot_cpus(void)
263 */ 233 */
264void smp4m_irq_rotate(int cpu) 234void smp4m_irq_rotate(int cpu)
265{ 235{
236 int next = cpu_data(cpu).next;
237 if (next != cpu)
238 set_irq_udt(next);
266} 239}
267 240
268/* Cross calls, in order to work efficiently and atomically do all 241/* Cross calls, in order to work efficiently and atomically do all
@@ -289,7 +262,7 @@ void smp4m_message_pass(int target, int msg, unsigned long data, int wait)
289 262
290 smp_cpu_in_msg[me]++; 263 smp_cpu_in_msg[me]++;
291 if(target == MSG_ALL_BUT_SELF || target == MSG_ALL) { 264 if(target == MSG_ALL_BUT_SELF || target == MSG_ALL) {
292 mask = cpu_present_map; 265 mask = cpu_online_map;
293 if(target == MSG_ALL_BUT_SELF) 266 if(target == MSG_ALL_BUT_SELF)
294 cpu_clear(me, mask); 267 cpu_clear(me, mask);
295 for(i = 0; i < 4; i++) { 268 for(i = 0; i < 4; i++) {
@@ -314,8 +287,8 @@ static struct smp_funcall {
314 unsigned long arg3; 287 unsigned long arg3;
315 unsigned long arg4; 288 unsigned long arg4;
316 unsigned long arg5; 289 unsigned long arg5;
317 unsigned long processors_in[NR_CPUS]; /* Set when ipi entered. */ 290 unsigned long processors_in[SUN4M_NCPUS]; /* Set when ipi entered. */
318 unsigned long processors_out[NR_CPUS]; /* Set when ipi exited. */ 291 unsigned long processors_out[SUN4M_NCPUS]; /* Set when ipi exited. */
319} ccall_info; 292} ccall_info;
320 293
321static DEFINE_SPINLOCK(cross_call_lock); 294static DEFINE_SPINLOCK(cross_call_lock);
@@ -324,8 +297,7 @@ static DEFINE_SPINLOCK(cross_call_lock);
324void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2, 297void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
325 unsigned long arg3, unsigned long arg4, unsigned long arg5) 298 unsigned long arg3, unsigned long arg4, unsigned long arg5)
326{ 299{
327 if(smp_processors_ready) { 300 register int ncpus = SUN4M_NCPUS;
328 register int ncpus = smp_num_cpus;
329 unsigned long flags; 301 unsigned long flags;
330 302
331 spin_lock_irqsave(&cross_call_lock, flags); 303 spin_lock_irqsave(&cross_call_lock, flags);
@@ -340,7 +312,7 @@ void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
340 312
341 /* Init receive/complete mapping, plus fire the IPI's off. */ 313 /* Init receive/complete mapping, plus fire the IPI's off. */
342 { 314 {
343 cpumask_t mask = cpu_present_map; 315 cpumask_t mask = cpu_online_map;
344 register int i; 316 register int i;
345 317
346 cpu_clear(smp_processor_id(), mask); 318 cpu_clear(smp_processor_id(), mask);
@@ -373,7 +345,6 @@ void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
373 } 345 }
374 346
375 spin_unlock_irqrestore(&cross_call_lock, flags); 347 spin_unlock_irqrestore(&cross_call_lock, flags);
376 }
377} 348}
378 349
379/* Running cross calls. */ 350/* Running cross calls. */
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 27b0e0ba8581..58c65cc8d0d3 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -1302,7 +1302,12 @@ void __init srmmu_paging_init(void)
1302 1302
1303 flush_cache_all(); 1303 flush_cache_all();
1304 srmmu_set_ctable_ptr((unsigned long)srmmu_ctx_table_phys); 1304 srmmu_set_ctable_ptr((unsigned long)srmmu_ctx_table_phys);
1305#ifdef CONFIG_SMP
1306 /* Stop from hanging here... */
1307 local_flush_tlb_all();
1308#else
1305 flush_tlb_all(); 1309 flush_tlb_all();
1310#endif
1306 poke_srmmu(); 1311 poke_srmmu();
1307 1312
1308#ifdef CONFIG_SUN_IO 1313#ifdef CONFIG_SUN_IO
@@ -1419,6 +1424,7 @@ static void __init init_vac_layout(void)
1419 max_size = vac_cache_size; 1424 max_size = vac_cache_size;
1420 if(vac_line_size < min_line_size) 1425 if(vac_line_size < min_line_size)
1421 min_line_size = vac_line_size; 1426 min_line_size = vac_line_size;
1427 //FIXME: cpus not contiguous!!
1422 cpu++; 1428 cpu++;
1423 if (cpu >= NR_CPUS || !cpu_online(cpu)) 1429 if (cpu >= NR_CPUS || !cpu_online(cpu))
1424 break; 1430 break;
diff --git a/arch/sparc64/Kconfig.debug b/arch/sparc64/Kconfig.debug
index 3e31be494e54..afe0a7720a26 100644
--- a/arch/sparc64/Kconfig.debug
+++ b/arch/sparc64/Kconfig.debug
@@ -24,7 +24,7 @@ config DEBUG_BOOTMEM
24 bool "Debug BOOTMEM initialization" 24 bool "Debug BOOTMEM initialization"
25 25
26config DEBUG_PAGEALLOC 26config DEBUG_PAGEALLOC
27 bool "Page alloc debugging" 27 bool "Debug page memory allocations"
28 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND 28 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND
29 help 29 help
30 Unmap pages from the kernel linear mapping after free_pages(). 30 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 e505a4125e35..11e645c9ec50 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -727,7 +727,7 @@ void handler_irq(int irq, struct pt_regs *regs)
727} 727}
728 728
729#ifdef CONFIG_BLK_DEV_FD 729#ifdef CONFIG_BLK_DEV_FD
730extern irqreturn_t floppy_interrupt(int, void *, struct pt_regs *);; 730extern irqreturn_t floppy_interrupt(int, void *, struct pt_regs *);
731 731
732/* XXX No easy way to include asm/floppy.h XXX */ 732/* XXX No easy way to include asm/floppy.h XXX */
733extern unsigned char *pdma_vaddr; 733extern unsigned char *pdma_vaddr;
diff --git a/arch/um/Makefile b/arch/um/Makefile
index c58b657f0097..8d14c7a831be 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -1,4 +1,7 @@
1# 1#
2# This file is included by the global makefile so that you can add your own
3# architecture-specific flags and dependencies.
4#
2# Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 5# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3# Licensed under the GPL 6# Licensed under the GPL
4# 7#
@@ -88,7 +91,7 @@ CONFIG_KERNEL_HALF_GIGS ?= 0
88 91
89SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) 92SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
90 93
91.PHONY: linux 94PHONY += linux
92 95
93all: linux 96all: linux
94 97
diff --git a/arch/v850/kernel/process.c b/arch/v850/kernel/process.c
index 621111ddf907..57218c76925c 100644
--- a/arch/v850/kernel/process.c
+++ b/arch/v850/kernel/process.c
@@ -37,7 +37,7 @@ extern void ret_from_fork (void);
37 37
38 38
39/* The idle loop. */ 39/* The idle loop. */
40void default_idle (void) 40static void default_idle (void)
41{ 41{
42 while (! need_resched ()) 42 while (! need_resched ())
43 asm ("halt; nop; nop; nop; nop; nop" ::: "cc"); 43 asm ("halt; nop; nop; nop; nop; nop" ::: "cc");
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index e18eb79bf855..6420baeb8c1f 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -323,7 +323,7 @@ config HAVE_ARCH_EARLY_PFN_TO_NID
323 323
324config NR_CPUS 324config NR_CPUS
325 int "Maximum number of CPUs (2-256)" 325 int "Maximum number of CPUs (2-256)"
326 range 2 256 326 range 2 255
327 depends on SMP 327 depends on SMP
328 default "8" 328 default "8"
329 help 329 help
@@ -364,13 +364,15 @@ config GART_IOMMU
364 select SWIOTLB 364 select SWIOTLB
365 depends on PCI 365 depends on PCI
366 help 366 help
367 Support the IOMMU. Needed to run systems with more than 3GB of memory 367 Support for hardware IOMMU in AMD's Opteron/Athlon64 Processors
368 properly with 32-bit PCI devices that do not support DAC (Double Address 368 and for the bounce buffering software IOMMU.
369 Cycle). The IOMMU can be turned off at runtime with the iommu=off parameter. 369 Needed to run systems with more than 3GB of memory properly with
370 Normally the kernel will take the right choice by itself. 370 32-bit PCI devices that do not support DAC (Double Address Cycle).
371 This option includes a driver for the AMD Opteron/Athlon64 northbridge IOMMU 371 The IOMMU can be turned off at runtime with the iommu=off parameter.
372 and a software emulation used on other systems. 372 Normally the kernel will take the right choice by itself.
373 If unsure, say Y. 373 This option includes a driver for the AMD Opteron/Athlon64 IOMMU
374 northbridge and a software emulation used on other systems without
375 hardware IOMMU. If unsure, say Y.
374 376
375# need this always enabled with GART_IOMMU for the VIA workaround 377# need this always enabled with GART_IOMMU for the VIA workaround
376config SWIOTLB 378config SWIOTLB
@@ -429,10 +431,10 @@ config CRASH_DUMP
429config PHYSICAL_START 431config PHYSICAL_START
430 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) 432 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
431 default "0x1000000" if CRASH_DUMP 433 default "0x1000000" if CRASH_DUMP
432 default "0x100000" 434 default "0x200000"
433 help 435 help
434 This gives the physical address where the kernel is loaded. Normally 436 This gives the physical address where the kernel is loaded. Normally
435 for regular kernels this value is 0x100000 (1MB). But in the case 437 for regular kernels this value is 0x200000 (2MB). But in the case
436 of kexec on panic the fail safe kernel needs to run at a different 438 of kexec on panic the fail safe kernel needs to run at a different
437 address than the panic-ed kernel. This option is used to set the load 439 address than the panic-ed kernel. This option is used to set the load
438 address for kernels used to capture crash dump on being kexec'ed 440 address for kernels used to capture crash dump on being kexec'ed
@@ -464,6 +466,14 @@ config SECCOMP
464 466
465source kernel/Kconfig.hz 467source kernel/Kconfig.hz
466 468
469config REORDER
470 bool "Function reordering"
471 default n
472 help
473 This option enables the toolchain to reorder functions for a more
474 optimal TLB usage. If you have pretty much any version of binutils,
475 this can increase your kernel build time by roughly one minute.
476
467endmenu 477endmenu
468 478
469# 479#
@@ -512,16 +522,6 @@ config PCI_MMCONFIG
512 bool "Support mmconfig PCI config space access" 522 bool "Support mmconfig PCI config space access"
513 depends on PCI && ACPI 523 depends on PCI && ACPI
514 524
515config UNORDERED_IO
516 bool "Unordered IO mapping access"
517 depends on EXPERIMENTAL
518 help
519 Use unordered stores to access IO memory mappings in device drivers.
520 Still very experimental. When a driver works on IA64/ppc64/pa-risc it should
521 work with this option, but it makes the drivers behave differently
522 from i386. Requires that the driver writer used memory barriers
523 properly.
524
525source "drivers/pci/pcie/Kconfig" 525source "drivers/pci/pcie/Kconfig"
526 526
527source "drivers/pci/Kconfig" 527source "drivers/pci/Kconfig"
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index d7fd46479c55..0fbc0283609c 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -29,12 +29,14 @@ CHECKFLAGS += -D__x86_64__ -m64
29 29
30cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) 30cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
31cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona) 31cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
32cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
32CFLAGS += $(cflags-y) 33CFLAGS += $(cflags-y)
33 34
34CFLAGS += -m64 35CFLAGS += -m64
35CFLAGS += -mno-red-zone 36CFLAGS += -mno-red-zone
36CFLAGS += -mcmodel=kernel 37CFLAGS += -mcmodel=kernel
37CFLAGS += -pipe 38CFLAGS += -pipe
39cflags-$(CONFIG_REORDER) += -ffunction-sections
38# this makes reading assembly source easier, but produces worse code 40# this makes reading assembly source easier, but produces worse code
39# actually it makes the kernel smaller too. 41# actually it makes the kernel smaller too.
40CFLAGS += -fno-reorder-blocks 42CFLAGS += -fno-reorder-blocks
@@ -67,8 +69,8 @@ drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
67 69
68boot := arch/x86_64/boot 70boot := arch/x86_64/boot
69 71
70.PHONY: bzImage bzlilo install archmrproper \ 72PHONY += bzImage bzlilo install archmrproper \
71 fdimage fdimage144 fdimage288 archclean 73 fdimage fdimage144 fdimage288 archclean
72 74
73#Default target when executing "make" 75#Default target when executing "make"
74all: bzImage 76all: bzImage
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index ce4de61ed85d..566ecc97ee5a 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16-rc3-git9 3# Linux kernel version: 2.6.16-git9
4# Sat Feb 18 00:27:03 2006 4# Sat Mar 25 15:18:40 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -38,6 +38,7 @@ CONFIG_SYSCTL=y
38CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
40# CONFIG_CPUSETS is not set 40# CONFIG_CPUSETS is not set
41# CONFIG_RELAY is not set
41CONFIG_INITRAMFS_SOURCE="" 42CONFIG_INITRAMFS_SOURCE=""
42CONFIG_UID16=y 43CONFIG_UID16=y
43CONFIG_VM86=y 44CONFIG_VM86=y
@@ -79,6 +80,7 @@ CONFIG_STOP_MACHINE=y
79# Block layer 80# Block layer
80# 81#
81CONFIG_LBD=y 82CONFIG_LBD=y
83# CONFIG_BLK_DEV_IO_TRACE is not set
82 84
83# 85#
84# IO Schedulers 86# IO Schedulers
@@ -139,7 +141,6 @@ CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
139CONFIG_NR_CPUS=32 141CONFIG_NR_CPUS=32
140CONFIG_HOTPLUG_CPU=y 142CONFIG_HOTPLUG_CPU=y
141CONFIG_HPET_TIMER=y 143CONFIG_HPET_TIMER=y
142CONFIG_X86_PM_TIMER=y
143CONFIG_HPET_EMULATE_RTC=y 144CONFIG_HPET_EMULATE_RTC=y
144CONFIG_GART_IOMMU=y 145CONFIG_GART_IOMMU=y
145CONFIG_SWIOTLB=y 146CONFIG_SWIOTLB=y
@@ -148,12 +149,13 @@ CONFIG_X86_MCE_INTEL=y
148CONFIG_X86_MCE_AMD=y 149CONFIG_X86_MCE_AMD=y
149# CONFIG_KEXEC is not set 150# CONFIG_KEXEC is not set
150# CONFIG_CRASH_DUMP is not set 151# CONFIG_CRASH_DUMP is not set
151CONFIG_PHYSICAL_START=0x100000 152CONFIG_PHYSICAL_START=0x200000
152CONFIG_SECCOMP=y 153CONFIG_SECCOMP=y
153# CONFIG_HZ_100 is not set 154# CONFIG_HZ_100 is not set
154CONFIG_HZ_250=y 155CONFIG_HZ_250=y
155# CONFIG_HZ_1000 is not set 156# CONFIG_HZ_1000 is not set
156CONFIG_HZ=250 157CONFIG_HZ=250
158# CONFIG_REORDER is not set
157CONFIG_GENERIC_HARDIRQS=y 159CONFIG_GENERIC_HARDIRQS=y
158CONFIG_GENERIC_IRQ_PROBE=y 160CONFIG_GENERIC_IRQ_PROBE=y
159CONFIG_ISA_DMA_API=y 161CONFIG_ISA_DMA_API=y
@@ -189,12 +191,14 @@ CONFIG_ACPI_NUMA=y
189# CONFIG_ACPI_ASUS is not set 191# CONFIG_ACPI_ASUS is not set
190# CONFIG_ACPI_IBM is not set 192# CONFIG_ACPI_IBM is not set
191CONFIG_ACPI_TOSHIBA=y 193CONFIG_ACPI_TOSHIBA=y
192CONFIG_ACPI_BLACKLIST_YEAR=2001 194CONFIG_ACPI_BLACKLIST_YEAR=0
193# CONFIG_ACPI_DEBUG is not set 195# CONFIG_ACPI_DEBUG is not set
194CONFIG_ACPI_EC=y 196CONFIG_ACPI_EC=y
195CONFIG_ACPI_POWER=y 197CONFIG_ACPI_POWER=y
196CONFIG_ACPI_SYSTEM=y 198CONFIG_ACPI_SYSTEM=y
199CONFIG_X86_PM_TIMER=y
197CONFIG_ACPI_CONTAINER=y 200CONFIG_ACPI_CONTAINER=y
201CONFIG_ACPI_HOTPLUG_MEMORY=y
198 202
199# 203#
200# CPU Frequency scaling 204# CPU Frequency scaling
@@ -232,10 +236,8 @@ CONFIG_X86_ACPI_CPUFREQ_PROC_INTF=y
232CONFIG_PCI=y 236CONFIG_PCI=y
233CONFIG_PCI_DIRECT=y 237CONFIG_PCI_DIRECT=y
234CONFIG_PCI_MMCONFIG=y 238CONFIG_PCI_MMCONFIG=y
235CONFIG_UNORDERED_IO=y
236CONFIG_PCIEPORTBUS=y 239CONFIG_PCIEPORTBUS=y
237CONFIG_PCI_MSI=y 240CONFIG_PCI_MSI=y
238# CONFIG_PCI_LEGACY_PROC is not set
239# CONFIG_PCI_DEBUG is not set 241# CONFIG_PCI_DEBUG is not set
240 242
241# 243#
@@ -294,6 +296,7 @@ CONFIG_INET_TCP_DIAG=y
294CONFIG_TCP_CONG_BIC=y 296CONFIG_TCP_CONG_BIC=y
295CONFIG_IPV6=y 297CONFIG_IPV6=y
296# CONFIG_IPV6_PRIVACY is not set 298# CONFIG_IPV6_PRIVACY is not set
299# CONFIG_IPV6_ROUTER_PREF is not set
297# CONFIG_INET6_AH is not set 300# CONFIG_INET6_AH is not set
298# CONFIG_INET6_ESP is not set 301# CONFIG_INET6_ESP is not set
299# CONFIG_INET6_IPCOMP is not set 302# CONFIG_INET6_IPCOMP is not set
@@ -701,6 +704,7 @@ CONFIG_S2IO=m
701# Wireless LAN (non-hamradio) 704# Wireless LAN (non-hamradio)
702# 705#
703# CONFIG_NET_RADIO is not set 706# CONFIG_NET_RADIO is not set
707# CONFIG_NET_WIRELESS_RTNETLINK is not set
704 708
705# 709#
706# Wan interfaces 710# Wan interfaces
@@ -861,6 +865,8 @@ CONFIG_RTC=y
861CONFIG_AGP=y 865CONFIG_AGP=y
862CONFIG_AGP_AMD64=y 866CONFIG_AGP_AMD64=y
863CONFIG_AGP_INTEL=y 867CONFIG_AGP_INTEL=y
868# CONFIG_AGP_SIS is not set
869# CONFIG_AGP_VIA is not set
864# CONFIG_DRM is not set 870# CONFIG_DRM is not set
865# CONFIG_MWAVE is not set 871# CONFIG_MWAVE is not set
866CONFIG_RAW_DRIVER=y 872CONFIG_RAW_DRIVER=y
@@ -907,10 +913,6 @@ CONFIG_HWMON=y
907# CONFIG_IBM_ASM is not set 913# CONFIG_IBM_ASM is not set
908 914
909# 915#
910# Multimedia Capabilities Port drivers
911#
912
913#
914# Multimedia devices 916# Multimedia devices
915# 917#
916# CONFIG_VIDEO_DEV is not set 918# CONFIG_VIDEO_DEV is not set
@@ -974,6 +976,7 @@ CONFIG_SOUND_ICH=y
974# 976#
975CONFIG_USB_ARCH_HAS_HCD=y 977CONFIG_USB_ARCH_HAS_HCD=y
976CONFIG_USB_ARCH_HAS_OHCI=y 978CONFIG_USB_ARCH_HAS_OHCI=y
979CONFIG_USB_ARCH_HAS_EHCI=y
977CONFIG_USB=y 980CONFIG_USB=y
978# CONFIG_USB_DEBUG is not set 981# CONFIG_USB_DEBUG is not set
979 982
@@ -1002,7 +1005,6 @@ CONFIG_USB_UHCI_HCD=y
1002# 1005#
1003# USB Device Class drivers 1006# USB Device Class drivers
1004# 1007#
1005# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
1006# CONFIG_USB_ACM is not set 1008# CONFIG_USB_ACM is not set
1007CONFIG_USB_PRINTER=y 1009CONFIG_USB_PRINTER=y
1008 1010
@@ -1121,11 +1123,7 @@ CONFIG_USB_MON=y
1121# CONFIG_INFINIBAND is not set 1123# CONFIG_INFINIBAND is not set
1122 1124
1123# 1125#
1124# SN Devices 1126# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1125#
1126
1127#
1128# EDAC - error detection and reporting (RAS)
1129# 1127#
1130# CONFIG_EDAC is not set 1128# CONFIG_EDAC is not set
1131 1129
@@ -1198,7 +1196,6 @@ CONFIG_TMPFS=y
1198CONFIG_HUGETLBFS=y 1196CONFIG_HUGETLBFS=y
1199CONFIG_HUGETLB_PAGE=y 1197CONFIG_HUGETLB_PAGE=y
1200CONFIG_RAMFS=y 1198CONFIG_RAMFS=y
1201CONFIG_RELAYFS_FS=y
1202# CONFIG_CONFIGFS_FS is not set 1199# CONFIG_CONFIGFS_FS is not set
1203 1200
1204# 1201#
@@ -1321,6 +1318,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
1321CONFIG_DEBUG_FS=y 1318CONFIG_DEBUG_FS=y
1322# CONFIG_DEBUG_VM is not set 1319# CONFIG_DEBUG_VM is not set
1323# CONFIG_FRAME_POINTER is not set 1320# CONFIG_FRAME_POINTER is not set
1321# CONFIG_UNWIND_INFO is not set
1324# CONFIG_FORCED_INLINING is not set 1322# CONFIG_FORCED_INLINING is not set
1325# CONFIG_RCU_TORTURE_TEST is not set 1323# CONFIG_RCU_TORTURE_TEST is not set
1326# CONFIG_DEBUG_RODATA is not set 1324# CONFIG_DEBUG_RODATA is not set
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 572b3b28772d..e776139afb20 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -58,7 +58,7 @@ struct elf_phdr;
58 58
59#define USE_ELF_CORE_DUMP 1 59#define USE_ELF_CORE_DUMP 1
60 60
61/* Overwrite elfcore.h */ 61/* Override elfcore.h */
62#define _LINUX_ELFCORE_H 1 62#define _LINUX_ELFCORE_H 1
63typedef unsigned int elf_greg_t; 63typedef unsigned int elf_greg_t;
64 64
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 2bc55af95419..2b2d029f477c 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)
430 return err; 430 return err;
431} 431}
432 432
433extern int do_setitimer(int which, struct itimerval *, struct itimerval *); 433extern unsigned int alarm_setitimer(unsigned int seconds);
434 434
435asmlinkage long 435asmlinkage long
436sys32_alarm(unsigned int seconds) 436sys32_alarm(unsigned int seconds)
437{ 437{
438 struct itimerval it_new, it_old; 438 return alarm_setitimer(seconds);
439 unsigned int oldalarm;
440
441 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
442 it_new.it_value.tv_sec = seconds;
443 it_new.it_value.tv_usec = 0;
444 do_setitimer(ITIMER_REAL, &it_new, &it_old);
445 oldalarm = it_old.it_value.tv_sec;
446 /* ehhh.. We can't return 0 if we have an alarm pending.. */
447 /* And we'd better return too much than too little anyway */
448 if (it_old.it_value.tv_usec)
449 oldalarm++;
450 return oldalarm;
451} 439}
452 440
453/* Translations due to time_t size differences. Which affects all 441/* Translations due to time_t size differences. Which affects all
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index a0f955b9995f..fffd6b0a2fab 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -60,7 +60,7 @@ static u32 __init allocate_aperture(void)
60 printk("Cannot allocate aperture memory hole (%p,%uK)\n", 60 printk("Cannot allocate aperture memory hole (%p,%uK)\n",
61 p, aper_size>>10); 61 p, aper_size>>10);
62 if (p) 62 if (p)
63 free_bootmem_node(nd0, (unsigned long)p, aper_size); 63 free_bootmem_node(nd0, __pa(p), aper_size);
64 return 0; 64 return 0;
65 } 65 }
66 printk("Mapping aperture over %d KB of RAM @ %lx\n", 66 printk("Mapping aperture over %d KB of RAM @ %lx\n",
@@ -161,7 +161,7 @@ static __u32 __init search_agp_bridge(u32 *order, int *valid_agp)
161 int num, slot, func; 161 int num, slot, func;
162 162
163 /* Poor man's PCI discovery */ 163 /* Poor man's PCI discovery */
164 for (num = 0; num < 32; num++) { 164 for (num = 0; num < 256; num++) {
165 for (slot = 0; slot < 32; slot++) { 165 for (slot = 0; slot < 32; slot++) {
166 for (func = 0; func < 8; func++) { 166 for (func = 0; func < 8; func++) {
167 u32 class, cap; 167 u32 class, cap;
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index e5b14c57eaa0..d54620147e8e 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -342,6 +342,7 @@ void __init init_bsp_APIC(void)
342void __cpuinit setup_local_APIC (void) 342void __cpuinit setup_local_APIC (void)
343{ 343{
344 unsigned int value, maxlvt; 344 unsigned int value, maxlvt;
345 int i, j;
345 346
346 value = apic_read(APIC_LVR); 347 value = apic_read(APIC_LVR);
347 348
@@ -371,6 +372,25 @@ void __cpuinit setup_local_APIC (void)
371 apic_write(APIC_TASKPRI, value); 372 apic_write(APIC_TASKPRI, value);
372 373
373 /* 374 /*
375 * After a crash, we no longer service the interrupts and a pending
376 * interrupt from previous kernel might still have ISR bit set.
377 *
378 * Most probably by now CPU has serviced that pending interrupt and
379 * it might not have done the ack_APIC_irq() because it thought,
380 * interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
381 * does not clear the ISR bit and cpu thinks it has already serivced
382 * the interrupt. Hence a vector might get locked. It was noticed
383 * for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
384 */
385 for (i = APIC_ISR_NR - 1; i >= 0; i--) {
386 value = apic_read(APIC_ISR + i*0x10);
387 for (j = 31; j >= 0; j--) {
388 if (value & (1<<j))
389 ack_APIC_irq();
390 }
391 }
392
393 /*
374 * Now that we are all set up, enable the APIC 394 * Now that we are all set up, enable the APIC
375 */ 395 */
376 value = apic_read(APIC_SPIV); 396 value = apic_read(APIC_SPIV);
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index a8a6aa70d695..13af920b6594 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -60,7 +60,7 @@ static struct console early_vga_console = {
60 .index = -1, 60 .index = -1,
61}; 61};
62 62
63/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */ 63/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
64 64
65static int early_serial_base = 0x3f8; /* ttyS0 */ 65static int early_serial_base = 0x3f8; /* ttyS0 */
66 66
@@ -80,30 +80,30 @@ static int early_serial_base = 0x3f8; /* ttyS0 */
80#define DLL 0 /* Divisor Latch Low */ 80#define DLL 0 /* Divisor Latch Low */
81#define DLH 1 /* Divisor latch High */ 81#define DLH 1 /* Divisor latch High */
82 82
83static int early_serial_putc(unsigned char ch) 83static int early_serial_putc(unsigned char ch)
84{ 84{
85 unsigned timeout = 0xffff; 85 unsigned timeout = 0xffff;
86 while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout) 86 while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
87 cpu_relax(); 87 cpu_relax();
88 outb(ch, early_serial_base + TXR); 88 outb(ch, early_serial_base + TXR);
89 return timeout ? 0 : -1; 89 return timeout ? 0 : -1;
90} 90}
91 91
92static void early_serial_write(struct console *con, const char *s, unsigned n) 92static void early_serial_write(struct console *con, const char *s, unsigned n)
93{ 93{
94 while (*s && n-- > 0) { 94 while (*s && n-- > 0) {
95 early_serial_putc(*s); 95 early_serial_putc(*s);
96 if (*s == '\n') 96 if (*s == '\n')
97 early_serial_putc('\r'); 97 early_serial_putc('\r');
98 s++; 98 s++;
99 } 99 }
100} 100}
101 101
102#define DEFAULT_BAUD 9600 102#define DEFAULT_BAUD 9600
103 103
104static __init void early_serial_init(char *s) 104static __init void early_serial_init(char *s)
105{ 105{
106 unsigned char c; 106 unsigned char c;
107 unsigned divisor; 107 unsigned divisor;
108 unsigned baud = DEFAULT_BAUD; 108 unsigned baud = DEFAULT_BAUD;
109 char *e; 109 char *e;
@@ -112,7 +112,7 @@ static __init void early_serial_init(char *s)
112 ++s; 112 ++s;
113 113
114 if (*s) { 114 if (*s) {
115 unsigned port; 115 unsigned port;
116 if (!strncmp(s,"0x",2)) { 116 if (!strncmp(s,"0x",2)) {
117 early_serial_base = simple_strtoul(s, &e, 16); 117 early_serial_base = simple_strtoul(s, &e, 16);
118 } else { 118 } else {
@@ -136,16 +136,16 @@ static __init void early_serial_init(char *s)
136 outb(0x3, early_serial_base + MCR); /* DTR + RTS */ 136 outb(0x3, early_serial_base + MCR); /* DTR + RTS */
137 137
138 if (*s) { 138 if (*s) {
139 baud = simple_strtoul(s, &e, 0); 139 baud = simple_strtoul(s, &e, 0);
140 if (baud == 0 || s == e) 140 if (baud == 0 || s == e)
141 baud = DEFAULT_BAUD; 141 baud = DEFAULT_BAUD;
142 } 142 }
143 143
144 divisor = 115200 / baud; 144 divisor = 115200 / baud;
145 c = inb(early_serial_base + LCR); 145 c = inb(early_serial_base + LCR);
146 outb(c | DLAB, early_serial_base + LCR); 146 outb(c | DLAB, early_serial_base + LCR);
147 outb(divisor & 0xff, early_serial_base + DLL); 147 outb(divisor & 0xff, early_serial_base + DLL);
148 outb((divisor >> 8) & 0xff, early_serial_base + DLH); 148 outb((divisor >> 8) & 0xff, early_serial_base + DLH);
149 outb(c & ~DLAB, early_serial_base + LCR); 149 outb(c & ~DLAB, early_serial_base + LCR);
150} 150}
151 151
@@ -202,68 +202,68 @@ struct console *early_console = &early_vga_console;
202static int early_console_initialized = 0; 202static int early_console_initialized = 0;
203 203
204void early_printk(const char *fmt, ...) 204void early_printk(const char *fmt, ...)
205{ 205{
206 char buf[512]; 206 char buf[512];
207 int n; 207 int n;
208 va_list ap; 208 va_list ap;
209 209
210 va_start(ap,fmt); 210 va_start(ap,fmt);
211 n = vscnprintf(buf,512,fmt,ap); 211 n = vscnprintf(buf,512,fmt,ap);
212 early_console->write(early_console,buf,n); 212 early_console->write(early_console,buf,n);
213 va_end(ap); 213 va_end(ap);
214} 214}
215 215
216static int __initdata keep_early; 216static int __initdata keep_early;
217 217
218int __init setup_early_printk(char *opt) 218int __init setup_early_printk(char *opt)
219{ 219{
220 char *space; 220 char *space;
221 char buf[256]; 221 char buf[256];
222 222
223 if (early_console_initialized) 223 if (early_console_initialized)
224 return -1; 224 return -1;
225 225
226 strlcpy(buf,opt,sizeof(buf)); 226 strlcpy(buf,opt,sizeof(buf));
227 space = strchr(buf, ' '); 227 space = strchr(buf, ' ');
228 if (space) 228 if (space)
229 *space = 0; 229 *space = 0;
230 230
231 if (strstr(buf,"keep")) 231 if (strstr(buf,"keep"))
232 keep_early = 1; 232 keep_early = 1;
233 233
234 if (!strncmp(buf, "serial", 6)) { 234 if (!strncmp(buf, "serial", 6)) {
235 early_serial_init(buf + 6); 235 early_serial_init(buf + 6);
236 early_console = &early_serial_console; 236 early_console = &early_serial_console;
237 } else if (!strncmp(buf, "ttyS", 4)) { 237 } else if (!strncmp(buf, "ttyS", 4)) {
238 early_serial_init(buf); 238 early_serial_init(buf);
239 early_console = &early_serial_console; 239 early_console = &early_serial_console;
240 } else if (!strncmp(buf, "vga", 3) 240 } else if (!strncmp(buf, "vga", 3)
241 && SCREEN_INFO.orig_video_isVGA == 1) { 241 && SCREEN_INFO.orig_video_isVGA == 1) {
242 max_xpos = SCREEN_INFO.orig_video_cols; 242 max_xpos = SCREEN_INFO.orig_video_cols;
243 max_ypos = SCREEN_INFO.orig_video_lines; 243 max_ypos = SCREEN_INFO.orig_video_lines;
244 current_ypos = SCREEN_INFO.orig_y; 244 current_ypos = SCREEN_INFO.orig_y;
245 early_console = &early_vga_console; 245 early_console = &early_vga_console;
246 } else if (!strncmp(buf, "simnow", 6)) { 246 } else if (!strncmp(buf, "simnow", 6)) {
247 simnow_init(buf + 6); 247 simnow_init(buf + 6);
248 early_console = &simnow_console; 248 early_console = &simnow_console;
249 keep_early = 1; 249 keep_early = 1;
250 } 250 }
251 early_console_initialized = 1; 251 early_console_initialized = 1;
252 register_console(early_console); 252 register_console(early_console);
253 return 0; 253 return 0;
254} 254}
255 255
256void __init disable_early_printk(void) 256void __init disable_early_printk(void)
257{ 257{
258 if (!early_console_initialized || !early_console) 258 if (!early_console_initialized || !early_console)
259 return; 259 return;
260 if (!keep_early) { 260 if (!keep_early) {
261 printk("disabling early console\n"); 261 printk("disabling early console\n");
262 unregister_console(early_console); 262 unregister_console(early_console);
263 early_console_initialized = 0; 263 early_console_initialized = 0;
264 } else { 264 } else {
265 printk("keeping early console\n"); 265 printk("keeping early console\n");
266 } 266 }
267} 267}
268 268
269__setup("earlyprintk=", setup_early_printk); 269__setup("earlyprintk=", setup_early_printk);
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 7c10e9009d61..8538bfea30e6 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -553,7 +553,7 @@ iret_label:
553 /* force a signal here? this matches i386 behaviour */ 553 /* force a signal here? this matches i386 behaviour */
554 /* running with kernel gs */ 554 /* running with kernel gs */
555bad_iret: 555bad_iret:
556 movq $-9999,%rdi /* better code? */ 556 movq $11,%rdi /* SIGSEGV */
557 sti 557 sti
558 jmp do_exit 558 jmp do_exit
559 .previous 559 .previous
diff --git a/arch/x86_64/kernel/functionlist b/arch/x86_64/kernel/functionlist
new file mode 100644
index 000000000000..2bcebdc3eedb
--- /dev/null
+++ b/arch/x86_64/kernel/functionlist
@@ -0,0 +1,1286 @@
1*(.text.flush_thread)
2*(.text.check_poison_obj)
3*(.text.copy_page)
4*(.text.__set_personality)
5*(.text.gart_map_sg)
6*(.text.kmem_cache_free)
7*(.text.find_get_page)
8*(.text._raw_spin_lock)
9*(.text.ide_outb)
10*(.text.unmap_vmas)
11*(.text.copy_page_range)
12*(.text.kprobe_handler)
13*(.text.__handle_mm_fault)
14*(.text.__d_lookup)
15*(.text.copy_user_generic)
16*(.text.__link_path_walk)
17*(.text.get_page_from_freelist)
18*(.text.kmem_cache_alloc)
19*(.text.drive_cmd_intr)
20*(.text.ia32_setup_sigcontext)
21*(.text.huge_pte_offset)
22*(.text.do_page_fault)
23*(.text.page_remove_rmap)
24*(.text.release_pages)
25*(.text.ide_end_request)
26*(.text.__mutex_lock_slowpath)
27*(.text.__find_get_block)
28*(.text.kfree)
29*(.text.vfs_read)
30*(.text._raw_spin_unlock)
31*(.text.free_hot_cold_page)
32*(.text.fget_light)
33*(.text.schedule)
34*(.text.memcmp)
35*(.text.touch_atime)
36*(.text.__might_sleep)
37*(.text.__down_read_trylock)
38*(.text.arch_pick_mmap_layout)
39*(.text.find_vma)
40*(.text.__make_request)
41*(.text.do_generic_mapping_read)
42*(.text.mutex_lock_interruptible)
43*(.text.__generic_file_aio_read)
44*(.text._atomic_dec_and_lock)
45*(.text.__wake_up_bit)
46*(.text.add_to_page_cache)
47*(.text.cache_alloc_debugcheck_after)
48*(.text.vm_normal_page)
49*(.text.mutex_debug_check_no_locks_freed)
50*(.text.net_rx_action)
51*(.text.__find_first_zero_bit)
52*(.text.put_page)
53*(.text._raw_read_lock)
54*(.text.__delay)
55*(.text.dnotify_parent)
56*(.text.do_path_lookup)
57*(.text.do_sync_read)
58*(.text.do_lookup)
59*(.text.bit_waitqueue)
60*(.text.file_read_actor)
61*(.text.strncpy_from_user)
62*(.text.__pagevec_lru_add_active)
63*(.text.fget)
64*(.text.dput)
65*(.text.__strnlen_user)
66*(.text.inotify_inode_queue_event)
67*(.text.rw_verify_area)
68*(.text.ide_intr)
69*(.text.inotify_dentry_parent_queue_event)
70*(.text.permission)
71*(.text.memscan)
72*(.text.hpet_rtc_interrupt)
73*(.text.do_mmap_pgoff)
74*(.text.current_fs_time)
75*(.text.vfs_getattr)
76*(.text.kmem_flagcheck)
77*(.text.mark_page_accessed)
78*(.text.free_pages_and_swap_cache)
79*(.text.generic_fillattr)
80*(.text.__block_prepare_write)
81*(.text.__set_page_dirty_nobuffers)
82*(.text.link_path_walk)
83*(.text.find_get_pages_tag)
84*(.text.ide_do_request)
85*(.text.__alloc_pages)
86*(.text.generic_permission)
87*(.text.mod_page_state_offset)
88*(.text.free_pgd_range)
89*(.text.generic_file_buffered_write)
90*(.text.number)
91*(.text.ide_do_rw_disk)
92*(.text.__brelse)
93*(.text.__mod_page_state_offset)
94*(.text.rotate_reclaimable_page)
95*(.text.find_vma_prepare)
96*(.text.find_vma_prev)
97*(.text.lru_cache_add_active)
98*(.text.__kmalloc_track_caller)
99*(.text.smp_invalidate_interrupt)
100*(.text.handle_IRQ_event)
101*(.text.__find_get_block_slow)
102*(.text.do_wp_page)
103*(.text.do_select)
104*(.text.set_user_nice)
105*(.text.sys_read)
106*(.text.do_munmap)
107*(.text.csum_partial)
108*(.text.__do_softirq)
109*(.text.may_open)
110*(.text.getname)
111*(.text.get_empty_filp)
112*(.text.__fput)
113*(.text.remove_mapping)
114*(.text.filp_ctor)
115*(.text.poison_obj)
116*(.text.unmap_region)
117*(.text.test_set_page_writeback)
118*(.text.__do_page_cache_readahead)
119*(.text.sock_def_readable)
120*(.text.ide_outl)
121*(.text.shrink_zone)
122*(.text.rb_insert_color)
123*(.text.get_request)
124*(.text.sys_pread64)
125*(.text.spin_bug)
126*(.text.ide_outsl)
127*(.text.mask_and_ack_8259A)
128*(.text.filemap_nopage)
129*(.text.page_add_file_rmap)
130*(.text.find_lock_page)
131*(.text.tcp_poll)
132*(.text.__mark_inode_dirty)
133*(.text.file_ra_state_init)
134*(.text.generic_file_llseek)
135*(.text.__pagevec_lru_add)
136*(.text.page_cache_readahead)
137*(.text.n_tty_receive_buf)
138*(.text.zonelist_policy)
139*(.text.vma_adjust)
140*(.text.test_clear_page_dirty)
141*(.text.sync_buffer)
142*(.text.do_exit)
143*(.text.__bitmap_weight)
144*(.text.alloc_pages_current)
145*(.text.get_unused_fd)
146*(.text.zone_watermark_ok)
147*(.text.cpuset_update_task_memory_state)
148*(.text.__bitmap_empty)
149*(.text.sys_munmap)
150*(.text.__inode_dir_notify)
151*(.text.__generic_file_aio_write_nolock)
152*(.text.__pte_alloc)
153*(.text.sys_select)
154*(.text.vm_acct_memory)
155*(.text.vfs_write)
156*(.text.__lru_add_drain)
157*(.text.prio_tree_insert)
158*(.text.generic_file_aio_read)
159*(.text.vma_merge)
160*(.text.block_write_full_page)
161*(.text.__page_set_anon_rmap)
162*(.text.apic_timer_interrupt)
163*(.text.release_console_sem)
164*(.text.sys_write)
165*(.text.sys_brk)
166*(.text.dup_mm)
167*(.text.read_current_timer)
168*(.text.ll_rw_block)
169*(.text.blk_rq_map_sg)
170*(.text.dbg_userword)
171*(.text.__block_commit_write)
172*(.text.cache_grow)
173*(.text.copy_strings)
174*(.text.release_task)
175*(.text.do_sync_write)
176*(.text.unlock_page)
177*(.text.load_elf_binary)
178*(.text.__follow_mount)
179*(.text.__getblk)
180*(.text.do_sys_open)
181*(.text.current_kernel_time)
182*(.text.call_rcu)
183*(.text.write_chan)
184*(.text.vsnprintf)
185*(.text.dummy_inode_setsecurity)
186*(.text.submit_bh)
187*(.text.poll_freewait)
188*(.text.bio_alloc_bioset)
189*(.text.skb_clone)
190*(.text.page_waitqueue)
191*(.text.__mutex_lock_interruptible_slowpath)
192*(.text.get_index)
193*(.text.csum_partial_copy_generic)
194*(.text.bad_range)
195*(.text.remove_vma)
196*(.text.cp_new_stat)
197*(.text.alloc_arraycache)
198*(.text.test_clear_page_writeback)
199*(.text.strsep)
200*(.text.open_namei)
201*(.text._raw_read_unlock)
202*(.text.get_vma_policy)
203*(.text.__down_write_trylock)
204*(.text.find_get_pages)
205*(.text.tcp_rcv_established)
206*(.text.generic_make_request)
207*(.text.__block_write_full_page)
208*(.text.cfq_set_request)
209*(.text.sys_inotify_init)
210*(.text.split_vma)
211*(.text.__mod_timer)
212*(.text.get_options)
213*(.text.vma_link)
214*(.text.mpage_writepages)
215*(.text.truncate_complete_page)
216*(.text.tcp_recvmsg)
217*(.text.sigprocmask)
218*(.text.filemap_populate)
219*(.text.sys_close)
220*(.text.inotify_dev_queue_event)
221*(.text.do_task_stat)
222*(.text.__dentry_open)
223*(.text.unlink_file_vma)
224*(.text.__pollwait)
225*(.text.packet_rcv_spkt)
226*(.text.drop_buffers)
227*(.text.free_pgtables)
228*(.text.generic_file_direct_write)
229*(.text.copy_process)
230*(.text.netif_receive_skb)
231*(.text.dnotify_flush)
232*(.text.print_bad_pte)
233*(.text.anon_vma_unlink)
234*(.text.sys_mprotect)
235*(.text.sync_sb_inodes)
236*(.text.find_inode_fast)
237*(.text.dummy_inode_readlink)
238*(.text.putname)
239*(.text.init_smp_flush)
240*(.text.dbg_redzone2)
241*(.text.sk_run_filter)
242*(.text.may_expand_vm)
243*(.text.generic_file_aio_write)
244*(.text.find_next_zero_bit)
245*(.text.file_kill)
246*(.text.audit_getname)
247*(.text.arch_unmap_area_topdown)
248*(.text.alloc_page_vma)
249*(.text.tcp_transmit_skb)
250*(.text.rb_next)
251*(.text.dbg_redzone1)
252*(.text.generic_file_mmap)
253*(.text.vfs_fstat)
254*(.text.sys_time)
255*(.text.page_lock_anon_vma)
256*(.text.get_unmapped_area)
257*(.text.remote_llseek)
258*(.text.__up_read)
259*(.text.fd_install)
260*(.text.eventpoll_init_file)
261*(.text.dma_alloc_coherent)
262*(.text.create_empty_buffers)
263*(.text.__mutex_unlock_slowpath)
264*(.text.dup_fd)
265*(.text.d_alloc)
266*(.text.tty_ldisc_try)
267*(.text.sys_stime)
268*(.text.__rb_rotate_right)
269*(.text.d_validate)
270*(.text.rb_erase)
271*(.text.path_release)
272*(.text.memmove)
273*(.text.invalidate_complete_page)
274*(.text.clear_inode)
275*(.text.cache_estimate)
276*(.text.alloc_buffer_head)
277*(.text.smp_call_function_interrupt)
278*(.text.flush_tlb_others)
279*(.text.file_move)
280*(.text.balance_dirty_pages_ratelimited)
281*(.text.vma_prio_tree_add)
282*(.text.timespec_trunc)
283*(.text.mempool_alloc)
284*(.text.iget_locked)
285*(.text.d_alloc_root)
286*(.text.cpuset_populate_dir)
287*(.text.anon_vma_prepare)
288*(.text.sys_newstat)
289*(.text.alloc_page_interleave)
290*(.text.__path_lookup_intent_open)
291*(.text.__pagevec_free)
292*(.text.inode_init_once)
293*(.text.free_vfsmnt)
294*(.text.__user_walk_fd)
295*(.text.cfq_idle_slice_timer)
296*(.text.sys_mmap)
297*(.text.sys_llseek)
298*(.text.prio_tree_remove)
299*(.text.filp_close)
300*(.text.file_permission)
301*(.text.vma_prio_tree_remove)
302*(.text.tcp_ack)
303*(.text.nameidata_to_filp)
304*(.text.sys_lseek)
305*(.text.percpu_counter_mod)
306*(.text.igrab)
307*(.text.__bread)
308*(.text.alloc_inode)
309*(.text.filldir)
310*(.text.__rb_rotate_left)
311*(.text.irq_affinity_write_proc)
312*(.text.init_request_from_bio)
313*(.text.find_or_create_page)
314*(.text.tty_poll)
315*(.text.tcp_sendmsg)
316*(.text.ide_wait_stat)
317*(.text.free_buffer_head)
318*(.text.flush_signal_handlers)
319*(.text.tcp_v4_rcv)
320*(.text.nr_blockdev_pages)
321*(.text.locks_remove_flock)
322*(.text.__iowrite32_copy)
323*(.text.do_filp_open)
324*(.text.try_to_release_page)
325*(.text.page_add_new_anon_rmap)
326*(.text.kmem_cache_size)
327*(.text.eth_type_trans)
328*(.text.try_to_free_buffers)
329*(.text.schedule_tail)
330*(.text.proc_lookup)
331*(.text.no_llseek)
332*(.text.kfree_skbmem)
333*(.text.do_wait)
334*(.text.do_mpage_readpage)
335*(.text.vfs_stat_fd)
336*(.text.tty_write)
337*(.text.705)
338*(.text.sync_page)
339*(.text.__remove_shared_vm_struct)
340*(.text.__kfree_skb)
341*(.text.sock_poll)
342*(.text.get_request_wait)
343*(.text.do_sigaction)
344*(.text.do_brk)
345*(.text.tcp_event_data_recv)
346*(.text.read_chan)
347*(.text.pipe_writev)
348*(.text.__emul_lookup_dentry)
349*(.text.rtc_get_rtc_time)
350*(.text.print_objinfo)
351*(.text.file_update_time)
352*(.text.do_signal)
353*(.text.disable_8259A_irq)
354*(.text.blk_queue_bounce)
355*(.text.__anon_vma_link)
356*(.text.__vma_link)
357*(.text.vfs_rename)
358*(.text.sys_newlstat)
359*(.text.sys_newfstat)
360*(.text.sys_mknod)
361*(.text.__show_regs)
362*(.text.iput)
363*(.text.get_signal_to_deliver)
364*(.text.flush_tlb_page)
365*(.text.debug_mutex_wake_waiter)
366*(.text.copy_thread)
367*(.text.clear_page_dirty_for_io)
368*(.text.buffer_io_error)
369*(.text.vfs_permission)
370*(.text.truncate_inode_pages_range)
371*(.text.sys_recvfrom)
372*(.text.remove_suid)
373*(.text.mark_buffer_dirty)
374*(.text.local_bh_enable)
375*(.text.get_zeroed_page)
376*(.text.get_vmalloc_info)
377*(.text.flush_old_exec)
378*(.text.dummy_inode_permission)
379*(.text.__bio_add_page)
380*(.text.prio_tree_replace)
381*(.text.notify_change)
382*(.text.mntput_no_expire)
383*(.text.fput)
384*(.text.__end_that_request_first)
385*(.text.wake_up_bit)
386*(.text.unuse_mm)
387*(.text.skb_release_data)
388*(.text.shrink_icache_memory)
389*(.text.sched_balance_self)
390*(.text.__pmd_alloc)
391*(.text.pipe_poll)
392*(.text.normal_poll)
393*(.text.__free_pages)
394*(.text.follow_mount)
395*(.text.cdrom_start_packet_command)
396*(.text.blk_recount_segments)
397*(.text.bio_put)
398*(.text.__alloc_skb)
399*(.text.__wake_up)
400*(.text.vm_stat_account)
401*(.text.sys_fcntl)
402*(.text.sys_fadvise64)
403*(.text._raw_write_unlock)
404*(.text.__pud_alloc)
405*(.text.alloc_page_buffers)
406*(.text.vfs_llseek)
407*(.text.sockfd_lookup)
408*(.text._raw_write_lock)
409*(.text.put_compound_page)
410*(.text.prune_dcache)
411*(.text.pipe_readv)
412*(.text.mempool_free)
413*(.text.make_ahead_window)
414*(.text.lru_add_drain)
415*(.text.constant_test_bit)
416*(.text.__clear_user)
417*(.text.arch_unmap_area)
418*(.text.anon_vma_link)
419*(.text.sys_chroot)
420*(.text.setup_arg_pages)
421*(.text.radix_tree_preload)
422*(.text.init_rwsem)
423*(.text.generic_osync_inode)
424*(.text.generic_delete_inode)
425*(.text.do_sys_poll)
426*(.text.dev_queue_xmit)
427*(.text.default_llseek)
428*(.text.__writeback_single_inode)
429*(.text.vfs_ioctl)
430*(.text.__up_write)
431*(.text.unix_poll)
432*(.text.sys_rt_sigprocmask)
433*(.text.sock_recvmsg)
434*(.text.recalc_bh_state)
435*(.text.__put_unused_fd)
436*(.text.process_backlog)
437*(.text.locks_remove_posix)
438*(.text.lease_modify)
439*(.text.expand_files)
440*(.text.end_buffer_read_nobh)
441*(.text.d_splice_alias)
442*(.text.debug_mutex_init_waiter)
443*(.text.copy_from_user)
444*(.text.cap_vm_enough_memory)
445*(.text.show_vfsmnt)
446*(.text.release_sock)
447*(.text.pfifo_fast_enqueue)
448*(.text.half_md4_transform)
449*(.text.fs_may_remount_ro)
450*(.text.do_fork)
451*(.text.copy_hugetlb_page_range)
452*(.text.cache_free_debugcheck)
453*(.text.__tcp_select_window)
454*(.text.task_handoff_register)
455*(.text.sys_open)
456*(.text.strlcpy)
457*(.text.skb_copy_datagram_iovec)
458*(.text.set_up_list3s)
459*(.text.release_open_intent)
460*(.text.qdisc_restart)
461*(.text.n_tty_chars_in_buffer)
462*(.text.inode_change_ok)
463*(.text.__downgrade_write)
464*(.text.debug_mutex_unlock)
465*(.text.add_timer_randomness)
466*(.text.sock_common_recvmsg)
467*(.text.set_bh_page)
468*(.text.printk_lock)
469*(.text.path_release_on_umount)
470*(.text.ip_output)
471*(.text.ide_build_dmatable)
472*(.text.__get_user_8)
473*(.text.end_buffer_read_sync)
474*(.text.__d_path)
475*(.text.d_move)
476*(.text.del_timer)
477*(.text.constant_test_bit)
478*(.text.blockable_page_cache_readahead)
479*(.text.tty_read)
480*(.text.sys_readlink)
481*(.text.sys_faccessat)
482*(.text.read_swap_cache_async)
483*(.text.pty_write_room)
484*(.text.page_address_in_vma)
485*(.text.kthread)
486*(.text.cfq_exit_io_context)
487*(.text.__tcp_push_pending_frames)
488*(.text.sys_pipe)
489*(.text.submit_bio)
490*(.text.pid_revalidate)
491*(.text.page_referenced_file)
492*(.text.lock_sock)
493*(.text.get_page_state_node)
494*(.text.generic_block_bmap)
495*(.text.do_setitimer)
496*(.text.dev_queue_xmit_nit)
497*(.text.copy_from_read_buf)
498*(.text.__const_udelay)
499*(.text.console_conditional_schedule)
500*(.text.wake_up_new_task)
501*(.text.wait_for_completion_interruptible)
502*(.text.tcp_rcv_rtt_update)
503*(.text.sys_mlockall)
504*(.text.set_fs_altroot)
505*(.text.schedule_timeout)
506*(.text.nr_free_pagecache_pages)
507*(.text.nf_iterate)
508*(.text.mapping_tagged)
509*(.text.ip_queue_xmit)
510*(.text.ip_local_deliver)
511*(.text.follow_page)
512*(.text.elf_map)
513*(.text.dummy_file_permission)
514*(.text.dispose_list)
515*(.text.dentry_open)
516*(.text.dentry_iput)
517*(.text.bio_alloc)
518*(.text.alloc_skb_from_cache)
519*(.text.wait_on_page_bit)
520*(.text.vfs_readdir)
521*(.text.vfs_lstat)
522*(.text.seq_escape)
523*(.text.__posix_lock_file)
524*(.text.mm_release)
525*(.text.kref_put)
526*(.text.ip_rcv)
527*(.text.__iget)
528*(.text.free_pages)
529*(.text.find_mergeable_anon_vma)
530*(.text.find_extend_vma)
531*(.text.dummy_inode_listsecurity)
532*(.text.bio_add_page)
533*(.text.__vm_enough_memory)
534*(.text.vfs_stat)
535*(.text.tty_paranoia_check)
536*(.text.tcp_read_sock)
537*(.text.tcp_data_queue)
538*(.text.sys_uname)
539*(.text.sys_renameat)
540*(.text.__strncpy_from_user)
541*(.text.__mutex_init)
542*(.text.__lookup_hash)
543*(.text.kref_get)
544*(.text.ip_route_input)
545*(.text.__insert_inode_hash)
546*(.text.do_sock_write)
547*(.text.blk_done_softirq)
548*(.text.__wake_up_sync)
549*(.text.__vma_link_rb)
550*(.text.tty_ioctl)
551*(.text.tracesys)
552*(.text.sys_getdents)
553*(.text.sys_dup)
554*(.text.stub_execve)
555*(.text.sha_transform)
556*(.text.radix_tree_tag_clear)
557*(.text.put_unused_fd)
558*(.text.put_files_struct)
559*(.text.mpage_readpages)
560*(.text.may_delete)
561*(.text.kmem_cache_create)
562*(.text.ip_mc_output)
563*(.text.interleave_nodes)
564*(.text.groups_search)
565*(.text.generic_drop_inode)
566*(.text.generic_commit_write)
567*(.text.fcntl_setlk)
568*(.text.exit_mmap)
569*(.text.end_page_writeback)
570*(.text.__d_rehash)
571*(.text.debug_mutex_free_waiter)
572*(.text.csum_ipv6_magic)
573*(.text.count)
574*(.text.cleanup_rbuf)
575*(.text.check_spinlock_acquired_node)
576*(.text.can_vma_merge_after)
577*(.text.bio_endio)
578*(.text.alloc_pidmap)
579*(.text.write_ldt)
580*(.text.vmtruncate_range)
581*(.text.vfs_create)
582*(.text.__user_walk)
583*(.text.update_send_head)
584*(.text.unmap_underlying_metadata)
585*(.text.tty_ldisc_deref)
586*(.text.tcp_setsockopt)
587*(.text.tcp_send_ack)
588*(.text.sys_pause)
589*(.text.sys_gettimeofday)
590*(.text.sync_dirty_buffer)
591*(.text.strncmp)
592*(.text.release_posix_timer)
593*(.text.proc_file_read)
594*(.text.prepare_to_wait)
595*(.text.locks_mandatory_locked)
596*(.text.interruptible_sleep_on_timeout)
597*(.text.inode_sub_bytes)
598*(.text.in_group_p)
599*(.text.hrtimer_try_to_cancel)
600*(.text.filldir64)
601*(.text.fasync_helper)
602*(.text.dummy_sb_pivotroot)
603*(.text.d_lookup)
604*(.text.d_instantiate)
605*(.text.__d_find_alias)
606*(.text.cpu_idle_wait)
607*(.text.cond_resched_lock)
608*(.text.chown_common)
609*(.text.blk_congestion_wait)
610*(.text.activate_page)
611*(.text.unlock_buffer)
612*(.text.tty_wakeup)
613*(.text.tcp_v4_do_rcv)
614*(.text.tcp_current_mss)
615*(.text.sys_openat)
616*(.text.sys_fchdir)
617*(.text.strnlen_user)
618*(.text.strnlen)
619*(.text.strchr)
620*(.text.sock_common_getsockopt)
621*(.text.skb_checksum)
622*(.text.remove_wait_queue)
623*(.text.rb_replace_node)
624*(.text.radix_tree_node_ctor)
625*(.text.pty_chars_in_buffer)
626*(.text.profile_hit)
627*(.text.prio_tree_left)
628*(.text.pgd_clear_bad)
629*(.text.pfifo_fast_dequeue)
630*(.text.page_referenced)
631*(.text.open_exec)
632*(.text.mmput)
633*(.text.mm_init)
634*(.text.__ide_dma_off_quietly)
635*(.text.ide_dma_intr)
636*(.text.hrtimer_start)
637*(.text.get_io_context)
638*(.text.__get_free_pages)
639*(.text.find_first_zero_bit)
640*(.text.file_free_rcu)
641*(.text.dummy_socket_sendmsg)
642*(.text.do_unlinkat)
643*(.text.do_arch_prctl)
644*(.text.destroy_inode)
645*(.text.can_vma_merge_before)
646*(.text.block_sync_page)
647*(.text.block_prepare_write)
648*(.text.bio_init)
649*(.text.arch_ptrace)
650*(.text.wake_up_inode)
651*(.text.wait_on_retry_sync_kiocb)
652*(.text.vma_prio_tree_next)
653*(.text.tcp_rcv_space_adjust)
654*(.text.__tcp_ack_snd_check)
655*(.text.sys_utime)
656*(.text.sys_recvmsg)
657*(.text.sys_mremap)
658*(.text.sys_bdflush)
659*(.text.sleep_on)
660*(.text.set_page_dirty_lock)
661*(.text.seq_path)
662*(.text.schedule_timeout_interruptible)
663*(.text.sched_fork)
664*(.text.rt_run_flush)
665*(.text.profile_munmap)
666*(.text.prepare_binprm)
667*(.text.__pagevec_release_nonlru)
668*(.text.m_show)
669*(.text.lookup_mnt)
670*(.text.__lookup_mnt)
671*(.text.lock_timer_base)
672*(.text.is_subdir)
673*(.text.invalidate_bh_lru)
674*(.text.init_buffer_head)
675*(.text.ifind_fast)
676*(.text.ide_dma_start)
677*(.text.__get_page_state)
678*(.text.flock_to_posix_lock)
679*(.text.__find_symbol)
680*(.text.do_futex)
681*(.text.do_execve)
682*(.text.dirty_writeback_centisecs_handler)
683*(.text.dev_watchdog)
684*(.text.can_share_swap_page)
685*(.text.blkdev_put)
686*(.text.bio_get_nr_vecs)
687*(.text.xfrm_compile_policy)
688*(.text.vma_prio_tree_insert)
689*(.text.vfs_lstat_fd)
690*(.text.__user_path_lookup_open)
691*(.text.thread_return)
692*(.text.tcp_send_delayed_ack)
693*(.text.sock_def_error_report)
694*(.text.shrink_slab)
695*(.text.serial_out)
696*(.text.seq_read)
697*(.text.secure_ip_id)
698*(.text.search_binary_handler)
699*(.text.proc_pid_unhash)
700*(.text.pagevec_lookup)
701*(.text.new_inode)
702*(.text.memcpy_toiovec)
703*(.text.locks_free_lock)
704*(.text.__lock_page)
705*(.text.__lock_buffer)
706*(.text.load_module)
707*(.text.is_bad_inode)
708*(.text.invalidate_inode_buffers)
709*(.text.insert_vm_struct)
710*(.text.inode_setattr)
711*(.text.inode_add_bytes)
712*(.text.ide_read_24)
713*(.text.ide_get_error_location)
714*(.text.ide_do_drive_cmd)
715*(.text.get_locked_pte)
716*(.text.get_filesystem_list)
717*(.text.generic_file_open)
718*(.text.follow_down)
719*(.text.find_next_bit)
720*(.text.__find_first_bit)
721*(.text.exit_mm)
722*(.text.exec_keys)
723*(.text.end_buffer_write_sync)
724*(.text.end_bio_bh_io_sync)
725*(.text.dummy_socket_shutdown)
726*(.text.d_rehash)
727*(.text.d_path)
728*(.text.do_ioctl)
729*(.text.dget_locked)
730*(.text.copy_thread_group_keys)
731*(.text.cdrom_end_request)
732*(.text.cap_bprm_apply_creds)
733*(.text.blk_rq_bio_prep)
734*(.text.__bitmap_intersects)
735*(.text.bio_phys_segments)
736*(.text.bio_free)
737*(.text.arch_get_unmapped_area_topdown)
738*(.text.writeback_in_progress)
739*(.text.vfs_follow_link)
740*(.text.tcp_rcv_state_process)
741*(.text.tcp_check_space)
742*(.text.sys_stat)
743*(.text.sys_rt_sigreturn)
744*(.text.sys_rt_sigaction)
745*(.text.sys_remap_file_pages)
746*(.text.sys_pwrite64)
747*(.text.sys_fchownat)
748*(.text.sys_fchmodat)
749*(.text.strncat)
750*(.text.strlcat)
751*(.text.strcmp)
752*(.text.steal_locks)
753*(.text.sock_create)
754*(.text.sk_stream_rfree)
755*(.text.sk_stream_mem_schedule)
756*(.text.skip_atoi)
757*(.text.sk_alloc)
758*(.text.show_stat)
759*(.text.set_fs_pwd)
760*(.text.set_binfmt)
761*(.text.pty_unthrottle)
762*(.text.proc_symlink)
763*(.text.pipe_release)
764*(.text.pageout)
765*(.text.n_tty_write_wakeup)
766*(.text.n_tty_ioctl)
767*(.text.nr_free_zone_pages)
768*(.text.migration_thread)
769*(.text.mempool_free_slab)
770*(.text.meminfo_read_proc)
771*(.text.max_sane_readahead)
772*(.text.lru_cache_add)
773*(.text.kill_fasync)
774*(.text.kernel_read)
775*(.text.invalidate_mapping_pages)
776*(.text.inode_has_buffers)
777*(.text.init_once)
778*(.text.inet_sendmsg)
779*(.text.idedisk_issue_flush)
780*(.text.generic_file_write)
781*(.text.free_more_memory)
782*(.text.__free_fdtable)
783*(.text.filp_dtor)
784*(.text.exit_sem)
785*(.text.exit_itimers)
786*(.text.error_interrupt)
787*(.text.end_buffer_async_write)
788*(.text.eligible_child)
789*(.text.elf_map)
790*(.text.dump_task_regs)
791*(.text.dummy_task_setscheduler)
792*(.text.dummy_socket_accept)
793*(.text.dummy_file_free_security)
794*(.text.__down_read)
795*(.text.do_sock_read)
796*(.text.do_sigaltstack)
797*(.text.do_mremap)
798*(.text.current_io_context)
799*(.text.cpu_swap_callback)
800*(.text.copy_vma)
801*(.text.cap_bprm_set_security)
802*(.text.blk_insert_request)
803*(.text.bio_map_kern_endio)
804*(.text.bio_hw_segments)
805*(.text.bictcp_cong_avoid)
806*(.text.add_interrupt_randomness)
807*(.text.wait_for_completion)
808*(.text.version_read_proc)
809*(.text.unix_write_space)
810*(.text.tty_ldisc_ref_wait)
811*(.text.tty_ldisc_put)
812*(.text.try_to_wake_up)
813*(.text.tcp_v4_tw_remember_stamp)
814*(.text.tcp_try_undo_dsack)
815*(.text.tcp_may_send_now)
816*(.text.sys_waitid)
817*(.text.sys_sched_getparam)
818*(.text.sys_getppid)
819*(.text.sys_getcwd)
820*(.text.sys_dup2)
821*(.text.sys_chmod)
822*(.text.sys_chdir)
823*(.text.sprintf)
824*(.text.sock_wfree)
825*(.text.sock_aio_write)
826*(.text.skb_drop_fraglist)
827*(.text.skb_dequeue)
828*(.text.set_close_on_exec)
829*(.text.set_brk)
830*(.text.seq_puts)
831*(.text.SELECT_DRIVE)
832*(.text.sched_exec)
833*(.text.return_EIO)
834*(.text.remove_from_page_cache)
835*(.text.rcu_start_batch)
836*(.text.__put_task_struct)
837*(.text.proc_pid_readdir)
838*(.text.proc_get_inode)
839*(.text.prepare_to_wait_exclusive)
840*(.text.pipe_wait)
841*(.text.pipe_new)
842*(.text.pdflush_operation)
843*(.text.__pagevec_release)
844*(.text.pagevec_lookup_tag)
845*(.text.packet_rcv)
846*(.text.n_tty_set_room)
847*(.text.nr_free_pages)
848*(.text.__net_timestamp)
849*(.text.mpage_end_io_read)
850*(.text.mod_timer)
851*(.text.__memcpy)
852*(.text.mb_cache_shrink_fn)
853*(.text.lock_rename)
854*(.text.kstrdup)
855*(.text.is_ignored)
856*(.text.int_very_careful)
857*(.text.inotify_inode_is_dead)
858*(.text.inotify_get_cookie)
859*(.text.inode_get_bytes)
860*(.text.init_timer)
861*(.text.init_dev)
862*(.text.inet_getname)
863*(.text.ide_map_sg)
864*(.text.__ide_dma_end)
865*(.text.hrtimer_get_remaining)
866*(.text.get_task_mm)
867*(.text.get_random_int)
868*(.text.free_pipe_info)
869*(.text.filemap_write_and_wait_range)
870*(.text.exit_thread)
871*(.text.enter_idle)
872*(.text.end_that_request_first)
873*(.text.end_8259A_irq)
874*(.text.dummy_file_alloc_security)
875*(.text.do_group_exit)
876*(.text.debug_mutex_init)
877*(.text.cpuset_exit)
878*(.text.cpu_idle)
879*(.text.copy_semundo)
880*(.text.copy_files)
881*(.text.chrdev_open)
882*(.text.cdrom_transfer_packet_command)
883*(.text.cdrom_mode_sense)
884*(.text.blk_phys_contig_segment)
885*(.text.blk_get_queue)
886*(.text.bio_split)
887*(.text.audit_alloc)
888*(.text.anon_pipe_buf_release)
889*(.text.add_wait_queue_exclusive)
890*(.text.add_wait_queue)
891*(.text.acct_process)
892*(.text.account)
893*(.text.zeromap_page_range)
894*(.text.yield)
895*(.text.writeback_acquire)
896*(.text.worker_thread)
897*(.text.wait_on_page_writeback_range)
898*(.text.__wait_on_buffer)
899*(.text.vscnprintf)
900*(.text.vmalloc_to_pfn)
901*(.text.vgacon_save_screen)
902*(.text.vfs_unlink)
903*(.text.vfs_rmdir)
904*(.text.unregister_md_personality)
905*(.text.unlock_new_inode)
906*(.text.unix_stream_sendmsg)
907*(.text.unix_stream_recvmsg)
908*(.text.unhash_process)
909*(.text.udp_v4_lookup_longway)
910*(.text.tty_ldisc_flush)
911*(.text.tty_ldisc_enable)
912*(.text.tty_hung_up_p)
913*(.text.tty_buffer_free_all)
914*(.text.tso_fragment)
915*(.text.try_to_del_timer_sync)
916*(.text.tcp_v4_err)
917*(.text.tcp_unhash)
918*(.text.tcp_seq_next)
919*(.text.tcp_select_initial_window)
920*(.text.tcp_sacktag_write_queue)
921*(.text.tcp_cwnd_validate)
922*(.text.sys_vhangup)
923*(.text.sys_uselib)
924*(.text.sys_symlink)
925*(.text.sys_signal)
926*(.text.sys_poll)
927*(.text.sys_mount)
928*(.text.sys_kill)
929*(.text.sys_ioctl)
930*(.text.sys_inotify_add_watch)
931*(.text.sys_getuid)
932*(.text.sys_getrlimit)
933*(.text.sys_getitimer)
934*(.text.sys_getgroups)
935*(.text.sys_ftruncate)
936*(.text.sysfs_lookup)
937*(.text.sys_exit_group)
938*(.text.stub_fork)
939*(.text.sscanf)
940*(.text.sock_map_fd)
941*(.text.sock_get_timestamp)
942*(.text.__sock_create)
943*(.text.smp_call_function_single)
944*(.text.sk_stop_timer)
945*(.text.skb_copy_and_csum_datagram)
946*(.text.__skb_checksum_complete)
947*(.text.single_next)
948*(.text.sigqueue_alloc)
949*(.text.shrink_dcache_parent)
950*(.text.select_idle_routine)
951*(.text.run_workqueue)
952*(.text.run_local_timers)
953*(.text.remove_inode_hash)
954*(.text.remove_dquot_ref)
955*(.text.register_binfmt)
956*(.text.read_cache_pages)
957*(.text.rb_last)
958*(.text.pty_open)
959*(.text.proc_root_readdir)
960*(.text.proc_pid_flush)
961*(.text.proc_pident_lookup)
962*(.text.proc_fill_super)
963*(.text.proc_exe_link)
964*(.text.posix_locks_deadlock)
965*(.text.pipe_iov_copy_from_user)
966*(.text.opost)
967*(.text.nf_register_hook)
968*(.text.netif_rx_ni)
969*(.text.m_start)
970*(.text.mpage_writepage)
971*(.text.mm_alloc)
972*(.text.memory_open)
973*(.text.mark_buffer_async_write)
974*(.text.lru_add_drain_all)
975*(.text.locks_init_lock)
976*(.text.locks_delete_lock)
977*(.text.lock_hrtimer_base)
978*(.text.load_script)
979*(.text.__kill_fasync)
980*(.text.ip_mc_sf_allow)
981*(.text.__ioremap)
982*(.text.int_with_check)
983*(.text.int_sqrt)
984*(.text.install_thread_keyring)
985*(.text.init_page_buffers)
986*(.text.inet_sock_destruct)
987*(.text.idle_notifier_register)
988*(.text.ide_execute_command)
989*(.text.ide_end_drive_cmd)
990*(.text.__ide_dma_host_on)
991*(.text.hrtimer_run_queues)
992*(.text.hpet_mask_rtc_irq_bit)
993*(.text.__get_zone_counts)
994*(.text.get_zone_counts)
995*(.text.get_write_access)
996*(.text.get_fs_struct)
997*(.text.get_dirty_limits)
998*(.text.generic_readlink)
999*(.text.free_hot_page)
1000*(.text.finish_wait)
1001*(.text.find_inode)
1002*(.text.find_first_bit)
1003*(.text.__filemap_fdatawrite_range)
1004*(.text.__filemap_copy_from_user_iovec)
1005*(.text.exit_aio)
1006*(.text.elv_set_request)
1007*(.text.elv_former_request)
1008*(.text.dup_namespace)
1009*(.text.dupfd)
1010*(.text.dummy_socket_getsockopt)
1011*(.text.dummy_sb_post_mountroot)
1012*(.text.dummy_quotactl)
1013*(.text.dummy_inode_rename)
1014*(.text.__do_SAK)
1015*(.text.do_pipe)
1016*(.text.do_fsync)
1017*(.text.d_instantiate_unique)
1018*(.text.d_find_alias)
1019*(.text.deny_write_access)
1020*(.text.dentry_unhash)
1021*(.text.d_delete)
1022*(.text.datagram_poll)
1023*(.text.cpuset_fork)
1024*(.text.cpuid_read)
1025*(.text.copy_namespace)
1026*(.text.cond_resched)
1027*(.text.check_version)
1028*(.text.__change_page_attr)
1029*(.text.cfq_slab_kill)
1030*(.text.cfq_completed_request)
1031*(.text.cdrom_pc_intr)
1032*(.text.cdrom_decode_status)
1033*(.text.cap_capset_check)
1034*(.text.blk_put_request)
1035*(.text.bio_fs_destructor)
1036*(.text.bictcp_min_cwnd)
1037*(.text.alloc_chrdev_region)
1038*(.text.add_element)
1039*(.text.acct_update_integrals)
1040*(.text.write_boundary_block)
1041*(.text.writeback_release)
1042*(.text.writeback_inodes)
1043*(.text.wake_up_state)
1044*(.text.__wake_up_locked)
1045*(.text.wake_futex)
1046*(.text.wait_task_inactive)
1047*(.text.__wait_on_freeing_inode)
1048*(.text.wait_noreap_copyout)
1049*(.text.vmstat_start)
1050*(.text.vgacon_do_font_op)
1051*(.text.vfs_readv)
1052*(.text.vfs_quota_sync)
1053*(.text.update_queue)
1054*(.text.unshare_files)
1055*(.text.unmap_vm_area)
1056*(.text.unix_socketpair)
1057*(.text.unix_release_sock)
1058*(.text.unix_detach_fds)
1059*(.text.unix_create1)
1060*(.text.unix_bind)
1061*(.text.udp_sendmsg)
1062*(.text.udp_rcv)
1063*(.text.udp_queue_rcv_skb)
1064*(.text.uart_write)
1065*(.text.uart_startup)
1066*(.text.uart_open)
1067*(.text.tty_vhangup)
1068*(.text.tty_termios_baud_rate)
1069*(.text.tty_release)
1070*(.text.tty_ldisc_ref)
1071*(.text.throttle_vm_writeout)
1072*(.text.058)
1073*(.text.tcp_xmit_probe_skb)
1074*(.text.tcp_v4_send_check)
1075*(.text.tcp_v4_destroy_sock)
1076*(.text.tcp_sync_mss)
1077*(.text.tcp_snd_test)
1078*(.text.tcp_slow_start)
1079*(.text.tcp_send_fin)
1080*(.text.tcp_rtt_estimator)
1081*(.text.tcp_parse_options)
1082*(.text.tcp_ioctl)
1083*(.text.tcp_init_tso_segs)
1084*(.text.tcp_init_cwnd)
1085*(.text.tcp_getsockopt)
1086*(.text.tcp_fin)
1087*(.text.tcp_connect)
1088*(.text.tcp_cong_avoid)
1089*(.text.__tcp_checksum_complete_user)
1090*(.text.task_dumpable)
1091*(.text.sys_wait4)
1092*(.text.sys_utimes)
1093*(.text.sys_symlinkat)
1094*(.text.sys_socketpair)
1095*(.text.sys_rmdir)
1096*(.text.sys_readahead)
1097*(.text.sys_nanosleep)
1098*(.text.sys_linkat)
1099*(.text.sys_fstat)
1100*(.text.sysfs_readdir)
1101*(.text.sys_execve)
1102*(.text.sysenter_tracesys)
1103*(.text.sys_chown)
1104*(.text.stub_clone)
1105*(.text.strrchr)
1106*(.text.strncpy)
1107*(.text.stopmachine_set_state)
1108*(.text.sock_sendmsg)
1109*(.text.sock_release)
1110*(.text.sock_fasync)
1111*(.text.sock_close)
1112*(.text.sk_stream_write_space)
1113*(.text.sk_reset_timer)
1114*(.text.skb_split)
1115*(.text.skb_recv_datagram)
1116*(.text.skb_queue_tail)
1117*(.text.sk_attach_filter)
1118*(.text.si_swapinfo)
1119*(.text.simple_strtoll)
1120*(.text.set_termios)
1121*(.text.set_task_comm)
1122*(.text.set_shrinker)
1123*(.text.set_normalized_timespec)
1124*(.text.set_brk)
1125*(.text.serial_in)
1126*(.text.seq_printf)
1127*(.text.secure_dccp_sequence_number)
1128*(.text.rwlock_bug)
1129*(.text.rt_hash_code)
1130*(.text.__rta_fill)
1131*(.text.__request_resource)
1132*(.text.relocate_new_kernel)
1133*(.text.release_thread)
1134*(.text.release_mem)
1135*(.text.rb_prev)
1136*(.text.rb_first)
1137*(.text.random_poll)
1138*(.text.__put_super_and_need_restart)
1139*(.text.pty_write)
1140*(.text.ptrace_stop)
1141*(.text.proc_self_readlink)
1142*(.text.proc_root_lookup)
1143*(.text.proc_root_link)
1144*(.text.proc_pid_make_inode)
1145*(.text.proc_pid_attr_write)
1146*(.text.proc_lookupfd)
1147*(.text.proc_delete_inode)
1148*(.text.posix_same_owner)
1149*(.text.posix_block_lock)
1150*(.text.poll_initwait)
1151*(.text.pipe_write)
1152*(.text.pipe_read_fasync)
1153*(.text.pipe_ioctl)
1154*(.text.pdflush)
1155*(.text.pci_user_read_config_dword)
1156*(.text.page_readlink)
1157*(.text.null_lseek)
1158*(.text.nf_hook_slow)
1159*(.text.netlink_sock_destruct)
1160*(.text.netlink_broadcast)
1161*(.text.neigh_resolve_output)
1162*(.text.name_to_int)
1163*(.text.mwait_idle)
1164*(.text.mutex_trylock)
1165*(.text.mutex_debug_check_no_locks_held)
1166*(.text.m_stop)
1167*(.text.mpage_end_io_write)
1168*(.text.mpage_alloc)
1169*(.text.move_page_tables)
1170*(.text.mounts_open)
1171*(.text.__memset)
1172*(.text.memcpy_fromiovec)
1173*(.text.make_8259A_irq)
1174*(.text.lookup_user_key_possessed)
1175*(.text.lookup_create)
1176*(.text.locks_insert_lock)
1177*(.text.locks_alloc_lock)
1178*(.text.kthread_should_stop)
1179*(.text.kswapd)
1180*(.text.kobject_uevent)
1181*(.text.kobject_get_path)
1182*(.text.kobject_get)
1183*(.text.klist_children_put)
1184*(.text.__ip_route_output_key)
1185*(.text.ip_flush_pending_frames)
1186*(.text.ip_compute_csum)
1187*(.text.ip_append_data)
1188*(.text.ioc_set_batching)
1189*(.text.invalidate_inode_pages)
1190*(.text.__invalidate_device)
1191*(.text.install_arg_page)
1192*(.text.in_sched_functions)
1193*(.text.inotify_unmount_inodes)
1194*(.text.init_once)
1195*(.text.init_cdrom_command)
1196*(.text.inet_stream_connect)
1197*(.text.inet_sk_rebuild_header)
1198*(.text.inet_csk_addr2sockaddr)
1199*(.text.inet_create)
1200*(.text.ifind)
1201*(.text.ide_setup_dma)
1202*(.text.ide_outsw)
1203*(.text.ide_fixstring)
1204*(.text.ide_dma_setup)
1205*(.text.ide_cdrom_packet)
1206*(.text.ide_cd_put)
1207*(.text.ide_build_sglist)
1208*(.text.i8259A_shutdown)
1209*(.text.hung_up_tty_ioctl)
1210*(.text.hrtimer_nanosleep)
1211*(.text.hrtimer_init)
1212*(.text.hrtimer_cancel)
1213*(.text.hash_futex)
1214*(.text.group_send_sig_info)
1215*(.text.grab_cache_page_nowait)
1216*(.text.get_wchan)
1217*(.text.get_stack)
1218*(.text.get_page_state)
1219*(.text.getnstimeofday)
1220*(.text.get_node)
1221*(.text.get_kprobe)
1222*(.text.generic_unplug_device)
1223*(.text.free_task)
1224*(.text.frag_show)
1225*(.text.find_next_zero_string)
1226*(.text.filp_open)
1227*(.text.fillonedir)
1228*(.text.exit_io_context)
1229*(.text.exit_idle)
1230*(.text.exact_lock)
1231*(.text.eth_header)
1232*(.text.dummy_unregister_security)
1233*(.text.dummy_socket_post_create)
1234*(.text.dummy_socket_listen)
1235*(.text.dummy_quota_on)
1236*(.text.dummy_inode_follow_link)
1237*(.text.dummy_file_receive)
1238*(.text.dummy_file_mprotect)
1239*(.text.dummy_file_lock)
1240*(.text.dummy_file_ioctl)
1241*(.text.dummy_bprm_post_apply_creds)
1242*(.text.do_writepages)
1243*(.text.__down_interruptible)
1244*(.text.do_notify_resume)
1245*(.text.do_acct_process)
1246*(.text.del_timer_sync)
1247*(.text.default_rebuild_header)
1248*(.text.d_callback)
1249*(.text.dcache_readdir)
1250*(.text.ctrl_dumpfamily)
1251*(.text.cpuset_rmdir)
1252*(.text.copy_strings_kernel)
1253*(.text.con_write_room)
1254*(.text.complete_all)
1255*(.text.collect_sigign_sigcatch)
1256*(.text.clear_user)
1257*(.text.check_unthrottle)
1258*(.text.cdrom_release)
1259*(.text.cdrom_newpc_intr)
1260*(.text.cdrom_ioctl)
1261*(.text.cdrom_check_status)
1262*(.text.cdev_put)
1263*(.text.cdev_add)
1264*(.text.cap_ptrace)
1265*(.text.cap_bprm_secureexec)
1266*(.text.cache_alloc_refill)
1267*(.text.bmap)
1268*(.text.blk_run_queue)
1269*(.text.blk_queue_dma_alignment)
1270*(.text.blk_ordered_req_seq)
1271*(.text.blk_backing_dev_unplug)
1272*(.text.__bitmap_subset)
1273*(.text.__bitmap_and)
1274*(.text.bio_unmap_user)
1275*(.text.__bforget)
1276*(.text.bd_forget)
1277*(.text.bad_pipe_w)
1278*(.text.bad_get_user)
1279*(.text.audit_free)
1280*(.text.anon_vma_ctor)
1281*(.text.anon_pipe_buf_map)
1282*(.text.alloc_sock_iocb)
1283*(.text.alloc_fdset)
1284*(.text.aio_kick_handler)
1285*(.text.__add_entropy_words)
1286*(.text.add_disk_randomness)
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 02fc7fa0ea28..6df05e6034fa 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28 .text 28 .text
29 .section .bootstrap.text
29 .code32 30 .code32
30 .globl startup_32 31 .globl startup_32
31/* %bx: 1 if coming from smp trampoline on secondary cpu */ 32/* %bx: 1 if coming from smp trampoline on secondary cpu */
@@ -192,7 +193,8 @@ startup_64:
192 movq initial_code(%rip),%rax 193 movq initial_code(%rip),%rax
193 jmp *%rax 194 jmp *%rax
194 195
195 /* SMP bootup changes these two */ 196 /* SMP bootup changes these two */
197 .align 8
196 .globl initial_code 198 .globl initial_code
197initial_code: 199initial_code:
198 .quad x86_64_start_kernel 200 .quad x86_64_start_kernel
@@ -237,7 +239,7 @@ ENTRY(no_long_mode)
237.org 0xf00 239.org 0xf00
238 .globl pGDT32 240 .globl pGDT32
239pGDT32: 241pGDT32:
240 .word gdt_end-cpu_gdt_table 242 .word gdt_end-cpu_gdt_table-1
241 .long cpu_gdt_table-__START_KERNEL_map 243 .long cpu_gdt_table-__START_KERNEL_map
242 244
243.org 0xf10 245.org 0xf10
@@ -293,8 +295,6 @@ NEXT_PAGE(level2_kernel_pgt)
293 /* Module mapping starts here */ 295 /* Module mapping starts here */
294 .fill 492,8,0 296 .fill 492,8,0
295 297
296NEXT_PAGE(empty_zero_page)
297
298NEXT_PAGE(level3_physmem_pgt) 298NEXT_PAGE(level3_physmem_pgt)
299 .quad phys_level2_kernel_pgt | 0x007 /* so that __va works even before pagetable_init */ 299 .quad phys_level2_kernel_pgt | 0x007 /* so that __va works even before pagetable_init */
300 .fill 511,8,0 300 .fill 511,8,0
@@ -337,7 +337,7 @@ ENTRY(boot_level4_pgt)
337 .align 16 337 .align 16
338 .globl cpu_gdt_descr 338 .globl cpu_gdt_descr
339cpu_gdt_descr: 339cpu_gdt_descr:
340 .word gdt_end-cpu_gdt_table 340 .word gdt_end-cpu_gdt_table-1
341gdt: 341gdt:
342 .quad cpu_gdt_table 342 .quad cpu_gdt_table
343#ifdef CONFIG_SMP 343#ifdef CONFIG_SMP
@@ -352,7 +352,8 @@ gdt:
352 * Also sysret mandates a special GDT layout 352 * Also sysret mandates a special GDT layout
353 */ 353 */
354 354
355.align PAGE_SIZE 355 .section .data.page_aligned, "aw"
356 .align PAGE_SIZE
356 357
357/* The TLS descriptors are currently at a different place compared to i386. 358/* The TLS descriptors are currently at a different place compared to i386.
358 Hopefully nobody expects them at a fixed place (Wine?) */ 359 Hopefully nobody expects them at a fixed place (Wine?) */
@@ -378,9 +379,12 @@ gdt_end:
378 /* zero the remaining page */ 379 /* zero the remaining page */
379 .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0 380 .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
380 381
381ENTRY(idt_table) 382 .section .bss, "aw", @nobits
382 .rept 256 383 .align L1_CACHE_BYTES
383 .quad 0 384ENTRY(idt_table)
384 .quad 0 385 .skip 256 * 16
385 .endr
386 386
387 .section .bss.page_aligned, "aw", @nobits
388 .align PAGE_SIZE
389ENTRY(empty_zero_page)
390 .skip PAGE_SIZE
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index ffed464e6b12..77b4c608cca0 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -50,7 +50,7 @@ static int no_timer_check;
50 50
51int disable_timer_pin_1 __initdata; 51int disable_timer_pin_1 __initdata;
52 52
53int timer_over_8254 __initdata = 1; 53int timer_over_8254 __initdata = 0;
54 54
55/* Where if anywhere is the i8259 connect in external int mode */ 55/* Where if anywhere is the i8259 connect in external int mode */
56static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 56static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
@@ -310,7 +310,7 @@ void __init check_ioapic(void)
310 force_iommu) && 310 force_iommu) &&
311 !iommu_aperture_allowed) { 311 !iommu_aperture_allowed) {
312 printk(KERN_INFO 312 printk(KERN_INFO
313 "Looks like a VIA chipset. Disabling IOMMU. Overwrite with \"iommu=allowed\"\n"); 313 "Looks like a VIA chipset. Disabling IOMMU. Override with \"iommu=allowed\"\n");
314 iommu_aperture_disabled = 1; 314 iommu_aperture_disabled = 1;
315 } 315 }
316#endif 316#endif
@@ -1848,7 +1848,7 @@ static inline void check_timer(void)
1848 */ 1848 */
1849 setup_ExtINT_IRQ0_pin(apic2, pin2, vector); 1849 setup_ExtINT_IRQ0_pin(apic2, pin2, vector);
1850 if (timer_irq_works()) { 1850 if (timer_irq_works()) {
1851 printk("works.\n"); 1851 apic_printk(APIC_VERBOSE," works.\n");
1852 nmi_watchdog_default(); 1852 nmi_watchdog_default();
1853 if (nmi_watchdog == NMI_IO_APIC) { 1853 if (nmi_watchdog == NMI_IO_APIC) {
1854 setup_nmi(); 1854 setup_nmi();
@@ -1860,7 +1860,7 @@ static inline void check_timer(void)
1860 */ 1860 */
1861 clear_IO_APIC_pin(apic2, pin2); 1861 clear_IO_APIC_pin(apic2, pin2);
1862 } 1862 }
1863 printk(" failed.\n"); 1863 apic_printk(APIC_VERBOSE," failed.\n");
1864 1864
1865 if (nmi_watchdog == NMI_IO_APIC) { 1865 if (nmi_watchdog == NMI_IO_APIC) {
1866 printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n"); 1866 printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");
@@ -1875,7 +1875,7 @@ static inline void check_timer(void)
1875 enable_8259A_irq(0); 1875 enable_8259A_irq(0);
1876 1876
1877 if (timer_irq_works()) { 1877 if (timer_irq_works()) {
1878 apic_printk(APIC_QUIET, " works.\n"); 1878 apic_printk(APIC_VERBOSE," works.\n");
1879 return; 1879 return;
1880 } 1880 }
1881 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector); 1881 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector);
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index b8b9529fa89e..04282ef9fbd4 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)
139 139
140static int mce_available(struct cpuinfo_x86 *c) 140static int mce_available(struct cpuinfo_x86 *c)
141{ 141{
142 return test_bit(X86_FEATURE_MCE, &c->x86_capability) && 142 return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
143 test_bit(X86_FEATURE_MCA, &c->x86_capability);
144} 143}
145 144
146static inline void mce_get_rip(struct mce *m, struct pt_regs *regs) 145static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 9013a90b5c2e..b17cf3eba359 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -106,11 +106,11 @@ static int __init mpf_checksum(unsigned char *mp, int len)
106 return sum & 0xFF; 106 return sum & 0xFF;
107} 107}
108 108
109static void __init MP_processor_info (struct mpc_config_processor *m) 109static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
110{ 110{
111 int cpu; 111 int cpu;
112 unsigned char ver; 112 unsigned char ver;
113 static int found_bsp=0; 113 cpumask_t tmp_map;
114 114
115 if (!(m->mpc_cpuflag & CPU_ENABLED)) { 115 if (!(m->mpc_cpuflag & CPU_ENABLED)) {
116 disabled_cpus++; 116 disabled_cpus++;
@@ -133,8 +133,10 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
133 return; 133 return;
134 } 134 }
135 135
136 cpu = num_processors++; 136 num_processors++;
137 137 cpus_complement(tmp_map, cpu_present_map);
138 cpu = first_cpu(tmp_map);
139
138#if MAX_APICS < 255 140#if MAX_APICS < 255
139 if ((int)m->mpc_apicid > MAX_APICS) { 141 if ((int)m->mpc_apicid > MAX_APICS) {
140 printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n", 142 printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n",
@@ -160,12 +162,7 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
160 * entry is BSP, and so on. 162 * entry is BSP, and so on.
161 */ 163 */
162 cpu = 0; 164 cpu = 0;
163 165 }
164 bios_cpu_apicid[0] = m->mpc_apicid;
165 x86_cpu_to_apicid[0] = m->mpc_apicid;
166 found_bsp = 1;
167 } else
168 cpu = num_processors - found_bsp;
169 bios_cpu_apicid[cpu] = m->mpc_apicid; 166 bios_cpu_apicid[cpu] = m->mpc_apicid;
170 x86_cpu_to_apicid[cpu] = m->mpc_apicid; 167 x86_cpu_to_apicid[cpu] = m->mpc_apicid;
171 168
@@ -691,7 +688,7 @@ void __init mp_register_lapic_address (
691} 688}
692 689
693 690
694void __init mp_register_lapic ( 691void __cpuinit mp_register_lapic (
695 u8 id, 692 u8 id,
696 u8 enabled) 693 u8 enabled)
697{ 694{
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 66c009e10bac..d9e4067faf05 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -534,6 +534,7 @@ asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
534 534
535void set_nmi_callback(nmi_callback_t callback) 535void set_nmi_callback(nmi_callback_t callback)
536{ 536{
537 vmalloc_sync_all();
537 rcu_assign_pointer(nmi_callback, callback); 538 rcu_assign_pointer(nmi_callback, callback);
538} 539}
539 540
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index 4ed391edd47a..03c9eeedb0f3 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -73,6 +73,9 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
73 if (dma_mask == 0) 73 if (dma_mask == 0)
74 dma_mask = 0xffffffff; 74 dma_mask = 0xffffffff;
75 75
76 /* Don't invoke OOM killer */
77 gfp |= __GFP_NORETRY;
78
76 /* Kludge to make it bug-to-bug compatible with i386. i386 79 /* Kludge to make it bug-to-bug compatible with i386. i386
77 uses the normal dma_mask for alloc_coherent. */ 80 uses the normal dma_mask for alloc_coherent. */
78 dma_mask &= *dev->dma_mask; 81 dma_mask &= *dev->dma_mask;
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 0c3f052ba6ce..a6c01e121266 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -65,9 +65,7 @@ static u32 gart_unmapped_entry;
65 65
66#define for_all_nb(dev) \ 66#define for_all_nb(dev) \
67 dev = NULL; \ 67 dev = NULL; \
68 while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)\ 68 while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)
69 if (dev->bus->number == 0 && \
70 (PCI_SLOT(dev->devfn) >= 24) && (PCI_SLOT(dev->devfn) <= 31))
71 69
72static struct pci_dev *northbridges[MAX_NB]; 70static struct pci_dev *northbridges[MAX_NB];
73static u32 northbridge_flush_word[MAX_NB]; 71static u32 northbridge_flush_word[MAX_NB];
@@ -148,9 +146,12 @@ static void flush_gart(struct device *dev)
148 if (!northbridges[i]) 146 if (!northbridges[i])
149 continue; 147 continue;
150 /* Make sure the hardware actually executed the flush. */ 148 /* Make sure the hardware actually executed the flush. */
151 do { 149 for (;;) {
152 pci_read_config_dword(northbridges[i], 0x9c, &w); 150 pci_read_config_dword(northbridges[i], 0x9c, &w);
153 } while (w & 1); 151 if (!(w & 1))
152 break;
153 cpu_relax();
154 }
154 } 155 }
155 if (!flushed) 156 if (!flushed)
156 printk("nothing to flush?\n"); 157 printk("nothing to flush?\n");
diff --git a/arch/x86_64/kernel/pmtimer.c b/arch/x86_64/kernel/pmtimer.c
index 5c51d10408a6..ee5ee4891f3d 100644
--- a/arch/x86_64/kernel/pmtimer.c
+++ b/arch/x86_64/kernel/pmtimer.c
@@ -86,7 +86,7 @@ static unsigned pmtimer_wait_tick(void)
86 for (a = b = inl(pmtmr_ioport) & ACPI_PM_MASK; 86 for (a = b = inl(pmtmr_ioport) & ACPI_PM_MASK;
87 a == b; 87 a == b;
88 b = inl(pmtmr_ioport) & ACPI_PM_MASK) 88 b = inl(pmtmr_ioport) & ACPI_PM_MASK)
89 ; 89 cpu_relax();
90 return b; 90 return b;
91} 91}
92 92
@@ -97,6 +97,7 @@ void pmtimer_wait(unsigned us)
97 a = pmtimer_wait_tick(); 97 a = pmtimer_wait_tick();
98 do { 98 do {
99 b = inl(pmtmr_ioport); 99 b = inl(pmtmr_ioport);
100 cpu_relax();
100 } while (cyc2us(b - a) < us); 101 } while (cyc2us(b - a) < us);
101} 102}
102 103
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 22a05dec81a2..81111835722d 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -114,7 +114,7 @@ void exit_idle(void)
114 * We use this if we don't have any better 114 * We use this if we don't have any better
115 * idle routine.. 115 * idle routine..
116 */ 116 */
117void default_idle(void) 117static void default_idle(void)
118{ 118{
119 local_irq_enable(); 119 local_irq_enable();
120 120
@@ -508,7 +508,7 @@ out:
508/* 508/*
509 * This special macro can be used to load a debugging register 509 * This special macro can be used to load a debugging register
510 */ 510 */
511#define loaddebug(thread,r) set_debug(thread->debugreg ## r, r) 511#define loaddebug(thread,r) set_debugreg(thread->debugreg ## r, r)
512 512
513/* 513/*
514 * switch_to(x,y) should switch tasks from x to y. 514 * switch_to(x,y) should switch tasks from x to y.
@@ -527,8 +527,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
527 int cpu = smp_processor_id(); 527 int cpu = smp_processor_id();
528 struct tss_struct *tss = &per_cpu(init_tss, cpu); 528 struct tss_struct *tss = &per_cpu(init_tss, cpu);
529 529
530 unlazy_fpu(prev_p);
531
532 /* 530 /*
533 * Reload esp0, LDT and the page table pointer: 531 * Reload esp0, LDT and the page table pointer:
534 */ 532 */
@@ -586,11 +584,14 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
586 } 584 }
587 585
588 /* 586 /*
589 * Switch the PDA context. 587 * Switch the PDA and FPU contexts.
590 */ 588 */
591 prev->userrsp = read_pda(oldrsp); 589 prev->userrsp = read_pda(oldrsp);
592 write_pda(oldrsp, next->userrsp); 590 write_pda(oldrsp, next->userrsp);
593 write_pda(pcurrent, next_p); 591 write_pda(pcurrent, next_p);
592 /* This must be here to ensure both math_state_restore() and
593 kernel_fpu_begin() work consistently. */
594 unlazy_fpu(prev_p);
594 write_pda(kernelstack, 595 write_pda(kernelstack,
595 task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET); 596 task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
596 597
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index 53205622351c..d44b2c1e63a6 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -420,9 +420,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
420 case offsetof(struct user, u_debugreg[7]): 420 case offsetof(struct user, u_debugreg[7]):
421 /* See arch/i386/kernel/ptrace.c for an explanation of 421 /* See arch/i386/kernel/ptrace.c for an explanation of
422 * this awkward check.*/ 422 * this awkward check.*/
423 data &= ~DR_CONTROL_RESERVED; 423 data &= ~DR_CONTROL_RESERVED;
424 for(i=0; i<4; i++) 424 for(i=0; i<4; i++)
425 if ((0x5454 >> ((data >> (16 + 4*i)) & 0xf)) & 1) 425 if ((0x5554 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
426 break; 426 break;
427 if (i == 4) { 427 if (i == 4) {
428 child->thread.debugreg7 = data; 428 child->thread.debugreg7 = data;
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index aa55e3cec665..a57eec8311a7 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -46,6 +46,7 @@
46#include <linux/cpufreq.h> 46#include <linux/cpufreq.h>
47#include <linux/dmi.h> 47#include <linux/dmi.h>
48#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
49#include <linux/ctype.h>
49 50
50#include <asm/mtrr.h> 51#include <asm/mtrr.h>
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
@@ -67,6 +68,7 @@
67#include <asm/swiotlb.h> 68#include <asm/swiotlb.h>
68#include <asm/sections.h> 69#include <asm/sections.h>
69#include <asm/gart-mapping.h> 70#include <asm/gart-mapping.h>
71#include <asm/dmi.h>
70 72
71/* 73/*
72 * Machine setup.. 74 * Machine setup..
@@ -91,6 +93,12 @@ int bootloader_type;
91 93
92unsigned long saved_video_mode; 94unsigned long saved_video_mode;
93 95
96/*
97 * Early DMI memory
98 */
99int dmi_alloc_index;
100char dmi_alloc_data[DMI_MAX_DATA];
101
94/* 102/*
95 * Setup options 103 * Setup options
96 */ 104 */
@@ -270,6 +278,13 @@ static void __init probe_roms(void)
270 } 278 }
271} 279}
272 280
281/* Check for full argument with no trailing characters */
282static int fullarg(char *p, char *arg)
283{
284 int l = strlen(arg);
285 return !memcmp(p, arg, l) && (p[l] == 0 || isspace(p[l]));
286}
287
273static __init void parse_cmdline_early (char ** cmdline_p) 288static __init void parse_cmdline_early (char ** cmdline_p)
274{ 289{
275 char c = ' ', *to = command_line, *from = COMMAND_LINE; 290 char c = ' ', *to = command_line, *from = COMMAND_LINE;
@@ -293,10 +308,10 @@ static __init void parse_cmdline_early (char ** cmdline_p)
293#endif 308#endif
294#ifdef CONFIG_ACPI 309#ifdef CONFIG_ACPI
295 /* "acpi=off" disables both ACPI table parsing and interpreter init */ 310 /* "acpi=off" disables both ACPI table parsing and interpreter init */
296 if (!memcmp(from, "acpi=off", 8)) 311 if (fullarg(from,"acpi=off"))
297 disable_acpi(); 312 disable_acpi();
298 313
299 if (!memcmp(from, "acpi=force", 10)) { 314 if (fullarg(from, "acpi=force")) {
300 /* add later when we do DMI horrors: */ 315 /* add later when we do DMI horrors: */
301 acpi_force = 1; 316 acpi_force = 1;
302 acpi_disabled = 0; 317 acpi_disabled = 0;
@@ -304,52 +319,47 @@ static __init void parse_cmdline_early (char ** cmdline_p)
304 319
305 /* acpi=ht just means: do ACPI MADT parsing 320 /* acpi=ht just means: do ACPI MADT parsing
306 at bootup, but don't enable the full ACPI interpreter */ 321 at bootup, but don't enable the full ACPI interpreter */
307 if (!memcmp(from, "acpi=ht", 7)) { 322 if (fullarg(from, "acpi=ht")) {
308 if (!acpi_force) 323 if (!acpi_force)
309 disable_acpi(); 324 disable_acpi();
310 acpi_ht = 1; 325 acpi_ht = 1;
311 } 326 }
312 else if (!memcmp(from, "pci=noacpi", 10)) 327 else if (fullarg(from, "pci=noacpi"))
313 acpi_disable_pci(); 328 acpi_disable_pci();
314 else if (!memcmp(from, "acpi=noirq", 10)) 329 else if (fullarg(from, "acpi=noirq"))
315 acpi_noirq_set(); 330 acpi_noirq_set();
316 331
317 else if (!memcmp(from, "acpi_sci=edge", 13)) 332 else if (fullarg(from, "acpi_sci=edge"))
318 acpi_sci_flags.trigger = 1; 333 acpi_sci_flags.trigger = 1;
319 else if (!memcmp(from, "acpi_sci=level", 14)) 334 else if (fullarg(from, "acpi_sci=level"))
320 acpi_sci_flags.trigger = 3; 335 acpi_sci_flags.trigger = 3;
321 else if (!memcmp(from, "acpi_sci=high", 13)) 336 else if (fullarg(from, "acpi_sci=high"))
322 acpi_sci_flags.polarity = 1; 337 acpi_sci_flags.polarity = 1;
323 else if (!memcmp(from, "acpi_sci=low", 12)) 338 else if (fullarg(from, "acpi_sci=low"))
324 acpi_sci_flags.polarity = 3; 339 acpi_sci_flags.polarity = 3;
325 340
326 /* acpi=strict disables out-of-spec workarounds */ 341 /* acpi=strict disables out-of-spec workarounds */
327 else if (!memcmp(from, "acpi=strict", 11)) { 342 else if (fullarg(from, "acpi=strict")) {
328 acpi_strict = 1; 343 acpi_strict = 1;
329 } 344 }
330#ifdef CONFIG_X86_IO_APIC 345#ifdef CONFIG_X86_IO_APIC
331 else if (!memcmp(from, "acpi_skip_timer_override", 24)) 346 else if (fullarg(from, "acpi_skip_timer_override"))
332 acpi_skip_timer_override = 1; 347 acpi_skip_timer_override = 1;
333#endif 348#endif
334#endif 349#endif
335 350
336 if (!memcmp(from, "disable_timer_pin_1", 19)) 351 if (fullarg(from, "disable_timer_pin_1"))
337 disable_timer_pin_1 = 1; 352 disable_timer_pin_1 = 1;
338 if (!memcmp(from, "enable_timer_pin_1", 18)) 353 if (fullarg(from, "enable_timer_pin_1"))
339 disable_timer_pin_1 = -1; 354 disable_timer_pin_1 = -1;
340 355
341 if (!memcmp(from, "nolapic", 7) || 356 if (fullarg(from, "nolapic") || fullarg(from, "disableapic"))
342 !memcmp(from, "disableapic", 11))
343 disable_apic = 1; 357 disable_apic = 1;
344 358
345 /* Don't confuse with noapictimer */ 359 if (fullarg(from, "noapic"))
346 if (!memcmp(from, "noapic", 6) &&
347 (from[6] == ' ' || from[6] == 0))
348 skip_ioapic_setup = 1; 360 skip_ioapic_setup = 1;
349 361
350 /* Make sure to not confuse with apic= */ 362 if (fullarg(from,"apic")) {
351 if (!memcmp(from, "apic", 4) &&
352 (from[4] == ' ' || from[4] == 0)) {
353 skip_ioapic_setup = 0; 363 skip_ioapic_setup = 0;
354 ioapic_force = 1; 364 ioapic_force = 1;
355 } 365 }
@@ -388,7 +398,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
388 iommu_setup(from+6); 398 iommu_setup(from+6);
389 } 399 }
390 400
391 if (!memcmp(from,"oops=panic", 10)) 401 if (fullarg(from,"oops=panic"))
392 panic_on_oops = 1; 402 panic_on_oops = 1;
393 403
394 if (!memcmp(from, "noexec=", 7)) 404 if (!memcmp(from, "noexec=", 7))
@@ -611,11 +621,14 @@ void __init setup_arch(char **cmdline_p)
611 * we are rounding upwards: 621 * we are rounding upwards:
612 */ 622 */
613 end_pfn = e820_end_of_ram(); 623 end_pfn = e820_end_of_ram();
624 num_physpages = end_pfn; /* for pfn_valid */
614 625
615 check_efer(); 626 check_efer();
616 627
617 init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT)); 628 init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
618 629
630 dmi_scan_machine();
631
619 zap_low_mappings(0); 632 zap_low_mappings(0);
620 633
621#ifdef CONFIG_ACPI 634#ifdef CONFIG_ACPI
@@ -708,6 +721,12 @@ void __init setup_arch(char **cmdline_p)
708 721
709 check_ioapic(); 722 check_ioapic();
710 723
724 /*
725 * set this early, so we dont allocate cpu0
726 * if MADT list doesnt list BSP first
727 * mpparse.c/MP_processor_info() allocates logical cpu numbers.
728 */
729 cpu_set(0, cpu_present_map);
711#ifdef CONFIG_ACPI 730#ifdef CONFIG_ACPI
712 /* 731 /*
713 * Read APIC and some other early information from ACPI tables. 732 * Read APIC and some other early information from ACPI tables.
@@ -836,7 +855,7 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
836 unsigned bits; 855 unsigned bits;
837#ifdef CONFIG_NUMA 856#ifdef CONFIG_NUMA
838 int node = 0; 857 int node = 0;
839 unsigned apicid = phys_proc_id[cpu]; 858 unsigned apicid = hard_smp_processor_id();
840#endif 859#endif
841 860
842 bits = 0; 861 bits = 0;
@@ -846,7 +865,7 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
846 /* Low order bits define the core id (index of core in socket) */ 865 /* Low order bits define the core id (index of core in socket) */
847 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1); 866 cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1);
848 /* Convert the APIC ID into the socket ID */ 867 /* Convert the APIC ID into the socket ID */
849 phys_proc_id[cpu] >>= bits; 868 phys_proc_id[cpu] = phys_pkg_id(bits);
850 869
851#ifdef CONFIG_NUMA 870#ifdef CONFIG_NUMA
852 node = phys_proc_id[cpu]; 871 node = phys_proc_id[cpu];
@@ -872,8 +891,8 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
872 } 891 }
873 numa_set_node(cpu, node); 892 numa_set_node(cpu, node);
874 893
875 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", 894 printk(KERN_INFO "CPU %d/%x(%d) -> Node %d -> Core %d\n",
876 cpu, c->x86_max_cores, node, cpu_core_id[cpu]); 895 cpu, apicid, c->x86_max_cores, node, cpu_core_id[cpu]);
877#endif 896#endif
878#endif 897#endif
879} 898}
@@ -927,8 +946,6 @@ static int __init init_amd(struct cpuinfo_x86 *c)
927 946
928 if (c->extended_cpuid_level >= 0x80000008) { 947 if (c->extended_cpuid_level >= 0x80000008) {
929 c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; 948 c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
930 if (c->x86_max_cores & (c->x86_max_cores - 1))
931 c->x86_max_cores = 1;
932 949
933 amd_detect_cmp(c); 950 amd_detect_cmp(c);
934 } 951 }
@@ -1261,7 +1278,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1261 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1278 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1262 1279
1263 /* Intel-defined (#2) */ 1280 /* Intel-defined (#2) */
1264 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", NULL, "est", 1281 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
1265 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL, 1282 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
1266 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1283 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1267 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1284 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -1344,8 +1361,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1344 { 1361 {
1345 int i; 1362 int i;
1346 for ( i = 0 ; i < 32*NCAPINTS ; i++ ) 1363 for ( i = 0 ; i < 32*NCAPINTS ; i++ )
1347 if ( test_bit(i, &c->x86_capability) && 1364 if (cpu_has(c, i) && x86_cap_flags[i] != NULL)
1348 x86_cap_flags[i] != NULL )
1349 seq_printf(m, " %s", x86_cap_flags[i]); 1365 seq_printf(m, " %s", x86_cap_flags[i]);
1350 } 1366 }
1351 1367
@@ -1403,10 +1419,3 @@ struct seq_operations cpuinfo_op = {
1403 .show = show_cpuinfo, 1419 .show = show_cpuinfo,
1404}; 1420};
1405 1421
1406static int __init run_dmi_scan(void)
1407{
1408 dmi_scan_machine();
1409 return 0;
1410}
1411core_initcall(run_dmi_scan);
1412
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index 70f1bb808a20..eabdb63fec31 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -33,7 +33,7 @@ cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
33struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly; 33struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
34struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned; 34struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned;
35 35
36struct desc_ptr idt_descr = { 256 * 16, (unsigned long) idt_table }; 36struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
37 37
38char boot_cpu_stack[IRQSTACKSIZE] __attribute__((section(".bss.page_aligned"))); 38char boot_cpu_stack[IRQSTACKSIZE] __attribute__((section(".bss.page_aligned")));
39 39
@@ -59,7 +59,7 @@ int __init nonx_setup(char *str)
59} 59}
60__setup("noexec=", nonx_setup); /* parsed early actually */ 60__setup("noexec=", nonx_setup); /* parsed early actually */
61 61
62int force_personality32 = READ_IMPLIES_EXEC; 62int force_personality32 = 0;
63 63
64/* noexec32=on|off 64/* noexec32=on|off
65Control non executable heap for 32bit processes. 65Control non executable heap for 32bit processes.
@@ -248,7 +248,7 @@ void __cpuinit cpu_init (void)
248 switch (v + 1) { 248 switch (v + 1) {
249#if DEBUG_STKSZ > EXCEPTION_STKSZ 249#if DEBUG_STKSZ > EXCEPTION_STKSZ
250 case DEBUG_STACK: 250 case DEBUG_STACK:
251 cpu_pda[cpu].debugstack = (unsigned long)estacks; 251 cpu_pda(cpu)->debugstack = (unsigned long)estacks;
252 estacks += DEBUG_STKSZ; 252 estacks += DEBUG_STKSZ;
253 break; 253 break;
254#endif 254#endif
@@ -281,12 +281,12 @@ void __cpuinit cpu_init (void)
281 * Clear all 6 debug registers: 281 * Clear all 6 debug registers:
282 */ 282 */
283 283
284 set_debug(0UL, 0); 284 set_debugreg(0UL, 0);
285 set_debug(0UL, 1); 285 set_debugreg(0UL, 1);
286 set_debug(0UL, 2); 286 set_debugreg(0UL, 2);
287 set_debug(0UL, 3); 287 set_debugreg(0UL, 3);
288 set_debug(0UL, 6); 288 set_debugreg(0UL, 6);
289 set_debug(0UL, 7); 289 set_debugreg(0UL, 7);
290 290
291 fpu_init(); 291 fpu_init();
292} 292}
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 19ef012b1f17..4a6628b14d99 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -75,7 +75,7 @@ static inline void leave_mm(int cpu)
75{ 75{
76 if (read_pda(mmu_state) == TLBSTATE_OK) 76 if (read_pda(mmu_state) == TLBSTATE_OK)
77 BUG(); 77 BUG();
78 clear_bit(cpu, &read_pda(active_mm)->cpu_vm_mask); 78 cpu_clear(cpu, read_pda(active_mm)->cpu_vm_mask);
79 load_cr3(swapper_pg_dir); 79 load_cr3(swapper_pg_dir);
80} 80}
81 81
@@ -85,7 +85,7 @@ static inline void leave_mm(int cpu)
85 * [cpu0: the cpu that switches] 85 * [cpu0: the cpu that switches]
86 * 1) switch_mm() either 1a) or 1b) 86 * 1) switch_mm() either 1a) or 1b)
87 * 1a) thread switch to a different mm 87 * 1a) thread switch to a different mm
88 * 1a1) clear_bit(cpu, &old_mm->cpu_vm_mask); 88 * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask);
89 * Stop ipi delivery for the old mm. This is not synchronized with 89 * Stop ipi delivery for the old mm. This is not synchronized with
90 * the other cpus, but smp_invalidate_interrupt ignore flush ipis 90 * the other cpus, but smp_invalidate_interrupt ignore flush ipis
91 * for the wrong mm, and in the worst case we perform a superfluous 91 * for the wrong mm, and in the worst case we perform a superfluous
@@ -95,7 +95,7 @@ static inline void leave_mm(int cpu)
95 * was in lazy tlb mode. 95 * was in lazy tlb mode.
96 * 1a3) update cpu active_mm 96 * 1a3) update cpu active_mm
97 * Now cpu0 accepts tlb flushes for the new mm. 97 * Now cpu0 accepts tlb flushes for the new mm.
98 * 1a4) set_bit(cpu, &new_mm->cpu_vm_mask); 98 * 1a4) cpu_set(cpu, new_mm->cpu_vm_mask);
99 * Now the other cpus will send tlb flush ipis. 99 * Now the other cpus will send tlb flush ipis.
100 * 1a4) change cr3. 100 * 1a4) change cr3.
101 * 1b) thread switch without mm change 101 * 1b) thread switch without mm change
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index ee5ce3d3cbc3..7f58fa682491 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -88,7 +88,8 @@ static inline unsigned int do_gettimeoffset_tsc(void)
88 unsigned long t; 88 unsigned long t;
89 unsigned long x; 89 unsigned long x;
90 t = get_cycles_sync(); 90 t = get_cycles_sync();
91 if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */ 91 if (t < vxtime.last_tsc)
92 t = vxtime.last_tsc; /* hack */
92 x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32; 93 x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
93 return x; 94 return x;
94} 95}
@@ -178,8 +179,9 @@ unsigned long profile_pc(struct pt_regs *regs)
178{ 179{
179 unsigned long pc = instruction_pointer(regs); 180 unsigned long pc = instruction_pointer(regs);
180 181
181 /* Assume the lock function has either no stack frame or only a single word. 182 /* Assume the lock function has either no stack frame or only a single
182 This checks if the address on the stack looks like a kernel text address. 183 word. This checks if the address on the stack looks like a kernel
184 text address.
183 There is a small window for false hits, but in that case the tick 185 There is a small window for false hits, but in that case the tick
184 is just accounted to the spinlock function. 186 is just accounted to the spinlock function.
185 Better would be to write these functions in assembler again 187 Better would be to write these functions in assembler again
@@ -242,17 +244,10 @@ static void set_rtc_mmss(unsigned long nowtime)
242 real_minutes += 30; /* correct for half hour time zone */ 244 real_minutes += 30; /* correct for half hour time zone */
243 real_minutes %= 60; 245 real_minutes %= 60;
244 246
245#if 0
246 /* AMD 8111 is a really bad time keeper and hits this regularly.
247 It probably was an attempt to avoid screwing up DST, but ignore
248 that for now. */
249 if (abs(real_minutes - cmos_minutes) >= 30) { 247 if (abs(real_minutes - cmos_minutes) >= 30) {
250 printk(KERN_WARNING "time.c: can't update CMOS clock " 248 printk(KERN_WARNING "time.c: can't update CMOS clock "
251 "from %d to %d\n", cmos_minutes, real_minutes); 249 "from %d to %d\n", cmos_minutes, real_minutes);
252 } else 250 } else {
253#endif
254
255 {
256 BIN_TO_BCD(real_seconds); 251 BIN_TO_BCD(real_seconds);
257 BIN_TO_BCD(real_minutes); 252 BIN_TO_BCD(real_minutes);
258 CMOS_WRITE(real_seconds, RTC_SECONDS); 253 CMOS_WRITE(real_seconds, RTC_SECONDS);
@@ -293,8 +288,7 @@ unsigned long long monotonic_clock(void)
293 this_offset = hpet_readl(HPET_COUNTER); 288 this_offset = hpet_readl(HPET_COUNTER);
294 } while (read_seqretry(&xtime_lock, seq)); 289 } while (read_seqretry(&xtime_lock, seq));
295 offset = (this_offset - last_offset); 290 offset = (this_offset - last_offset);
296 offset *=(NSEC_PER_SEC/HZ)/hpet_tick; 291 offset *= (NSEC_PER_SEC/HZ) / hpet_tick;
297 return base + offset;
298 } else { 292 } else {
299 do { 293 do {
300 seq = read_seqbegin(&xtime_lock); 294 seq = read_seqbegin(&xtime_lock);
@@ -303,50 +297,46 @@ unsigned long long monotonic_clock(void)
303 base = monotonic_base; 297 base = monotonic_base;
304 } while (read_seqretry(&xtime_lock, seq)); 298 } while (read_seqretry(&xtime_lock, seq));
305 this_offset = get_cycles_sync(); 299 this_offset = get_cycles_sync();
306 offset = (this_offset - last_offset)*1000/cpu_khz; 300 offset = (this_offset - last_offset)*1000 / cpu_khz;
307 return base + offset;
308 } 301 }
302 return base + offset;
309} 303}
310EXPORT_SYMBOL(monotonic_clock); 304EXPORT_SYMBOL(monotonic_clock);
311 305
312static noinline void handle_lost_ticks(int lost, struct pt_regs *regs) 306static noinline void handle_lost_ticks(int lost, struct pt_regs *regs)
313{ 307{
314 static long lost_count; 308 static long lost_count;
315 static int warned; 309 static int warned;
316 310 if (report_lost_ticks) {
317 if (report_lost_ticks) { 311 printk(KERN_WARNING "time.c: Lost %d timer tick(s)! ", lost);
318 printk(KERN_WARNING "time.c: Lost %d timer " 312 print_symbol("rip %s)\n", regs->rip);
319 "tick(s)! ", lost); 313 }
320 print_symbol("rip %s)\n", regs->rip); 314
321 } 315 if (lost_count == 1000 && !warned) {
322 316 printk(KERN_WARNING "warning: many lost ticks.\n"
323 if (lost_count == 1000 && !warned) { 317 KERN_WARNING "Your time source seems to be instable or "
324 printk(KERN_WARNING
325 "warning: many lost ticks.\n"
326 KERN_WARNING "Your time source seems to be instable or "
327 "some driver is hogging interupts\n"); 318 "some driver is hogging interupts\n");
328 print_symbol("rip %s\n", regs->rip); 319 print_symbol("rip %s\n", regs->rip);
329 if (vxtime.mode == VXTIME_TSC && vxtime.hpet_address) { 320 if (vxtime.mode == VXTIME_TSC && vxtime.hpet_address) {
330 printk(KERN_WARNING "Falling back to HPET\n"); 321 printk(KERN_WARNING "Falling back to HPET\n");
331 if (hpet_use_timer) 322 if (hpet_use_timer)
332 vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick; 323 vxtime.last = hpet_readl(HPET_T0_CMP) -
333 else 324 hpet_tick;
334 vxtime.last = hpet_readl(HPET_COUNTER); 325 else
335 vxtime.mode = VXTIME_HPET; 326 vxtime.last = hpet_readl(HPET_COUNTER);
336 do_gettimeoffset = do_gettimeoffset_hpet; 327 vxtime.mode = VXTIME_HPET;
337 } 328 do_gettimeoffset = do_gettimeoffset_hpet;
338 /* else should fall back to PIT, but code missing. */ 329 }
339 warned = 1; 330 /* else should fall back to PIT, but code missing. */
340 } else 331 warned = 1;
341 lost_count++; 332 } else
333 lost_count++;
342 334
343#ifdef CONFIG_CPU_FREQ 335#ifdef CONFIG_CPU_FREQ
344 /* In some cases the CPU can change frequency without us noticing 336 /* In some cases the CPU can change frequency without us noticing
345 (like going into thermal throttle) 337 Give cpufreq a change to catch up. */
346 Give cpufreq a change to catch up. */ 338 if ((lost_count+1) % 25 == 0)
347 if ((lost_count+1) % 25 == 0) { 339 cpufreq_delayed_get();
348 cpufreq_delayed_get();
349 }
350#endif 340#endif
351} 341}
352 342
@@ -354,7 +344,7 @@ void main_timer_handler(struct pt_regs *regs)
354{ 344{
355 static unsigned long rtc_update = 0; 345 static unsigned long rtc_update = 0;
356 unsigned long tsc; 346 unsigned long tsc;
357 int delay, offset = 0, lost = 0; 347 int delay = 0, offset = 0, lost = 0;
358 348
359/* 349/*
360 * Here we are in the timer irq handler. We have irqs locally disabled (so we 350 * Here we are in the timer irq handler. We have irqs locally disabled (so we
@@ -375,7 +365,7 @@ void main_timer_handler(struct pt_regs *regs)
375 */ 365 */
376 offset = hpet_readl(HPET_T0_CMP) - hpet_tick; 366 offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
377 delay = hpet_readl(HPET_COUNTER) - offset; 367 delay = hpet_readl(HPET_COUNTER) - offset;
378 } else { 368 } else if (!pmtmr_ioport) {
379 spin_lock(&i8253_lock); 369 spin_lock(&i8253_lock);
380 outb_p(0x00, 0x43); 370 outb_p(0x00, 0x43);
381 delay = inb_p(0x40); 371 delay = inb_p(0x40);
@@ -517,6 +507,7 @@ static unsigned long get_cmos_time(void)
517 unsigned int timeout = 1000000, year, mon, day, hour, min, sec; 507 unsigned int timeout = 1000000, year, mon, day, hour, min, sec;
518 unsigned char uip = 0, this = 0; 508 unsigned char uip = 0, this = 0;
519 unsigned long flags; 509 unsigned long flags;
510 unsigned extyear = 0;
520 511
521/* 512/*
522 * The Linux interpretation of the CMOS clock register contents: When the 513 * The Linux interpretation of the CMOS clock register contents: When the
@@ -545,12 +536,17 @@ static unsigned long get_cmos_time(void)
545 mon = CMOS_READ(RTC_MONTH); 536 mon = CMOS_READ(RTC_MONTH);
546 year = CMOS_READ(RTC_YEAR); 537 year = CMOS_READ(RTC_YEAR);
547 538
539#ifdef CONFIG_ACPI
540 if (acpi_fadt.revision >= FADT2_REVISION_ID && acpi_fadt.century)
541 extyear = CMOS_READ(acpi_fadt.century);
542#endif
543
548 spin_unlock_irqrestore(&rtc_lock, flags); 544 spin_unlock_irqrestore(&rtc_lock, flags);
549 545
550 /* 546 /*
551 * We know that x86-64 always uses BCD format, no need to check the 547 * We know that x86-64 always uses BCD format, no need to check the
552 * config register. 548 * config register.
553 */ 549 */
554 550
555 BCD_TO_BIN(sec); 551 BCD_TO_BIN(sec);
556 BCD_TO_BIN(min); 552 BCD_TO_BIN(min);
@@ -559,11 +555,17 @@ static unsigned long get_cmos_time(void)
559 BCD_TO_BIN(mon); 555 BCD_TO_BIN(mon);
560 BCD_TO_BIN(year); 556 BCD_TO_BIN(year);
561 557
562 /* 558 if (extyear) {
563 * x86-64 systems only exists since 2002. 559 BCD_TO_BIN(extyear);
564 * This will work up to Dec 31, 2100 560 year += extyear;
565 */ 561 printk(KERN_INFO "Extended CMOS year: %d\n", extyear);
566 year += 2000; 562 } else {
563 /*
564 * x86-64 systems only exists since 2002.
565 * This will work up to Dec 31, 2100
566 */
567 year += 2000;
568 }
567 569
568 return mktime(year, mon, day, hour, min, sec); 570 return mktime(year, mon, day, hour, min, sec);
569} 571}
@@ -606,7 +608,8 @@ static void cpufreq_delayed_get(void)
606 cpufreq_delayed_issched = 1; 608 cpufreq_delayed_issched = 1;
607 if (!warned) { 609 if (!warned) {
608 warned = 1; 610 warned = 1;
609 printk(KERN_DEBUG "Losing some ticks... checking if CPU frequency changed.\n"); 611 printk(KERN_DEBUG
612 "Losing some ticks... checking if CPU frequency changed.\n");
610 } 613 }
611 schedule_work(&cpufreq_delayed_get_work); 614 schedule_work(&cpufreq_delayed_get_work);
612 } 615 }
@@ -629,9 +632,9 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
629 lpj = &dummy; 632 lpj = &dummy;
630 if (!(freq->flags & CPUFREQ_CONST_LOOPS)) 633 if (!(freq->flags & CPUFREQ_CONST_LOOPS))
631#ifdef CONFIG_SMP 634#ifdef CONFIG_SMP
632 lpj = &cpu_data[freq->cpu].loops_per_jiffy; 635 lpj = &cpu_data[freq->cpu].loops_per_jiffy;
633#else 636#else
634 lpj = &boot_cpu_data.loops_per_jiffy; 637 lpj = &boot_cpu_data.loops_per_jiffy;
635#endif 638#endif
636 639
637 if (!ref_freq) { 640 if (!ref_freq) {
@@ -768,9 +771,8 @@ static __init int late_hpet_init(void)
768 int i; 771 int i;
769 772
770 hpet = (struct hpet *) fix_to_virt(FIX_HPET_BASE); 773 hpet = (struct hpet *) fix_to_virt(FIX_HPET_BASE);
771 774 timer = &hpet->hpet_timers[2];
772 for (i = 2, timer = &hpet->hpet_timers[2]; i < ntimer; 775 for (i = 2; i < ntimer; timer++, i++)
773 timer++, i++)
774 hd.hd_irq[i] = (timer->hpet_config & 776 hd.hd_irq[i] = (timer->hpet_config &
775 Tn_INT_ROUTE_CNF_MASK) >> 777 Tn_INT_ROUTE_CNF_MASK) >>
776 Tn_INT_ROUTE_CNF_SHIFT; 778 Tn_INT_ROUTE_CNF_SHIFT;
@@ -927,8 +929,7 @@ void __init time_init(void)
927 -xtime.tv_sec, -xtime.tv_nsec); 929 -xtime.tv_sec, -xtime.tv_nsec);
928 930
929 if (!hpet_init()) 931 if (!hpet_init())
930 vxtime_hz = (1000000000000000L + hpet_period / 2) / 932 vxtime_hz = (1000000000000000L + hpet_period / 2) / hpet_period;
931 hpet_period;
932 else 933 else
933 vxtime.hpet_address = 0; 934 vxtime.hpet_address = 0;
934 935
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 28d50dc540e8..7b148309c529 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -47,8 +47,6 @@
47#include <asm/proto.h> 47#include <asm/proto.h>
48#include <asm/nmi.h> 48#include <asm/nmi.h>
49 49
50extern struct gate_struct idt_table[256];
51
52asmlinkage void divide_error(void); 50asmlinkage void divide_error(void);
53asmlinkage void debug(void); 51asmlinkage void debug(void);
54asmlinkage void nmi(void); 52asmlinkage void nmi(void);
@@ -78,6 +76,8 @@ int register_die_notifier(struct notifier_block *nb)
78{ 76{
79 int err = 0; 77 int err = 0;
80 unsigned long flags; 78 unsigned long flags;
79
80 vmalloc_sync_all();
81 spin_lock_irqsave(&die_notifier_lock, flags); 81 spin_lock_irqsave(&die_notifier_lock, flags);
82 err = notifier_chain_register(&die_chain, nb); 82 err = notifier_chain_register(&die_chain, nb);
83 spin_unlock_irqrestore(&die_notifier_lock, flags); 83 spin_unlock_irqrestore(&die_notifier_lock, flags);
@@ -122,7 +122,7 @@ int printk_address(unsigned long address)
122 if (!modname) 122 if (!modname)
123 modname = delim = ""; 123 modname = delim = "";
124 return printk("<%016lx>{%s%s%s%s%+ld}", 124 return printk("<%016lx>{%s%s%s%s%+ld}",
125 address,delim,modname,delim,symname,offset); 125 address, delim, modname, delim, symname, offset);
126} 126}
127#else 127#else
128int printk_address(unsigned long address) 128int printk_address(unsigned long address)
@@ -334,13 +334,12 @@ void show_registers(struct pt_regs *regs)
334 show_stack(NULL, (unsigned long*)rsp); 334 show_stack(NULL, (unsigned long*)rsp);
335 335
336 printk("\nCode: "); 336 printk("\nCode: ");
337 if(regs->rip < PAGE_OFFSET) 337 if (regs->rip < PAGE_OFFSET)
338 goto bad; 338 goto bad;
339 339
340 for(i=0;i<20;i++) 340 for (i=0; i<20; i++) {
341 {
342 unsigned char c; 341 unsigned char c;
343 if(__get_user(c, &((unsigned char*)regs->rip)[i])) { 342 if (__get_user(c, &((unsigned char*)regs->rip)[i])) {
344bad: 343bad:
345 printk(" Bad RIP value."); 344 printk(" Bad RIP value.");
346 break; 345 break;
@@ -479,7 +478,7 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
479 printk(KERN_INFO 478 printk(KERN_INFO
480 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n", 479 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
481 tsk->comm, tsk->pid, str, 480 tsk->comm, tsk->pid, str,
482 regs->rip,regs->rsp,error_code); 481 regs->rip, regs->rsp, error_code);
483 482
484 if (info) 483 if (info)
485 force_sig_info(signr, info, tsk); 484 force_sig_info(signr, info, tsk);
@@ -493,9 +492,9 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
493 { 492 {
494 const struct exception_table_entry *fixup; 493 const struct exception_table_entry *fixup;
495 fixup = search_exception_tables(regs->rip); 494 fixup = search_exception_tables(regs->rip);
496 if (fixup) { 495 if (fixup)
497 regs->rip = fixup->fixup; 496 regs->rip = fixup->fixup;
498 } else 497 else
499 die(str, regs, error_code); 498 die(str, regs, error_code);
500 return; 499 return;
501 } 500 }
@@ -568,7 +567,7 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
568 printk(KERN_INFO 567 printk(KERN_INFO
569 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n", 568 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
570 tsk->comm, tsk->pid, 569 tsk->comm, tsk->pid,
571 regs->rip,regs->rsp,error_code); 570 regs->rip, regs->rsp, error_code);
572 571
573 force_sig(SIGSEGV, tsk); 572 force_sig(SIGSEGV, tsk);
574 return; 573 return;
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 74db0062d4a2..39ff0708f803 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -20,6 +20,12 @@ SECTIONS
20 phys_startup_64 = startup_64 - LOAD_OFFSET; 20 phys_startup_64 = startup_64 - LOAD_OFFSET;
21 _text = .; /* Text and read-only data */ 21 _text = .; /* Text and read-only data */
22 .text : AT(ADDR(.text) - LOAD_OFFSET) { 22 .text : AT(ADDR(.text) - LOAD_OFFSET) {
23 /* First the code that has to be first for bootstrapping */
24 *(.bootstrap.text)
25 /* Then all the functions that are "hot" in profiles, to group them
26 onto the same hugetlb entry */
27 #include "functionlist"
28 /* Then the rest */
23 *(.text) 29 *(.text)
24 SCHED_TEXT 30 SCHED_TEXT
25 LOCK_TEXT 31 LOCK_TEXT
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index c9dc7e46731e..d96a9348e5a2 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -144,16 +144,12 @@ EXPORT_SYMBOL(rwsem_down_write_failed_thunk);
144EXPORT_SYMBOL(empty_zero_page); 144EXPORT_SYMBOL(empty_zero_page);
145 145
146EXPORT_SYMBOL(die_chain); 146EXPORT_SYMBOL(die_chain);
147EXPORT_SYMBOL(register_die_notifier);
148 147
149#ifdef CONFIG_SMP 148#ifdef CONFIG_SMP
150EXPORT_SYMBOL(cpu_sibling_map); 149EXPORT_SYMBOL(cpu_sibling_map);
151EXPORT_SYMBOL(smp_num_siblings); 150EXPORT_SYMBOL(smp_num_siblings);
152#endif 151#endif
153 152
154extern void do_softirq_thunk(void);
155EXPORT_SYMBOL(do_softirq_thunk);
156
157#ifdef CONFIG_BUG 153#ifdef CONFIG_BUG
158EXPORT_SYMBOL(out_of_line_bug); 154EXPORT_SYMBOL(out_of_line_bug);
159#endif 155#endif
diff --git a/arch/x86_64/lib/thunk.S b/arch/x86_64/lib/thunk.S
index acc1e2ca7ed7..e49af0032e94 100644
--- a/arch/x86_64/lib/thunk.S
+++ b/arch/x86_64/lib/thunk.S
@@ -42,7 +42,6 @@
42 thunk rwsem_wake_thunk,rwsem_wake 42 thunk rwsem_wake_thunk,rwsem_wake
43 thunk rwsem_downgrade_thunk,rwsem_downgrade_wake 43 thunk rwsem_downgrade_thunk,rwsem_downgrade_wake
44#endif 44#endif
45 thunk do_softirq_thunk,do_softirq
46 45
47 thunk __down_failed,__down 46 thunk __down_failed,__down
48 thunk_retrax __down_failed_interruptible,__down_interruptible 47 thunk_retrax __down_failed_interruptible,__down_interruptible
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 2e7c3c8ffe03..316c53de47bd 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -264,6 +264,8 @@ static int vmalloc_fault(unsigned long address)
264 return -1; 264 return -1;
265 if (pgd_none(*pgd)) 265 if (pgd_none(*pgd))
266 set_pgd(pgd, *pgd_ref); 266 set_pgd(pgd, *pgd_ref);
267 else
268 BUG_ON(pgd_page(*pgd) != pgd_page(*pgd_ref));
267 269
268 /* Below here mismatches are bugs because these lower tables 270 /* Below here mismatches are bugs because these lower tables
269 are shared */ 271 are shared */
@@ -312,21 +314,13 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
312 unsigned long flags; 314 unsigned long flags;
313 siginfo_t info; 315 siginfo_t info;
314 316
317 tsk = current;
318 mm = tsk->mm;
319 prefetchw(&mm->mmap_sem);
320
315 /* get the address */ 321 /* get the address */
316 __asm__("movq %%cr2,%0":"=r" (address)); 322 __asm__("movq %%cr2,%0":"=r" (address));
317 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
318 SIGSEGV) == NOTIFY_STOP)
319 return;
320
321 if (likely(regs->eflags & X86_EFLAGS_IF))
322 local_irq_enable();
323 323
324 if (unlikely(page_fault_trace))
325 printk("pagefault rip:%lx rsp:%lx cs:%lu ss:%lu address %lx error %lx\n",
326 regs->rip,regs->rsp,regs->cs,regs->ss,address,error_code);
327
328 tsk = current;
329 mm = tsk->mm;
330 info.si_code = SEGV_MAPERR; 324 info.si_code = SEGV_MAPERR;
331 325
332 326
@@ -351,10 +345,12 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
351 */ 345 */
352 if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) && 346 if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
353 ((address >= VMALLOC_START && address < VMALLOC_END))) { 347 ((address >= VMALLOC_START && address < VMALLOC_END))) {
354 if (vmalloc_fault(address) < 0) 348 if (vmalloc_fault(address) >= 0)
355 goto bad_area_nosemaphore; 349 return;
356 return;
357 } 350 }
351 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
352 SIGSEGV) == NOTIFY_STOP)
353 return;
358 /* 354 /*
359 * Don't take the mm semaphore here. If we fixup a prefetch 355 * Don't take the mm semaphore here. If we fixup a prefetch
360 * fault we could otherwise deadlock. 356 * fault we could otherwise deadlock.
@@ -362,6 +358,17 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
362 goto bad_area_nosemaphore; 358 goto bad_area_nosemaphore;
363 } 359 }
364 360
361 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
362 SIGSEGV) == NOTIFY_STOP)
363 return;
364
365 if (likely(regs->eflags & X86_EFLAGS_IF))
366 local_irq_enable();
367
368 if (unlikely(page_fault_trace))
369 printk("pagefault rip:%lx rsp:%lx cs:%lu ss:%lu address %lx error %lx\n",
370 regs->rip,regs->rsp,regs->cs,regs->ss,address,error_code);
371
365 if (unlikely(error_code & PF_RSVD)) 372 if (unlikely(error_code & PF_RSVD))
366 pgtable_bad(address, regs, error_code); 373 pgtable_bad(address, regs, error_code);
367 374
@@ -571,6 +578,48 @@ do_sigbus:
571 return; 578 return;
572} 579}
573 580
581DEFINE_SPINLOCK(pgd_lock);
582struct page *pgd_list;
583
584void vmalloc_sync_all(void)
585{
586 /* Note that races in the updates of insync and start aren't
587 problematic:
588 insync can only get set bits added, and updates to start are only
589 improving performance (without affecting correctness if undone). */
590 static DECLARE_BITMAP(insync, PTRS_PER_PGD);
591 static unsigned long start = VMALLOC_START & PGDIR_MASK;
592 unsigned long address;
593
594 for (address = start; address <= VMALLOC_END; address += PGDIR_SIZE) {
595 if (!test_bit(pgd_index(address), insync)) {
596 const pgd_t *pgd_ref = pgd_offset_k(address);
597 struct page *page;
598
599 if (pgd_none(*pgd_ref))
600 continue;
601 spin_lock(&pgd_lock);
602 for (page = pgd_list; page;
603 page = (struct page *)page->index) {
604 pgd_t *pgd;
605 pgd = (pgd_t *)page_address(page) + pgd_index(address);
606 if (pgd_none(*pgd))
607 set_pgd(pgd, *pgd_ref);
608 else
609 BUG_ON(pgd_page(*pgd) != pgd_page(*pgd_ref));
610 }
611 spin_unlock(&pgd_lock);
612 set_bit(pgd_index(address), insync);
613 }
614 if (address == start)
615 start = address + PGDIR_SIZE;
616 }
617 /* Check that there is no need to do the same for the modules area. */
618 BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
619 BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
620 (__START_KERNEL & PGDIR_MASK)));
621}
622
574static int __init enable_pagefaulttrace(char *str) 623static int __init enable_pagefaulttrace(char *str)
575{ 624{
576 page_fault_trace = 1; 625 page_fault_trace = 1;
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 40ed13d263cd..b04415625442 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -94,7 +94,7 @@ void show_mem(void)
94 94
95int after_bootmem; 95int after_bootmem;
96 96
97static void *spp_getpage(void) 97static __init void *spp_getpage(void)
98{ 98{
99 void *ptr; 99 void *ptr;
100 if (after_bootmem) 100 if (after_bootmem)
@@ -108,7 +108,7 @@ static void *spp_getpage(void)
108 return ptr; 108 return ptr;
109} 109}
110 110
111static void set_pte_phys(unsigned long vaddr, 111static __init void set_pte_phys(unsigned long vaddr,
112 unsigned long phys, pgprot_t prot) 112 unsigned long phys, pgprot_t prot)
113{ 113{
114 pgd_t *pgd; 114 pgd_t *pgd;
@@ -157,7 +157,8 @@ static void set_pte_phys(unsigned long vaddr,
157} 157}
158 158
159/* NOTE: this is meant to be run only at boot */ 159/* NOTE: this is meant to be run only at boot */
160void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t prot) 160void __init
161__set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
161{ 162{
162 unsigned long address = __fix_to_virt(idx); 163 unsigned long address = __fix_to_virt(idx);
163 164
@@ -225,6 +226,33 @@ static __meminit void unmap_low_page(int i)
225 ti->allocated = 0; 226 ti->allocated = 0;
226} 227}
227 228
229/* Must run before zap_low_mappings */
230__init void *early_ioremap(unsigned long addr, unsigned long size)
231{
232 unsigned long map = round_down(addr, LARGE_PAGE_SIZE);
233
234 /* actually usually some more */
235 if (size >= LARGE_PAGE_SIZE) {
236 printk("SMBIOS area too long %lu\n", size);
237 return NULL;
238 }
239 set_pmd(temp_mappings[0].pmd, __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
240 map += LARGE_PAGE_SIZE;
241 set_pmd(temp_mappings[1].pmd, __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
242 __flush_tlb();
243 return temp_mappings[0].address + (addr & (LARGE_PAGE_SIZE-1));
244}
245
246/* To avoid virtual aliases later */
247__init void early_iounmap(void *addr, unsigned long size)
248{
249 if ((void *)round_down((unsigned long)addr, LARGE_PAGE_SIZE) != temp_mappings[0].address)
250 printk("early_iounmap: bad address %p\n", addr);
251 set_pmd(temp_mappings[0].pmd, __pmd(0));
252 set_pmd(temp_mappings[1].pmd, __pmd(0));
253 __flush_tlb();
254}
255
228static void __meminit 256static void __meminit
229phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end) 257phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end)
230{ 258{
@@ -344,7 +372,7 @@ void __meminit init_memory_mapping(unsigned long start, unsigned long end)
344 pud_t *pud; 372 pud_t *pud;
345 373
346 if (after_bootmem) 374 if (after_bootmem)
347 pud = pud_offset_k(pgd, __PAGE_OFFSET); 375 pud = pud_offset_k(pgd, start & PGDIR_MASK);
348 else 376 else
349 pud = alloc_low_page(&map, &pud_phys); 377 pud = alloc_low_page(&map, &pud_phys);
350 378
diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
index dd60e71fdba6..7c45c2d2b8b2 100644
--- a/arch/x86_64/mm/k8topology.c
+++ b/arch/x86_64/mm/k8topology.c
@@ -43,7 +43,7 @@ static __init int find_northbridge(void)
43int __init k8_scan_nodes(unsigned long start, unsigned long end) 43int __init k8_scan_nodes(unsigned long start, unsigned long end)
44{ 44{
45 unsigned long prevbase; 45 unsigned long prevbase;
46 struct node nodes[8]; 46 struct bootnode nodes[8];
47 int nodeid, i, nb; 47 int nodeid, i, nb;
48 unsigned char nodeids[8]; 48 unsigned char nodeids[8];
49 int found = 0; 49 int found = 0;
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 22e51beee8d3..63c72641b737 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -25,8 +25,7 @@
25struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 25struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
26bootmem_data_t plat_node_bdata[MAX_NUMNODES]; 26bootmem_data_t plat_node_bdata[MAX_NUMNODES];
27 27
28int memnode_shift; 28struct memnode memnode;
29u8 memnodemap[NODEMAPSIZE];
30 29
31unsigned char cpu_to_node[NR_CPUS] __read_mostly = { 30unsigned char cpu_to_node[NR_CPUS] __read_mostly = {
32 [0 ... NR_CPUS-1] = NUMA_NO_NODE 31 [0 ... NR_CPUS-1] = NUMA_NO_NODE
@@ -47,7 +46,7 @@ int numa_off __initdata;
47 * -1 if node overlap or lost ram (shift too big) 46 * -1 if node overlap or lost ram (shift too big)
48 */ 47 */
49static int __init 48static int __init
50populate_memnodemap(const struct node *nodes, int numnodes, int shift) 49populate_memnodemap(const struct bootnode *nodes, int numnodes, int shift)
51{ 50{
52 int i; 51 int i;
53 int res = -1; 52 int res = -1;
@@ -74,7 +73,7 @@ populate_memnodemap(const struct node *nodes, int numnodes, int shift)
74 return res; 73 return res;
75} 74}
76 75
77int __init compute_hash_shift(struct node *nodes, int numnodes) 76int __init compute_hash_shift(struct bootnode *nodes, int numnodes)
78{ 77{
79 int shift = 20; 78 int shift = 20;
80 79
@@ -149,7 +148,7 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
149/* Initialize final allocator for a zone */ 148/* Initialize final allocator for a zone */
150void __init setup_node_zones(int nodeid) 149void __init setup_node_zones(int nodeid)
151{ 150{
152 unsigned long start_pfn, end_pfn; 151 unsigned long start_pfn, end_pfn, memmapsize, limit;
153 unsigned long zones[MAX_NR_ZONES]; 152 unsigned long zones[MAX_NR_ZONES];
154 unsigned long holes[MAX_NR_ZONES]; 153 unsigned long holes[MAX_NR_ZONES];
155 154
@@ -159,6 +158,16 @@ void __init setup_node_zones(int nodeid)
159 Dprintk(KERN_INFO "Setting up node %d %lx-%lx\n", 158 Dprintk(KERN_INFO "Setting up node %d %lx-%lx\n",
160 nodeid, start_pfn, end_pfn); 159 nodeid, start_pfn, end_pfn);
161 160
161 /* Try to allocate mem_map at end to not fill up precious <4GB
162 memory. */
163 memmapsize = sizeof(struct page) * (end_pfn-start_pfn);
164 limit = end_pfn << PAGE_SHIFT;
165 NODE_DATA(nodeid)->node_mem_map =
166 __alloc_bootmem_core(NODE_DATA(nodeid)->bdata,
167 memmapsize, SMP_CACHE_BYTES,
168 round_down(limit - memmapsize, PAGE_SIZE),
169 limit);
170
162 size_zones(zones, holes, start_pfn, end_pfn); 171 size_zones(zones, holes, start_pfn, end_pfn);
163 free_area_init_node(nodeid, NODE_DATA(nodeid), zones, 172 free_area_init_node(nodeid, NODE_DATA(nodeid), zones,
164 start_pfn, holes); 173 start_pfn, holes);
@@ -191,7 +200,7 @@ int numa_fake __initdata = 0;
191static int numa_emulation(unsigned long start_pfn, unsigned long end_pfn) 200static int numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
192{ 201{
193 int i; 202 int i;
194 struct node nodes[MAX_NUMNODES]; 203 struct bootnode nodes[MAX_NUMNODES];
195 unsigned long sz = ((end_pfn - start_pfn)<<PAGE_SHIFT) / numa_fake; 204 unsigned long sz = ((end_pfn - start_pfn)<<PAGE_SHIFT) / numa_fake;
196 205
197 /* Kludge needed for the hash function */ 206 /* Kludge needed for the hash function */
@@ -357,8 +366,7 @@ void __init init_cpu_to_node(void)
357 366
358EXPORT_SYMBOL(cpu_to_node); 367EXPORT_SYMBOL(cpu_to_node);
359EXPORT_SYMBOL(node_to_cpumask); 368EXPORT_SYMBOL(node_to_cpumask);
360EXPORT_SYMBOL(memnode_shift); 369EXPORT_SYMBOL(memnode);
361EXPORT_SYMBOL(memnodemap);
362EXPORT_SYMBOL(node_data); 370EXPORT_SYMBOL(node_data);
363 371
364#ifdef CONFIG_DISCONTIGMEM 372#ifdef CONFIG_DISCONTIGMEM
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 482c25767369..2eb879590dc4 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -23,7 +23,7 @@ static struct acpi_table_slit *acpi_slit;
23 23
24static nodemask_t nodes_parsed __initdata; 24static nodemask_t nodes_parsed __initdata;
25static nodemask_t nodes_found __initdata; 25static nodemask_t nodes_found __initdata;
26static struct node nodes[MAX_NUMNODES] __initdata; 26static struct bootnode nodes[MAX_NUMNODES] __initdata;
27static u8 pxm2node[256] = { [0 ... 255] = 0xff }; 27static u8 pxm2node[256] = { [0 ... 255] = 0xff };
28 28
29/* Too small nodes confuse the VM badly. Usually they result 29/* Too small nodes confuse the VM badly. Usually they result
@@ -57,7 +57,7 @@ static __init int conflicting_nodes(unsigned long start, unsigned long end)
57{ 57{
58 int i; 58 int i;
59 for_each_node_mask(i, nodes_parsed) { 59 for_each_node_mask(i, nodes_parsed) {
60 struct node *nd = &nodes[i]; 60 struct bootnode *nd = &nodes[i];
61 if (nd->start == nd->end) 61 if (nd->start == nd->end)
62 continue; 62 continue;
63 if (nd->end > start && nd->start < end) 63 if (nd->end > start && nd->start < end)
@@ -70,7 +70,7 @@ static __init int conflicting_nodes(unsigned long start, unsigned long end)
70 70
71static __init void cutoff_node(int i, unsigned long start, unsigned long end) 71static __init void cutoff_node(int i, unsigned long start, unsigned long end)
72{ 72{
73 struct node *nd = &nodes[i]; 73 struct bootnode *nd = &nodes[i];
74 if (nd->start < start) { 74 if (nd->start < start) {
75 nd->start = start; 75 nd->start = start;
76 if (nd->end < nd->start) 76 if (nd->end < nd->start)
@@ -159,7 +159,7 @@ acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
159void __init 159void __init
160acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma) 160acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
161{ 161{
162 struct node *nd; 162 struct bootnode *nd;
163 unsigned long start, end; 163 unsigned long start, end;
164 int node, pxm; 164 int node, pxm;
165 int i; 165 int i;
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index 18f371fe37f8..e616500207e4 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)
55static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) 55static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
56{ 56{
57 char __iomem *addr; 57 char __iomem *addr;
58 if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), &fallback_slots)) 58 if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), fallback_slots))
59 return NULL; 59 return NULL;
60 addr = get_virt(seg, bus); 60 addr = get_virt(seg, bus);
61 if (!addr) 61 if (!addr)
@@ -143,29 +143,29 @@ static __init void unreachable_devices(void)
143 continue; 143 continue;
144 addr = pci_dev_base(0, 0, PCI_DEVFN(i, 0)); 144 addr = pci_dev_base(0, 0, PCI_DEVFN(i, 0));
145 if (addr == NULL|| readl(addr) != val1) { 145 if (addr == NULL|| readl(addr) != val1) {
146 set_bit(i, &fallback_slots); 146 set_bit(i, fallback_slots);
147 } 147 }
148 } 148 }
149} 149}
150 150
151static int __init pci_mmcfg_init(void) 151void __init pci_mmcfg_init(void)
152{ 152{
153 int i; 153 int i;
154 154
155 if ((pci_probe & PCI_PROBE_MMCONF) == 0) 155 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
156 return 0; 156 return;
157 157
158 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); 158 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
159 if ((pci_mmcfg_config_num == 0) || 159 if ((pci_mmcfg_config_num == 0) ||
160 (pci_mmcfg_config == NULL) || 160 (pci_mmcfg_config == NULL) ||
161 (pci_mmcfg_config[0].base_address == 0)) 161 (pci_mmcfg_config[0].base_address == 0))
162 return 0; 162 return;
163 163
164 /* RED-PEN i386 doesn't do _nocache right now */ 164 /* RED-PEN i386 doesn't do _nocache right now */
165 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); 165 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
166 if (pci_mmcfg_virt == NULL) { 166 if (pci_mmcfg_virt == NULL) {
167 printk("PCI: Can not allocate memory for mmconfig structures\n"); 167 printk("PCI: Can not allocate memory for mmconfig structures\n");
168 return 0; 168 return;
169 } 169 }
170 for (i = 0; i < pci_mmcfg_config_num; ++i) { 170 for (i = 0; i < pci_mmcfg_config_num; ++i) {
171 pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i]; 171 pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i];
@@ -173,7 +173,7 @@ static int __init pci_mmcfg_init(void)
173 if (!pci_mmcfg_virt[i].virt) { 173 if (!pci_mmcfg_virt[i].virt) {
174 printk("PCI: Cannot map mmconfig aperture for segment %d\n", 174 printk("PCI: Cannot map mmconfig aperture for segment %d\n",
175 pci_mmcfg_config[i].pci_segment_group_number); 175 pci_mmcfg_config[i].pci_segment_group_number);
176 return 0; 176 return;
177 } 177 }
178 printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_config[i].base_address); 178 printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_config[i].base_address);
179 } 179 }
@@ -182,8 +182,4 @@ static int __init pci_mmcfg_init(void)
182 182
183 raw_pci_ops = &pci_mmcfg; 183 raw_pci_ops = &pci_mmcfg;
184 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 184 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
185
186 return 0;
187} 185}
188
189arch_initcall(pci_mmcfg_init);
diff --git a/block/elevator.c b/block/elevator.c
index 5e558c4689a4..56c2ed06a9e2 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -728,8 +728,7 @@ void elv_unregister_queue(struct request_queue *q)
728int elv_register(struct elevator_type *e) 728int elv_register(struct elevator_type *e)
729{ 729{
730 spin_lock_irq(&elv_list_lock); 730 spin_lock_irq(&elv_list_lock);
731 if (elevator_find(e->elevator_name)) 731 BUG_ON(elevator_find(e->elevator_name));
732 BUG();
733 list_add_tail(&e->list, &elv_list); 732 list_add_tail(&e->list, &elv_list);
734 spin_unlock_irq(&elv_list_lock); 733 spin_unlock_irq(&elv_list_lock);
735 734
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 82710ae39228..5cb96300eb0f 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -256,7 +256,8 @@ config ACPI_CUSTOM_DSDT_FILE
256 depends on ACPI_CUSTOM_DSDT 256 depends on ACPI_CUSTOM_DSDT
257 default "" 257 default ""
258 help 258 help
259 Enter the full path name to the file wich includes the AmlCode declaration. 259 Enter the full path name to the file which includes the AmlCode
260 declaration.
260 261
261config ACPI_BLACKLIST_YEAR 262config ACPI_BLACKLIST_YEAR
262 int "Disable ACPI for systems before Jan 1st this year" if X86_32 263 int "Disable ACPI for systems before Jan 1st this year" if X86_32
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 9824f679a910..f9c972b26f4f 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -77,28 +77,13 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata = {
77 77
78static int __init blacklist_by_year(void) 78static int __init blacklist_by_year(void)
79{ 79{
80 int year; 80 int year = dmi_get_year(DMI_BIOS_DATE);
81 char *s = dmi_get_system_info(DMI_BIOS_DATE); 81 /* Doesn't exist? Likely an old system */
82 82 if (year == -1)
83 if (!s) 83 return 1;
84 return 0; 84 /* 0? Likely a buggy new BIOS */
85 if (!*s) 85 if (year == 0)
86 return 0;
87
88 s = strrchr(s, '/');
89 if (!s)
90 return 0; 86 return 0;
91
92 s += 1;
93
94 year = simple_strtoul(s, NULL, 0);
95
96 if (year < 100) { /* 2-digit year */
97 year += 1900;
98 if (year < 1996) /* no dates < spec 1.0 */
99 year += 100;
100 }
101
102 if (year < CONFIG_ACPI_BLACKLIST_YEAR) { 87 if (year < CONFIG_ACPI_BLACKLIST_YEAR) {
103 printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), " 88 printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), "
104 "acpi=force is required to enable ACPI\n", 89 "acpi=force is required to enable ACPI\n",
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index eb730a80952c..2be895895943 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -876,14 +876,11 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
876{ 876{
877 unsigned int i; 877 unsigned int i;
878 unsigned int working = 0; 878 unsigned int working = 0;
879 879 int timer_broadcast = 0;
880#ifdef ARCH_APICTIMER_STOPS_ON_C3
881 struct cpuinfo_x86 *c = cpu_data + pr->id;
882 cpumask_t mask = cpumask_of_cpu(pr->id); 880 cpumask_t mask = cpumask_of_cpu(pr->id);
883 881
884 if (c->x86_vendor == X86_VENDOR_INTEL) { 882#ifdef ARCH_APICTIMER_STOPS_ON_C3
885 on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1); 883 on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
886 }
887#endif 884#endif
888 885
889 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 886 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
@@ -896,15 +893,20 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
896 893
897 case ACPI_STATE_C2: 894 case ACPI_STATE_C2:
898 acpi_processor_power_verify_c2(cx); 895 acpi_processor_power_verify_c2(cx);
896#ifdef ARCH_APICTIMER_STOPS_ON_C3
897 /* Some AMD systems fake C3 as C2, but still
898 have timer troubles */
899 if (cx->valid &&
900 boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
901 timer_broadcast++;
902#endif
899 break; 903 break;
900 904
901 case ACPI_STATE_C3: 905 case ACPI_STATE_C3:
902 acpi_processor_power_verify_c3(pr, cx); 906 acpi_processor_power_verify_c3(pr, cx);
903#ifdef ARCH_APICTIMER_STOPS_ON_C3 907#ifdef ARCH_APICTIMER_STOPS_ON_C3
904 if (cx->valid && c->x86_vendor == X86_VENDOR_INTEL) { 908 if (cx->valid)
905 on_each_cpu(switch_APIC_timer_to_ipi, 909 timer_broadcast++;
906 &mask, 1, 1);
907 }
908#endif 910#endif
909 break; 911 break;
910 } 912 }
@@ -913,6 +915,9 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
913 working++; 915 working++;
914 } 916 }
915 917
918 if (timer_broadcast)
919 on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1);
920
916 return (working); 921 return (working);
917} 922}
918 923
diff --git a/drivers/atm/.gitignore b/drivers/atm/.gitignore
new file mode 100644
index 000000000000..a165b7167714
--- /dev/null
+++ b/drivers/atm/.gitignore
@@ -0,0 +1,5 @@
1# Ignore generated files
2fore200e_mkfirm
3fore200e_pca_fw.c
4pca200e.bin
5
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 29f3d7504da1..dd712b24ec91 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -19,11 +19,6 @@ EXPORT_SYMBOL(cpu_sysdev_class);
19static struct sys_device *cpu_sys_devices[NR_CPUS]; 19static struct sys_device *cpu_sys_devices[NR_CPUS];
20 20
21#ifdef CONFIG_HOTPLUG_CPU 21#ifdef CONFIG_HOTPLUG_CPU
22int __attribute__((weak)) smp_prepare_cpu (int cpu)
23{
24 return 0;
25}
26
27static ssize_t show_online(struct sys_device *dev, char *buf) 22static ssize_t show_online(struct sys_device *dev, char *buf)
28{ 23{
29 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 24 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,
44 kobject_uevent(&dev->kobj, KOBJ_OFFLINE); 39 kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
45 break; 40 break;
46 case '1': 41 case '1':
47 ret = smp_prepare_cpu(cpu->sysdev.id); 42 ret = cpu_up(cpu->sysdev.id);
48 if (!ret)
49 ret = cpu_up(cpu->sysdev.id);
50 if (!ret) 43 if (!ret)
51 kobject_uevent(&dev->kobj, KOBJ_ONLINE); 44 kobject_uevent(&dev->kobj, KOBJ_ONLINE);
52 break; 45 break;
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 37b8cda3e8bc..9bdea2a5cf0e 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,
228 void *cpu_end = loaf->cpu_free + len; 228 void *cpu_end = loaf->cpu_free + len;
229 void *cpu_addr = loaf->cpu_free; 229 void *cpu_addr = loaf->cpu_free;
230 230
231 if (cpu_end > loaf->cpu_base + loaf->length) 231 BUG_ON(cpu_end > loaf->cpu_base + loaf->length);
232 BUG();
233 *dma_handle = loaf->dma_free; 232 *dma_handle = loaf->dma_free;
234 loaf->cpu_free = cpu_end; 233 loaf->cpu_free = cpu_end;
235 loaf->dma_free += len; 234 loaf->dma_free += len;
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 8b1331677407..e57ac5a43246 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -401,7 +401,6 @@ config BLK_DEV_RAM_SIZE
401 401
402config BLK_DEV_INITRD 402config BLK_DEV_INITRD
403 bool "Initial RAM disk (initrd) support" 403 bool "Initial RAM disk (initrd) support"
404 depends on BLK_DEV_RAM=y
405 help 404 help
406 The initial RAM disk is a RAM disk that is loaded by the boot loader 405 The initial RAM disk is a RAM disk that is loaded by the boot loader
407 (loadlin or lilo) and that is mounted as root before the normal boot 406 (loadlin or lilo) and that is mounted as root before the normal boot
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 3ec1f8df87b1..410f259a8031 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -7,7 +7,6 @@
7 7
8obj-$(CONFIG_MAC_FLOPPY) += swim3.o 8obj-$(CONFIG_MAC_FLOPPY) += swim3.o
9obj-$(CONFIG_BLK_DEV_FD) += floppy.o 9obj-$(CONFIG_BLK_DEV_FD) += floppy.o
10obj-$(CONFIG_BLK_DEV_FD98) += floppy98.o
11obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o 10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o
12obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o 11obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
13obj-$(CONFIG_BLK_DEV_SWIM_IOP) += swim_iop.o 12obj-$(CONFIG_BLK_DEV_SWIM_IOP) += swim_iop.o
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index f8ce235ccfc3..c39650920bdf 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -271,7 +271,7 @@ unsigned char *DMABuffer; /* buffer for writes */
271static unsigned long PhysDMABuffer; /* physical address */ 271static unsigned long PhysDMABuffer; /* physical address */
272 272
273static int UseTrackbuffer = -1; /* Do track buffering? */ 273static int UseTrackbuffer = -1; /* Do track buffering? */
274MODULE_PARM(UseTrackbuffer, "i"); 274module_param(UseTrackbuffer, int, 0);
275 275
276unsigned char *TrackBuffer; /* buffer for reads */ 276unsigned char *TrackBuffer; /* buffer for reads */
277static unsigned long PhysTrackBuffer; /* physical address */ 277static unsigned long PhysTrackBuffer; /* physical address */
@@ -296,7 +296,7 @@ static int MotorOn = 0, MotorOffTrys;
296static int IsFormatting = 0, FormatError; 296static int IsFormatting = 0, FormatError;
297 297
298static int UserSteprate[FD_MAX_UNITS] = { -1, -1 }; 298static int UserSteprate[FD_MAX_UNITS] = { -1, -1 };
299MODULE_PARM(UserSteprate, "1-" __MODULE_STRING(FD_MAX_UNITS) "i"); 299module_param_array(UserSteprate, int, NULL, 0);
300 300
301/* Synchronization of FDC access. */ 301/* Synchronization of FDC access. */
302static volatile int fdc_busy = 0; 302static volatile int fdc_busy = 0;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 1f2890989b56..71ec9e664383 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2361,8 +2361,7 @@ queue:
2361 if (!creq) 2361 if (!creq)
2362 goto startio; 2362 goto startio;
2363 2363
2364 if (creq->nr_phys_segments > MAXSGENTRIES) 2364 BUG_ON(creq->nr_phys_segments > MAXSGENTRIES);
2365 BUG();
2366 2365
2367 if (( c = cmd_alloc(h, 1)) == NULL) 2366 if (( c = cmd_alloc(h, 1)) == NULL)
2368 goto full; 2367 goto full;
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 9e35de05d5c5..0e66e904bd8c 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
1316 1316
1317 cp->Request.Timeout = 0; 1317 cp->Request.Timeout = 0;
1318 memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB)); 1318 memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB));
1319 if (cmd->cmd_len > sizeof(cp->Request.CDB)) BUG(); 1319 BUG_ON(cmd->cmd_len > sizeof(cp->Request.CDB));
1320 cp->Request.CDBLen = cmd->cmd_len; 1320 cp->Request.CDBLen = cmd->cmd_len;
1321 memcpy(cp->Request.CDB, cmd->cmnd, cmd->cmd_len); 1321 memcpy(cp->Request.CDB, cmd->cmnd, cmd->cmd_len);
1322 cp->Request.Type.Type = TYPE_CMD; 1322 cp->Request.Type.Type = TYPE_CMD;
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 862b9abac0ae..b6ea2f0c7276 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -906,8 +906,7 @@ queue_next:
906 if (!creq) 906 if (!creq)
907 goto startio; 907 goto startio;
908 908
909 if (creq->nr_phys_segments > SG_MAX) 909 BUG_ON(creq->nr_phys_segments > SG_MAX);
910 BUG();
911 910
912 if ((c = cmd_alloc(h,1)) == NULL) 911 if ((c = cmd_alloc(h,1)) == NULL)
913 goto startio; 912 goto startio;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index fb2d0be7cdeb..840919bba76c 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4594,7 +4594,7 @@ static void __init parse_floppy_cfg_string(char *cfg)
4594 } 4594 }
4595} 4595}
4596 4596
4597int init_module(void) 4597int __init init_module(void)
4598{ 4598{
4599 if (floppy) 4599 if (floppy)
4600 parse_floppy_cfg_string(floppy); 4600 parse_floppy_cfg_string(floppy);
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a9bde30dadad..8bca4905d7f7 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -639,10 +639,7 @@ static int __init nbd_init(void)
639 int err = -ENOMEM; 639 int err = -ENOMEM;
640 int i; 640 int i;
641 641
642 if (sizeof(struct nbd_request) != 28) { 642 BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
643 printk(KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" );
644 return -EIO;
645 }
646 643
647 if (nbds_max > MAX_NBD) { 644 if (nbds_max > MAX_NBD) {
648 printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD, 645 printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
diff --git a/drivers/block/paride/comm.c b/drivers/block/paride/comm.c
index d842956edf76..43d61359d8ec 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 )
60 60
61 case 2: 61 case 2:
62 case 3: 62 case 3:
63 case 4: w3(r+0x20); r1(); 63 case 4: w3(r+0x20); (void)r1();
64 w2(0x24); h = r4(); w2(4); 64 w2(0x24); h = r4(); w2(4);
65 return h; 65 return h;
66 66
@@ -82,7 +82,7 @@ static void comm_write_regr( PIA *pi, int cont, int regr, int val )
82 82
83 case 2: 83 case 2:
84 case 3: 84 case 3:
85 case 4: w3(r); r1(); w4(val); 85 case 4: w3(r); (void)r1(); w4(val);
86 break; 86 break;
87 } 87 }
88} 88}
@@ -126,17 +126,17 @@ static void comm_read_block( PIA *pi, char * buf, int count )
126 w2(4); 126 w2(4);
127 break; 127 break;
128 128
129 case 2: w3(0x68); r1(); w2(0x24); 129 case 2: w3(0x68); (void)r1(); w2(0x24);
130 for (i=0;i<count;i++) buf[i] = r4(); 130 for (i=0;i<count;i++) buf[i] = r4();
131 w2(4); 131 w2(4);
132 break; 132 break;
133 133
134 case 3: w3(0x68); r1(); w2(0x24); 134 case 3: w3(0x68); (void)r1(); w2(0x24);
135 for (i=0;i<count/2;i++) ((u16 *)buf)[i] = r4w(); 135 for (i=0;i<count/2;i++) ((u16 *)buf)[i] = r4w();
136 w2(4); 136 w2(4);
137 break; 137 break;
138 138
139 case 4: w3(0x68); r1(); w2(0x24); 139 case 4: w3(0x68); (void)r1(); w2(0x24);
140 for (i=0;i<count/4;i++) ((u32 *)buf)[i] = r4l(); 140 for (i=0;i<count/4;i++) ((u32 *)buf)[i] = r4l();
141 w2(4); 141 w2(4);
142 break; 142 break;
@@ -160,15 +160,15 @@ static void comm_write_block( PIA *pi, char * buf, int count )
160 w2(5); w2(4); 160 w2(5); w2(4);
161 break; 161 break;
162 162
163 case 2: w3(0x48); r1(); 163 case 2: w3(0x48); (void)r1();
164 for (k=0;k<count;k++) w4(buf[k^1]); 164 for (k=0;k<count;k++) w4(buf[k^1]);
165 break; 165 break;
166 166
167 case 3: w3(0x48); r1(); 167 case 3: w3(0x48); (void)r1();
168 for (k=0;k<count/2;k++) w4w(pi_swab16(buf,k)); 168 for (k=0;k<count/2;k++) w4w(pi_swab16(buf,k));
169 break; 169 break;
170 170
171 case 4: w3(0x48); r1(); 171 case 4: w3(0x48); (void)r1();
172 for (k=0;k<count/4;k++) w4l(pi_swab32(buf,k)); 172 for (k=0;k<count/4;k++) w4l(pi_swab32(buf,k));
173 break; 173 break;
174 174
diff --git a/drivers/block/paride/on26.c b/drivers/block/paride/on26.c
index 9f837d9a3639..0f833caa2101 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 )
66 case 3: 66 case 3:
67 case 4: w3(1); w3(1); w2(5); w4(r); w2(4); 67 case 4: w3(1); w3(1); w2(5); w4(r); w2(4);
68 w3(0); w3(0); w2(0x24); a = r4(); w2(4); 68 w3(0); w3(0); w2(0x24); a = r4(); w2(4);
69 w2(0x24); r4(); w2(4); 69 w2(0x24); (void)r4(); w2(4);
70 return a; 70 return a;
71 71
72 } 72 }
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 1c54f46d3f70..940bfd7951e5 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -186,7 +186,8 @@ static int ramdisk_writepages(struct address_space *mapping,
186 */ 186 */
187static int ramdisk_set_page_dirty(struct page *page) 187static int ramdisk_set_page_dirty(struct page *page)
188{ 188{
189 SetPageDirty(page); 189 if (!TestSetPageDirty(page))
190 return 1;
190 return 0; 191 return 0;
191} 192}
192 193
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
index fad27a87ce35..f43a988dd413 100644
--- a/drivers/cdrom/cm206.c
+++ b/drivers/cdrom/cm206.c
@@ -218,12 +218,12 @@ static int cm206_base = CM206_BASE;
218static int cm206_irq = CM206_IRQ; 218static int cm206_irq = CM206_IRQ;
219#ifdef MODULE 219#ifdef MODULE
220static int cm206[2] = { 0, 0 }; /* for compatible `insmod' parameter passing */ 220static int cm206[2] = { 0, 0 }; /* for compatible `insmod' parameter passing */
221module_param_array(cm206, int, NULL, 0); /* base,irq or irq,base */
221#endif 222#endif
222 223
223MODULE_PARM(cm206_base, "i"); /* base */ 224module_param(cm206_base, int, 0); /* base */
224MODULE_PARM(cm206_irq, "i"); /* irq */ 225module_param(cm206_irq, int, 0); /* irq */
225MODULE_PARM(cm206, "1-2i"); /* base,irq or irq,base */ 226module_param(auto_probe, bool, 0); /* auto probe base and irq */
226MODULE_PARM(auto_probe, "i"); /* auto probe base and irq */
227MODULE_LICENSE("GPL"); 227MODULE_LICENSE("GPL");
228 228
229#define POLLOOP 100 /* milliseconds */ 229#define POLLOOP 100 /* milliseconds */
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index 4760f515f591..05c9e865ecaf 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -464,8 +464,13 @@ static int sbpcd[] =
464static __cacheline_aligned DEFINE_SPINLOCK(sbpcd_lock); 464static __cacheline_aligned DEFINE_SPINLOCK(sbpcd_lock);
465static struct request_queue *sbpcd_queue; 465static struct request_queue *sbpcd_queue;
466 466
467MODULE_PARM(sbpcd, "2i"); 467/* You can only set the first pair, from old MODULE_PARM code. */
468MODULE_PARM(max_drives, "i"); 468static int sbpcd_set(const char *val, struct kernel_param *kp)
469{
470 get_options((char *)val, 2, (int *)sbpcd);
471 return 0;
472}
473module_param_call(sbpcd, sbpcd_set, NULL, NULL, 0);
469 474
470#define NUM_PROBE (sizeof(sbpcd) / sizeof(int)) 475#define NUM_PROBE (sizeof(sbpcd) / sizeof(int))
471 476
@@ -553,6 +558,7 @@ static unsigned char msgnum;
553static char msgbuf[80]; 558static char msgbuf[80];
554 559
555static int max_drives = MAX_DRIVES; 560static int max_drives = MAX_DRIVES;
561module_param(max_drives, int, 0);
556#ifndef MODULE 562#ifndef MODULE
557static unsigned char setup_done; 563static unsigned char setup_done;
558static const char *str_sb_l = "soundblaster"; 564static const char *str_sb_l = "soundblaster";
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index b524f5ba78a9..5980f3e886fc 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -290,7 +290,7 @@ config SX
290 290
291config RIO 291config RIO
292 tristate "Specialix RIO system support" 292 tristate "Specialix RIO system support"
293 depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && !64BIT 293 depends on SERIAL_NONSTANDARD && !64BIT
294 help 294 help
295 This is a driver for the Specialix RIO, a smart serial card which 295 This is a driver for the Specialix RIO, a smart serial card which
296 drives an outboard box that can support up to 128 ports. Product 296 drives an outboard box that can support up to 128 ports. Product
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 090d154098bb..b2a11245fa95 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
45obj-$(CONFIG_RAW_DRIVER) += raw.o 45obj-$(CONFIG_RAW_DRIVER) += raw.o
46obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 46obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
47obj-$(CONFIG_MMTIMER) += mmtimer.o 47obj-$(CONFIG_MMTIMER) += mmtimer.o
48obj-$(CONFIG_VIOCONS) += viocons.o 48obj-$(CONFIG_VIOCONS) += viocons.o
49obj-$(CONFIG_VIOTAPE) += viotape.o 49obj-$(CONFIG_VIOTAPE) += viotape.o
50obj-$(CONFIG_HVCS) += hvcs.o 50obj-$(CONFIG_HVCS) += hvcs.o
51obj-$(CONFIG_SGI_MBCS) += mbcs.o 51obj-$(CONFIG_SGI_MBCS) += mbcs.o
52 52
53obj-$(CONFIG_PRINTER) += lp.o 53obj-$(CONFIG_PRINTER) += lp.o
54obj-$(CONFIG_TIPAR) += tipar.o 54obj-$(CONFIG_TIPAR) += tipar.o
55 55
56obj-$(CONFIG_DTLK) += dtlk.o 56obj-$(CONFIG_DTLK) += dtlk.o
57obj-$(CONFIG_R3964) += n_r3964.o 57obj-$(CONFIG_R3964) += n_r3964.o
58obj-$(CONFIG_APPLICOM) += applicom.o 58obj-$(CONFIG_APPLICOM) += applicom.o
59obj-$(CONFIG_SONYPI) += sonypi.o 59obj-$(CONFIG_SONYPI) += sonypi.o
60obj-$(CONFIG_RTC) += rtc.o 60obj-$(CONFIG_RTC) += rtc.o
61obj-$(CONFIG_HPET) += hpet.o 61obj-$(CONFIG_HPET) += hpet.o
62obj-$(CONFIG_GEN_RTC) += genrtc.o 62obj-$(CONFIG_GEN_RTC) += genrtc.o
63obj-$(CONFIG_EFI_RTC) += efirtc.o 63obj-$(CONFIG_EFI_RTC) += efirtc.o
64obj-$(CONFIG_SGI_DS1286) += ds1286.o 64obj-$(CONFIG_SGI_DS1286) += ds1286.o
65obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o 65obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
66obj-$(CONFIG_DS1302) += ds1302.o 66obj-$(CONFIG_DS1302) += ds1302.o
67obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o 67obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o
68obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o 68obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o
69ifeq ($(CONFIG_GENERIC_NVRAM),y) 69ifeq ($(CONFIG_GENERIC_NVRAM),y)
70 obj-$(CONFIG_NVRAM) += generic_nvram.o 70 obj-$(CONFIG_NVRAM) += generic_nvram.o
71else 71else
72 obj-$(CONFIG_NVRAM) += nvram.o 72 obj-$(CONFIG_NVRAM) += nvram.o
73endif 73endif
74obj-$(CONFIG_TOSHIBA) += toshiba.o 74obj-$(CONFIG_TOSHIBA) += toshiba.o
75obj-$(CONFIG_I8K) += i8k.o 75obj-$(CONFIG_I8K) += i8k.o
76obj-$(CONFIG_DS1620) += ds1620.o 76obj-$(CONFIG_DS1620) += ds1620.o
77obj-$(CONFIG_HW_RANDOM) += hw_random.o 77obj-$(CONFIG_HW_RANDOM) += hw_random.o
78obj-$(CONFIG_FTAPE) += ftape/ 78obj-$(CONFIG_FTAPE) += ftape/
79obj-$(CONFIG_COBALT_LCD) += lcd.o 79obj-$(CONFIG_COBALT_LCD) += lcd.o
80obj-$(CONFIG_PPDEV) += ppdev.o 80obj-$(CONFIG_PPDEV) += ppdev.o
81obj-$(CONFIG_NWBUTTON) += nwbutton.o 81obj-$(CONFIG_NWBUTTON) += nwbutton.o
82obj-$(CONFIG_NWFLASH) += nwflash.o 82obj-$(CONFIG_NWFLASH) += nwflash.o
83obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 83obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
84obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o 84obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
85obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o 85obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
86obj-$(CONFIG_TANBAC_TB0219) += tb0219.o 86obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
87obj-$(CONFIG_TELCLOCK) += tlclk.o 87obj-$(CONFIG_TELCLOCK) += tlclk.o
88 88
89obj-$(CONFIG_WATCHDOG) += watchdog/ 89obj-$(CONFIG_WATCHDOG) += watchdog/
90obj-$(CONFIG_MWAVE) += mwave/ 90obj-$(CONFIG_MWAVE) += mwave/
91obj-$(CONFIG_AGP) += agp/ 91obj-$(CONFIG_AGP) += agp/
92obj-$(CONFIG_DRM) += drm/ 92obj-$(CONFIG_DRM) += drm/
93obj-$(CONFIG_PCMCIA) += pcmcia/ 93obj-$(CONFIG_PCMCIA) += pcmcia/
94obj-$(CONFIG_IPMI_HANDLER) += ipmi/ 94obj-$(CONFIG_IPMI_HANDLER) += ipmi/
95 95
96obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o 96obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
97obj-$(CONFIG_TCG_TPM) += tpm/ 97obj-$(CONFIG_TCG_TPM) += tpm/
98
98# Files generated that shall be removed upon make clean 99# Files generated that shall be removed upon make clean
99clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c 100clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c
100 101
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index a4d425d2dce2..0b9cf9c59a21 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -98,12 +98,12 @@ config AGP_SWORKS
98 tristate "Serverworks LE/HE chipset support" 98 tristate "Serverworks LE/HE chipset support"
99 depends on AGP && X86_32 99 depends on AGP && X86_32
100 help 100 help
101 Say Y here to support the Serverworks AGP card. See 101 Say Y here to support the Serverworks AGP card. See
102 <http://www.serverworks.com/> for product descriptions and images. 102 <http://www.serverworks.com/> for product descriptions and images.
103 103
104config AGP_VIA 104config AGP_VIA
105 tristate "VIA chipset support" 105 tristate "VIA chipset support"
106 depends on AGP && X86_32 106 depends on AGP
107 help 107 help
108 This option gives you AGP support for the GLX component of 108 This option gives you AGP support for the GLX component of
109 X on VIA MVP3/Apollo Pro chipsets. 109 X on VIA MVP3/Apollo Pro chipsets.
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index b4af87c6f9c8..3c623b67ea1c 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -19,9 +19,9 @@
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 22 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
25 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * 26 *
27 */ 27 */
@@ -53,7 +53,7 @@ enum aper_size_type {
53struct gatt_mask { 53struct gatt_mask {
54 unsigned long mask; 54 unsigned long mask;
55 u32 type; 55 u32 type;
56 /* totally device specific, for integrated chipsets that 56 /* totally device specific, for integrated chipsets that
57 * might have different types of memory masks. For other 57 * might have different types of memory masks. For other
58 * devices this will probably be ignored */ 58 * devices this will probably be ignored */
59}; 59};
@@ -104,8 +104,7 @@ struct agp_bridge_driver {
104 void (*agp_enable)(struct agp_bridge_data *, u32); 104 void (*agp_enable)(struct agp_bridge_data *, u32);
105 void (*cleanup)(void); 105 void (*cleanup)(void);
106 void (*tlb_flush)(struct agp_memory *); 106 void (*tlb_flush)(struct agp_memory *);
107 unsigned long (*mask_memory)(struct agp_bridge_data *, 107 unsigned long (*mask_memory)(struct agp_bridge_data *, unsigned long, int);
108 unsigned long, int);
109 void (*cache_flush)(void); 108 void (*cache_flush)(void);
110 int (*create_gatt_table)(struct agp_bridge_data *); 109 int (*create_gatt_table)(struct agp_bridge_data *);
111 int (*free_gatt_table)(struct agp_bridge_data *); 110 int (*free_gatt_table)(struct agp_bridge_data *);
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index b02fc2267159..5a31ec7c62fc 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -147,7 +147,7 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge)
147 147
148 if (!addr) 148 if (!addr)
149 return NULL; 149 return NULL;
150 150
151 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 151 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
152 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 152 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
153 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 153 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index a072d32005a4..2b5838e64751 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -23,8 +23,9 @@ static struct page *alpha_core_agp_vm_nopage(struct vm_area_struct *vma,
23 dma_addr = address - vma->vm_start + agp->aperture.bus_base; 23 dma_addr = address - vma->vm_start + agp->aperture.bus_base;
24 pa = agp->ops->translate(agp, dma_addr); 24 pa = agp->ops->translate(agp, dma_addr);
25 25
26 if (pa == (unsigned long)-EINVAL) return NULL; /* no translation */ 26 if (pa == (unsigned long)-EINVAL)
27 27 return NULL; /* no translation */
28
28 /* 29 /*
29 * Get the page, inc the use count, and return it 30 * Get the page, inc the use count, and return it
30 */ 31 */
@@ -89,7 +90,7 @@ static void alpha_core_agp_enable(struct agp_bridge_data *bridge, u32 mode)
89 agp_device_command(agp->mode.lw, 0); 90 agp_device_command(agp->mode.lw, 0);
90} 91}
91 92
92static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start, 93static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
93 int type) 94 int type)
94{ 95{
95 alpha_agp_info *agp = agp_bridge->dev_private_data; 96 alpha_agp_info *agp = agp_bridge->dev_private_data;
@@ -98,7 +99,8 @@ static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
98 99
99 temp = agp_bridge->current_size; 100 temp = agp_bridge->current_size;
100 num_entries = A_SIZE_FIX(temp)->num_entries; 101 num_entries = A_SIZE_FIX(temp)->num_entries;
101 if ((pg_start + mem->page_count) > num_entries) return -EINVAL; 102 if ((pg_start + mem->page_count) > num_entries)
103 return -EINVAL;
102 104
103 status = agp->ops->bind(agp, pg_start, mem); 105 status = agp->ops->bind(agp, pg_start, mem);
104 mb(); 106 mb();
@@ -107,7 +109,7 @@ static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
107 return status; 109 return status;
108} 110}
109 111
110static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start, 112static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start,
111 int type) 113 int type)
112{ 114{
113 alpha_agp_info *agp = agp_bridge->dev_private_data; 115 alpha_agp_info *agp = agp_bridge->dev_private_data;
@@ -125,7 +127,7 @@ struct agp_bridge_driver alpha_core_agp_driver = {
125 .size_type = FIXED_APER_SIZE, 127 .size_type = FIXED_APER_SIZE,
126 .cant_use_aperture = 1, 128 .cant_use_aperture = 1,
127 .masks = NULL, 129 .masks = NULL,
128 130
129 .fetch_size = alpha_core_agp_fetch_size, 131 .fetch_size = alpha_core_agp_fetch_size,
130 .configure = alpha_core_agp_configure, 132 .configure = alpha_core_agp_configure,
131 .agp_enable = alpha_core_agp_enable, 133 .agp_enable = alpha_core_agp_enable,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 1251b2515bbe..36517d4d1ad9 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -216,7 +216,7 @@ static struct aper_size_info_32 amd_8151_sizes[7] =
216 {256, 65536, 6, 0x00000700 }, /* 1 1 1 0 0 0 */ 216 {256, 65536, 6, 0x00000700 }, /* 1 1 1 0 0 0 */
217 {128, 32768, 5, 0x00000720 }, /* 1 1 1 1 0 0 */ 217 {128, 32768, 5, 0x00000720 }, /* 1 1 1 1 0 0 */
218 {64, 16384, 4, 0x00000730 }, /* 1 1 1 1 1 0 */ 218 {64, 16384, 4, 0x00000730 }, /* 1 1 1 1 1 0 */
219 {32, 8192, 3, 0x00000738 } /* 1 1 1 1 1 1 */ 219 {32, 8192, 3, 0x00000738 } /* 1 1 1 1 1 1 */
220}; 220};
221 221
222static int amd_8151_configure(void) 222static int amd_8151_configure(void)
@@ -725,7 +725,7 @@ static struct pci_device_id agp_amd64_pci_table[] = {
725 .class = (PCI_CLASS_BRIDGE_HOST << 8), 725 .class = (PCI_CLASS_BRIDGE_HOST << 8),
726 .class_mask = ~0, 726 .class_mask = ~0,
727 .vendor = PCI_VENDOR_ID_AL, 727 .vendor = PCI_VENDOR_ID_AL,
728 .device = 0x1689, 728 .device = 0x1695,
729 .subvendor = PCI_ANY_ID, 729 .subvendor = PCI_ANY_ID,
730 .subdevice = PCI_ANY_ID, 730 .subdevice = PCI_ANY_ID,
731 }, 731 },
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 5b74c36c116c..06fd10ba0c5e 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -74,7 +74,7 @@ static int ati_create_page_map(ati_page_map *page_map)
74 /*CACHE_FLUSH();*/ 74 /*CACHE_FLUSH();*/
75 global_cache_flush(); 75 global_cache_flush();
76 76
77 for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) { 77 for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
78 writel(agp_bridge->scratch_page, page_map->remapped+i); 78 writel(agp_bridge->scratch_page, page_map->remapped+i);
79 readl(page_map->remapped+i); /* PCI Posting. */ 79 readl(page_map->remapped+i); /* PCI Posting. */
80 } 80 }
@@ -99,7 +99,7 @@ static void ati_free_gatt_pages(void)
99 ati_page_map *entry; 99 ati_page_map *entry;
100 100
101 tables = ati_generic_private.gatt_pages; 101 tables = ati_generic_private.gatt_pages;
102 for(i = 0; i < ati_generic_private.num_tables; i++) { 102 for (i = 0; i < ati_generic_private.num_tables; i++) {
103 entry = tables[i]; 103 entry = tables[i];
104 if (entry != NULL) { 104 if (entry != NULL) {
105 if (entry->real != NULL) 105 if (entry->real != NULL)
@@ -387,7 +387,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
387 agp_bridge->gart_bus_addr = addr; 387 agp_bridge->gart_bus_addr = addr;
388 388
389 /* Calculate the agp offset */ 389 /* Calculate the agp offset */
390 for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { 390 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
391 writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1, 391 writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1,
392 page_dir.remapped+GET_PAGE_DIR_OFF(addr)); 392 page_dir.remapped+GET_PAGE_DIR_OFF(addr));
393 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ 393 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
@@ -466,6 +466,10 @@ static struct agp_device_ids ati_agp_device_ids[] __devinitdata =
466 .device_id = PCI_DEVICE_ID_ATI_RS300_200, 466 .device_id = PCI_DEVICE_ID_ATI_RS300_200,
467 .chipset_name = "IGP9100/M", 467 .chipset_name = "IGP9100/M",
468 }, 468 },
469 {
470 .device_id = PCI_DEVICE_ID_ATI_RS350_200,
471 .chipset_name = "IGP9100/M",
472 },
469 { }, /* dummy final entry, always present */ 473 { }, /* dummy final entry, always present */
470}; 474};
471 475
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 80ee17a8fc23..509adc403250 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -228,7 +228,7 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
228struct agp_bridge_data *agp_alloc_bridge(void) 228struct agp_bridge_data *agp_alloc_bridge(void)
229{ 229{
230 struct agp_bridge_data *bridge; 230 struct agp_bridge_data *bridge;
231 231
232 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); 232 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
233 if (!bridge) 233 if (!bridge)
234 return NULL; 234 return NULL;
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index e7aea77a60f9..fed0a87448d8 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Transmeta's Efficeon AGPGART driver. 2 * Transmeta's Efficeon AGPGART driver.
3 * 3 *
4 * Based upon a diff by Linus around November '02. 4 * Based upon a diff by Linus around November '02.
5 * 5 *
6 * Ported to the 2.6 kernel by Carlos Puchol <cpglinux@puchol.com> 6 * Ported to the 2.6 kernel by Carlos Puchol <cpglinux@puchol.com>
@@ -9,7 +9,7 @@
9 9
10/* 10/*
11 * NOTE-cpg-040217: 11 * NOTE-cpg-040217:
12 * 12 *
13 * - when compiled as a module, after loading the module, 13 * - when compiled as a module, after loading the module,
14 * it will refuse to unload, indicating it is in use, 14 * it will refuse to unload, indicating it is in use,
15 * when it is not. 15 * when it is not.
@@ -45,7 +45,7 @@
45 * 8: Present 45 * 8: Present
46 * 7:6: reserved, write as zero 46 * 7:6: reserved, write as zero
47 * 5:0: GATT directory index: which 1st-level entry 47 * 5:0: GATT directory index: which 1st-level entry
48 * 48 *
49 * The Efficeon AGP spec requires pages to be WB-cacheable 49 * The Efficeon AGP spec requires pages to be WB-cacheable
50 * but to be explicitly CLFLUSH'd after any changes. 50 * but to be explicitly CLFLUSH'd after any changes.
51 */ 51 */
@@ -125,7 +125,7 @@ static int efficeon_configure(void)
125 struct aper_size_info_lvl2 *current_size; 125 struct aper_size_info_lvl2 *current_size;
126 126
127 printk(KERN_DEBUG PFX "efficeon_configure()\n"); 127 printk(KERN_DEBUG PFX "efficeon_configure()\n");
128 128
129 current_size = A_SIZE_LVL2(agp_bridge->current_size); 129 current_size = A_SIZE_LVL2(agp_bridge->current_size);
130 130
131 /* aperture size */ 131 /* aperture size */
@@ -190,7 +190,7 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge)
190 const int present = EFFICEON_PRESENT; 190 const int present = EFFICEON_PRESENT;
191 const int clflush_chunk = ((cpuid_ebx(1) >> 8) & 0xff) << 3; 191 const int clflush_chunk = ((cpuid_ebx(1) >> 8) & 0xff) << 3;
192 int num_entries, l1_pages; 192 int num_entries, l1_pages;
193 193
194 num_entries = A_SIZE_LVL2(agp_bridge->current_size)->num_entries; 194 num_entries = A_SIZE_LVL2(agp_bridge->current_size)->num_entries;
195 195
196 printk(KERN_DEBUG PFX "efficeon_create_gatt_table(%d)\n", num_entries); 196 printk(KERN_DEBUG PFX "efficeon_create_gatt_table(%d)\n", num_entries);
@@ -257,12 +257,12 @@ static int efficeon_insert_memory(struct agp_memory * mem, off_t pg_start, int t
257 257
258 if (!page) 258 if (!page)
259 continue; 259 continue;
260 260
261 page += (index & 0x3ff); 261 page += (index & 0x3ff);
262 *page = insert; 262 *page = insert;
263 263
264 /* clflush is slow, so don't clflush until we have to */ 264 /* clflush is slow, so don't clflush until we have to */
265 if ( last_page && 265 if ( last_page &&
266 ((unsigned long)page^(unsigned long)last_page) & clflush_mask ) 266 ((unsigned long)page^(unsigned long)last_page) & clflush_mask )
267 asm volatile("clflush %0" : : "m" (*last_page)); 267 asm volatile("clflush %0" : : "m" (*last_page));
268 268
@@ -373,7 +373,7 @@ static int __devinit agp_efficeon_probe(struct pci_dev *pdev,
373 */ 373 */
374 r = &pdev->resource[0]; 374 r = &pdev->resource[0];
375 if (!r->start && r->end) { 375 if (!r->start && r->end) {
376 if(pci_assign_resource(pdev, 0)) { 376 if (pci_assign_resource(pdev, 0)) {
377 printk(KERN_ERR PFX "could not assign resource 0\n"); 377 printk(KERN_ERR PFX "could not assign resource 0\n");
378 return -ENODEV; 378 return -ENODEV;
379 } 379 }
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 97eeb2345b18..ffcf15c30e90 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -781,7 +781,7 @@ static int agpioc_acquire_wrap(struct agp_file_private *priv)
781 if (agp_fe.current_controller != NULL) 781 if (agp_fe.current_controller != NULL)
782 return -EBUSY; 782 return -EBUSY;
783 783
784 if(!agp_bridge) 784 if (!agp_bridge)
785 return -ENODEV; 785 return -ENODEV;
786 786
787 if (atomic_read(&agp_bridge->agp_in_use)) 787 if (atomic_read(&agp_bridge->agp_in_use))
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 5567ce8d72b0..4e1891e2c035 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -299,7 +299,7 @@ EXPORT_SYMBOL_GPL(agp_num_entries);
299/** 299/**
300 * agp_copy_info - copy bridge state information 300 * agp_copy_info - copy bridge state information
301 * 301 *
302 * @info: agp_kern_info pointer. The caller should insure that this pointer is valid. 302 * @info: agp_kern_info pointer. The caller should insure that this pointer is valid.
303 * 303 *
304 * This function copies information about the agp bridge device and the state of 304 * This function copies information about the agp bridge device and the state of
305 * the agp backend into an agp_kern_info pointer. 305 * the agp backend into an agp_kern_info pointer.
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index de5d6d212674..8c4c6ef748ec 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -85,8 +85,8 @@ static int __init hp_zx1_ioc_shared(void)
85 /* 85 /*
86 * IOC already configured by sba_iommu module; just use 86 * IOC already configured by sba_iommu module; just use
87 * its setup. We assume: 87 * its setup. We assume:
88 * - IOVA space is 1Gb in size 88 * - IOVA space is 1Gb in size
89 * - first 512Mb is IOMMU, second 512Mb is GART 89 * - first 512Mb is IOMMU, second 512Mb is GART
90 */ 90 */
91 hp->io_tlb_ps = readq(hp->ioc_regs+HP_ZX1_TCNFG); 91 hp->io_tlb_ps = readq(hp->ioc_regs+HP_ZX1_TCNFG);
92 switch (hp->io_tlb_ps) { 92 switch (hp->io_tlb_ps) {
@@ -115,7 +115,7 @@ static int __init hp_zx1_ioc_shared(void)
115 115
116 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { 116 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
117 /* Normal case when no AGP device in system */ 117 /* Normal case when no AGP device in system */
118 hp->gatt = NULL; 118 hp->gatt = NULL;
119 hp->gatt_entries = 0; 119 hp->gatt_entries = 0;
120 printk(KERN_ERR PFX "No reserved IO PDIR entry found; " 120 printk(KERN_ERR PFX "No reserved IO PDIR entry found; "
121 "GART disabled\n"); 121 "GART disabled\n");
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 8ee19a4a6bce..91769443d8fe 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -400,10 +400,10 @@ static int i460_insert_memory_large_io_page (struct agp_memory *mem,
400 num_entries = A_SIZE_8(temp)->num_entries; 400 num_entries = A_SIZE_8(temp)->num_entries;
401 401
402 /* Figure out what pg_start means in terms of our large GART pages */ 402 /* Figure out what pg_start means in terms of our large GART pages */
403 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE]; 403 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
404 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE]; 404 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
405 start_offset = pg_start % I460_KPAGES_PER_IOPAGE; 405 start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
406 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE; 406 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
407 407
408 if (end > i460.lp_desc + num_entries) { 408 if (end > i460.lp_desc + num_entries) {
409 printk(KERN_ERR PFX "Looks like we're out of AGP memory\n"); 409 printk(KERN_ERR PFX "Looks like we're out of AGP memory\n");
@@ -458,10 +458,10 @@ static int i460_remove_memory_large_io_page (struct agp_memory *mem,
458 num_entries = A_SIZE_8(temp)->num_entries; 458 num_entries = A_SIZE_8(temp)->num_entries;
459 459
460 /* Figure out what pg_start means in terms of our large GART pages */ 460 /* Figure out what pg_start means in terms of our large GART pages */
461 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE]; 461 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
462 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE]; 462 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
463 start_offset = pg_start % I460_KPAGES_PER_IOPAGE; 463 start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
464 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE; 464 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
465 465
466 for (i = 0, lp = start; lp <= end; ++lp) { 466 for (i = 0, lp = start; lp <= end; ++lp) {
467 for (idx = ((lp == start) ? start_offset : 0); 467 for (idx = ((lp == start) ? start_offset : 0);
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 631531fd97a5..bddcae54b16d 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -201,9 +201,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
201 temp = agp_bridge->current_size; 201 temp = agp_bridge->current_size;
202 num_entries = A_SIZE_FIX(temp)->num_entries; 202 num_entries = A_SIZE_FIX(temp)->num_entries;
203 203
204 if ((pg_start + mem->page_count) > num_entries) { 204 if ((pg_start + mem->page_count) > num_entries)
205 return -EINVAL; 205 return -EINVAL;
206 } 206
207 for (j = pg_start; j < (pg_start + mem->page_count); j++) { 207 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
208 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) 208 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j)))
209 return -EBUSY; 209 return -EBUSY;
@@ -221,7 +221,7 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
221 agp_bridge->driver->tlb_flush(mem); 221 agp_bridge->driver->tlb_flush(mem);
222 return 0; 222 return 0;
223 } 223 }
224 if((type == AGP_PHYS_MEMORY) && (mem->type == AGP_PHYS_MEMORY)) 224 if ((type == AGP_PHYS_MEMORY) && (mem->type == AGP_PHYS_MEMORY))
225 goto insert; 225 goto insert;
226 return -EINVAL; 226 return -EINVAL;
227 } 227 }
@@ -328,7 +328,7 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
328static void intel_i810_free_by_type(struct agp_memory *curr) 328static void intel_i810_free_by_type(struct agp_memory *curr)
329{ 329{
330 agp_free_key(curr->key); 330 agp_free_key(curr->key);
331 if(curr->type == AGP_PHYS_MEMORY) { 331 if (curr->type == AGP_PHYS_MEMORY) {
332 if (curr->page_count == 4) 332 if (curr->page_count == 4)
333 i8xx_destroy_pages(gart_to_virt(curr->memory[0])); 333 i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
334 else { 334 else {
@@ -1603,11 +1603,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1603 name = "i820"; 1603 name = "i820";
1604 break; 1604 break;
1605 case PCI_DEVICE_ID_INTEL_82830_HB: 1605 case PCI_DEVICE_ID_INTEL_82830_HB:
1606 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC)) { 1606 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1607 bridge->driver = &intel_830_driver; 1607 bridge->driver = &intel_830_driver;
1608 } else { 1608 else
1609 bridge->driver = &intel_830mp_driver; 1609 bridge->driver = &intel_830mp_driver;
1610 }
1611 name = "830M"; 1610 name = "830M";
1612 break; 1611 break;
1613 case PCI_DEVICE_ID_INTEL_82840_HB: 1612 case PCI_DEVICE_ID_INTEL_82840_HB:
@@ -1619,11 +1618,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1619 name = "i845"; 1618 name = "i845";
1620 break; 1619 break;
1621 case PCI_DEVICE_ID_INTEL_82845G_HB: 1620 case PCI_DEVICE_ID_INTEL_82845G_HB:
1622 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG)) { 1621 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1623 bridge->driver = &intel_830_driver; 1622 bridge->driver = &intel_830_driver;
1624 } else { 1623 else
1625 bridge->driver = &intel_845_driver; 1624 bridge->driver = &intel_845_driver;
1626 }
1627 name = "845G"; 1625 name = "845G";
1628 break; 1626 break;
1629 case PCI_DEVICE_ID_INTEL_82850_HB: 1627 case PCI_DEVICE_ID_INTEL_82850_HB:
@@ -1648,11 +1646,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1648 name = "i860"; 1646 name = "i860";
1649 break; 1647 break;
1650 case PCI_DEVICE_ID_INTEL_82865_HB: 1648 case PCI_DEVICE_ID_INTEL_82865_HB:
1651 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG)) { 1649 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1652 bridge->driver = &intel_830_driver; 1650 bridge->driver = &intel_830_driver;
1653 } else { 1651 else
1654 bridge->driver = &intel_845_driver; 1652 bridge->driver = &intel_845_driver;
1655 }
1656 name = "865"; 1653 name = "865";
1657 break; 1654 break;
1658 case PCI_DEVICE_ID_INTEL_82875_HB: 1655 case PCI_DEVICE_ID_INTEL_82875_HB:
@@ -1660,35 +1657,31 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1660 name = "i875"; 1657 name = "i875";
1661 break; 1658 break;
1662 case PCI_DEVICE_ID_INTEL_82915G_HB: 1659 case PCI_DEVICE_ID_INTEL_82915G_HB:
1663 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG)) { 1660 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1664 bridge->driver = &intel_915_driver; 1661 bridge->driver = &intel_915_driver;
1665 } else { 1662 else
1666 bridge->driver = &intel_845_driver; 1663 bridge->driver = &intel_845_driver;
1667 }
1668 name = "915G"; 1664 name = "915G";
1669 break; 1665 break;
1670 case PCI_DEVICE_ID_INTEL_82915GM_HB: 1666 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1671 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG)) { 1667 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1672 bridge->driver = &intel_915_driver; 1668 bridge->driver = &intel_915_driver;
1673 } else { 1669 else
1674 bridge->driver = &intel_845_driver; 1670 bridge->driver = &intel_845_driver;
1675 }
1676 name = "915GM"; 1671 name = "915GM";
1677 break; 1672 break;
1678 case PCI_DEVICE_ID_INTEL_82945G_HB: 1673 case PCI_DEVICE_ID_INTEL_82945G_HB:
1679 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG)) { 1674 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1680 bridge->driver = &intel_915_driver; 1675 bridge->driver = &intel_915_driver;
1681 } else { 1676 else
1682 bridge->driver = &intel_845_driver; 1677 bridge->driver = &intel_845_driver;
1683 }
1684 name = "945G"; 1678 name = "945G";
1685 break; 1679 break;
1686 case PCI_DEVICE_ID_INTEL_82945GM_HB: 1680 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1687 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG)) { 1681 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1688 bridge->driver = &intel_915_driver; 1682 bridge->driver = &intel_915_driver;
1689 } else { 1683 else
1690 bridge->driver = &intel_845_driver; 1684 bridge->driver = &intel_845_driver;
1691 }
1692 name = "945GM"; 1685 name = "945GM";
1693 break; 1686 break;
1694 case PCI_DEVICE_ID_INTEL_7505_0: 1687 case PCI_DEVICE_ID_INTEL_7505_0:
@@ -1724,7 +1717,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1724 */ 1717 */
1725 r = &pdev->resource[0]; 1718 r = &pdev->resource[0];
1726 if (!r->start && r->end) { 1719 if (!r->start && r->end) {
1727 if(pci_assign_resource(pdev, 0)) { 1720 if (pci_assign_resource(pdev, 0)) {
1728 printk(KERN_ERR PFX "could not assign resource 0\n"); 1721 printk(KERN_ERR PFX "could not assign resource 0\n");
1729 agp_put_bridge(bridge); 1722 agp_put_bridge(bridge);
1730 return -ENODEV; 1723 return -ENODEV;
diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c
index 7c14a096b85e..3f9ccde62377 100644
--- a/drivers/char/agp/isoch.c
+++ b/drivers/char/agp/isoch.c
@@ -26,7 +26,7 @@ static void agp_3_5_dev_list_insert(struct list_head *head, struct list_head *ne
26 26
27 list_for_each(pos, head) { 27 list_for_each(pos, head) {
28 cur = list_entry(pos, struct agp_3_5_dev, list); 28 cur = list_entry(pos, struct agp_3_5_dev, list);
29 if(cur->maxbw > n->maxbw) 29 if (cur->maxbw > n->maxbw)
30 break; 30 break;
31 } 31 }
32 list_add_tail(new, pos); 32 list_add_tail(new, pos);
@@ -54,9 +54,9 @@ static void agp_3_5_dev_list_sort(struct agp_3_5_dev *list, unsigned int ndevs)
54 } 54 }
55} 55}
56 56
57/* 57/*
58 * Initialize all isochronous transfer parameters for an AGP 3.0 58 * Initialize all isochronous transfer parameters for an AGP 3.0
59 * node (i.e. a host bridge in combination with the adapters 59 * node (i.e. a host bridge in combination with the adapters
60 * lying behind it...) 60 * lying behind it...)
61 */ 61 */
62 62
@@ -200,7 +200,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
200 * this to the hungriest device (as per the spec) */ 200 * this to the hungriest device (as per the spec) */
201 rem = target.n - tot_n; 201 rem = target.n - tot_n;
202 202
203 /* 203 /*
204 * Calculate the minimum isochronous RQ depth needed by each master. 204 * Calculate the minimum isochronous RQ depth needed by each master.
205 * Along the way, distribute the extra ISOCH_N capability calculated 205 * Along the way, distribute the extra ISOCH_N capability calculated
206 * above. 206 * above.
@@ -214,7 +214,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
214 * many writes on the AGP bus). 214 * many writes on the AGP bus).
215 */ 215 */
216 master[cdev].rq = master[cdev].n; 216 master[cdev].rq = master[cdev].n;
217 if(master[cdev].y > 0x1) 217 if (master[cdev].y > 0x1)
218 master[cdev].rq *= (1 << (master[cdev].y - 1)); 218 master[cdev].rq *= (1 << (master[cdev].y - 1));
219 219
220 tot_rq += master[cdev].rq; 220 tot_rq += master[cdev].rq;
@@ -334,9 +334,9 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
334 334
335 arqsz = (tstatus >> 13) & 0x7; 335 arqsz = (tstatus >> 13) & 0x7;
336 336
337 /* 337 /*
338 * Allocate a head for our AGP 3.5 device list 338 * Allocate a head for our AGP 3.5 device list
339 * (multiple AGP v3 devices are allowed behind a single bridge). 339 * (multiple AGP v3 devices are allowed behind a single bridge).
340 */ 340 */
341 if ((dev_list = kmalloc(sizeof(*dev_list), GFP_KERNEL)) == NULL) { 341 if ((dev_list = kmalloc(sizeof(*dev_list), GFP_KERNEL)) == NULL) {
342 ret = -ENOMEM; 342 ret = -ENOMEM;
@@ -366,7 +366,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
366 366
367 case 0x0300: /* Display controller */ 367 case 0x0300: /* Display controller */
368 case 0x0400: /* Multimedia controller */ 368 case 0x0400: /* Multimedia controller */
369 if((cur = kmalloc(sizeof(*cur), GFP_KERNEL)) == NULL) { 369 if ((cur = kmalloc(sizeof(*cur), GFP_KERNEL)) == NULL) {
370 ret = -ENOMEM; 370 ret = -ENOMEM;
371 goto free_and_exit; 371 goto free_and_exit;
372 } 372 }
@@ -391,7 +391,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
391 list_for_each(pos, head) { 391 list_for_each(pos, head) {
392 cur = list_entry(pos, struct agp_3_5_dev, list); 392 cur = list_entry(pos, struct agp_3_5_dev, list);
393 dev = cur->dev; 393 dev = cur->dev;
394 394
395 pci_read_config_word(dev, PCI_STATUS, &mpstat); 395 pci_read_config_word(dev, PCI_STATUS, &mpstat);
396 if ((mpstat & PCI_STATUS_CAP_LIST) == 0) 396 if ((mpstat & PCI_STATUS_CAP_LIST) == 0)
397 continue; 397 continue;
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 80dafa3030bd..70b8ed9cd172 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -72,7 +72,7 @@ static int nvidia_init_iorr(u32 base, u32 size)
72 /* Find the iorr that is already used for the base */ 72 /* Find the iorr that is already used for the base */
73 /* If not found, determine the uppermost available iorr */ 73 /* If not found, determine the uppermost available iorr */
74 free_iorr_addr = AMD_K7_NUM_IORR; 74 free_iorr_addr = AMD_K7_NUM_IORR;
75 for(iorr_addr = 0; iorr_addr < AMD_K7_NUM_IORR; iorr_addr++) { 75 for (iorr_addr = 0; iorr_addr < AMD_K7_NUM_IORR; iorr_addr++) {
76 rdmsr(IORR_BASE0 + 2 * iorr_addr, base_lo, base_hi); 76 rdmsr(IORR_BASE0 + 2 * iorr_addr, base_lo, base_hi);
77 rdmsr(IORR_MASK0 + 2 * iorr_addr, mask_lo, mask_hi); 77 rdmsr(IORR_MASK0 + 2 * iorr_addr, mask_lo, mask_hi);
78 78
@@ -82,7 +82,7 @@ static int nvidia_init_iorr(u32 base, u32 size)
82 if ((mask_lo & 0x00000800) == 0) 82 if ((mask_lo & 0x00000800) == 0)
83 free_iorr_addr = iorr_addr; 83 free_iorr_addr = iorr_addr;
84 } 84 }
85 85
86 if (iorr_addr >= AMD_K7_NUM_IORR) { 86 if (iorr_addr >= AMD_K7_NUM_IORR) {
87 iorr_addr = free_iorr_addr; 87 iorr_addr = free_iorr_addr;
88 if (iorr_addr >= AMD_K7_NUM_IORR) 88 if (iorr_addr >= AMD_K7_NUM_IORR)
@@ -139,7 +139,7 @@ static int nvidia_configure(void)
139 } 139 }
140 140
141 /* attbase */ 141 /* attbase */
142 for(i = 0; i < 8; i++) { 142 for (i = 0; i < 8; i++) {
143 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_ATTBASE(i), 143 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_ATTBASE(i),
144 (agp_bridge->gatt_bus_addr + (i % num_dirs) * 64 * 1024) | 1); 144 (agp_bridge->gatt_bus_addr + (i % num_dirs) * 64 * 1024) | 1);
145 } 145 }
@@ -197,15 +197,15 @@ extern int agp_memory_reserved;
197static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 197static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
198{ 198{
199 int i, j; 199 int i, j;
200 200
201 if ((type != 0) || (mem->type != 0)) 201 if ((type != 0) || (mem->type != 0))
202 return -EINVAL; 202 return -EINVAL;
203 203
204 if ((pg_start + mem->page_count) > 204 if ((pg_start + mem->page_count) >
205 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE)) 205 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE))
206 return -EINVAL; 206 return -EINVAL;
207 207
208 for(j = pg_start; j < (pg_start + mem->page_count); j++) { 208 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
209 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j))) 209 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j)))
210 return -EBUSY; 210 return -EBUSY;
211 } 211 }
@@ -264,9 +264,9 @@ static void nvidia_tlbflush(struct agp_memory *mem)
264 } 264 }
265 265
266 /* flush TLB entries */ 266 /* flush TLB entries */
267 for(i = 0; i < 32 + 1; i++) 267 for (i = 0; i < 32 + 1; i++)
268 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32))); 268 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32)));
269 for(i = 0; i < 32 + 1; i++) 269 for (i = 0; i < 32 + 1; i++)
270 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32))); 270 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32)));
271} 271}
272 272
@@ -323,7 +323,7 @@ static int __devinit agp_nvidia_probe(struct pci_dev *pdev,
323 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2)); 323 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
324 nvidia_private.dev_3 = 324 nvidia_private.dev_3 =
325 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0)); 325 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
326 326
327 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) { 327 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
328 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 " 328 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
329 "chipset, but could not find the secondary devices.\n"); 329 "chipset, but could not find the secondary devices.\n");
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 4df7734b51c2..cfa7922cb431 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -329,7 +329,7 @@ static int __devinit agp_sgi_init(void)
329 329
330static void __devexit agp_sgi_cleanup(void) 330static void __devexit agp_sgi_cleanup(void)
331{ 331{
332 if(sgi_tioca_agp_bridges) 332 if (sgi_tioca_agp_bridges)
333 kfree(sgi_tioca_agp_bridges); 333 kfree(sgi_tioca_agp_bridges);
334 sgi_tioca_agp_bridges=NULL; 334 sgi_tioca_agp_bridges=NULL;
335} 335}
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index ebc05554045c..a00fd48a6f05 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -121,7 +121,7 @@ static struct aper_size_info_8 sis_generic_sizes[7] =
121 121
122static struct agp_bridge_driver sis_driver = { 122static struct agp_bridge_driver sis_driver = {
123 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
124 .aperture_sizes = sis_generic_sizes, 124 .aperture_sizes = sis_generic_sizes,
125 .size_type = U8_APER_SIZE, 125 .size_type = U8_APER_SIZE,
126 .num_aperture_sizes = 7, 126 .num_aperture_sizes = 7,
127 .configure = sis_configure, 127 .configure = sis_configure,
@@ -243,11 +243,11 @@ static void __devinit sis_get_driver(struct agp_bridge_data *bridge)
243{ 243{
244 int i; 244 int i;
245 245
246 for(i=0; sis_broken_chipsets[i]!=0; ++i) 246 for (i=0; sis_broken_chipsets[i]!=0; ++i)
247 if(bridge->dev->device==sis_broken_chipsets[i]) 247 if (bridge->dev->device==sis_broken_chipsets[i])
248 break; 248 break;
249 249
250 if(sis_broken_chipsets[i] || agp_sis_force_delay) 250 if (sis_broken_chipsets[i] || agp_sis_force_delay)
251 sis_driver.agp_enable=sis_delayed_enable; 251 sis_driver.agp_enable=sis_delayed_enable;
252 252
253 // sis chipsets that indicate less than agp3.5 253 // sis chipsets that indicate less than agp3.5
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index efef9999f1cf..4f2d7d99902f 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -64,7 +64,7 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map)
64 } 64 }
65 global_cache_flush(); 65 global_cache_flush();
66 66
67 for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) 67 for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++)
68 writel(agp_bridge->scratch_page, page_map->remapped+i); 68 writel(agp_bridge->scratch_page, page_map->remapped+i);
69 69
70 return 0; 70 return 0;
@@ -84,7 +84,7 @@ static void serverworks_free_gatt_pages(void)
84 struct serverworks_page_map *entry; 84 struct serverworks_page_map *entry;
85 85
86 tables = serverworks_private.gatt_pages; 86 tables = serverworks_private.gatt_pages;
87 for(i = 0; i < serverworks_private.num_tables; i++) { 87 for (i = 0; i < serverworks_private.num_tables; i++) {
88 entry = tables[i]; 88 entry = tables[i];
89 if (entry != NULL) { 89 if (entry != NULL) {
90 if (entry->real != NULL) { 90 if (entry->real != NULL) {
@@ -103,7 +103,7 @@ static int serverworks_create_gatt_pages(int nr_tables)
103 int retval = 0; 103 int retval = 0;
104 int i; 104 int i;
105 105
106 tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *), 106 tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
107 GFP_KERNEL); 107 GFP_KERNEL);
108 if (tables == NULL) 108 if (tables == NULL)
109 return -ENOMEM; 109 return -ENOMEM;
@@ -161,7 +161,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
161 return retval; 161 return retval;
162 } 162 }
163 /* Create a fake scratch directory */ 163 /* Create a fake scratch directory */
164 for(i = 0; i < 1024; i++) { 164 for (i = 0; i < 1024; i++) {
165 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i); 165 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i);
166 writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i); 166 writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
167 } 167 }
@@ -185,9 +185,8 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
185 pci_read_config_dword(agp_bridge->dev,serverworks_private.gart_addr_ofs,&temp); 185 pci_read_config_dword(agp_bridge->dev,serverworks_private.gart_addr_ofs,&temp);
186 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 186 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
187 187
188 /* Calculate the agp offset */ 188 /* Calculate the agp offset */
189 189 for (i = 0; i < value->num_entries / 1024; i++)
190 for(i = 0; i < value->num_entries / 1024; i++)
191 writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i); 190 writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
192 191
193 return 0; 192 return 0;
@@ -196,7 +195,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
196static int serverworks_free_gatt_table(struct agp_bridge_data *bridge) 195static int serverworks_free_gatt_table(struct agp_bridge_data *bridge)
197{ 196{
198 struct serverworks_page_map page_dir; 197 struct serverworks_page_map page_dir;
199 198
200 page_dir.real = (unsigned long *)agp_bridge->gatt_table_real; 199 page_dir.real = (unsigned long *)agp_bridge->gatt_table_real;
201 page_dir.remapped = (unsigned long __iomem *)agp_bridge->gatt_table; 200 page_dir.remapped = (unsigned long __iomem *)agp_bridge->gatt_table;
202 201
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 50947e38501a..9846defbddb4 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -95,12 +95,12 @@ static void uninorth_cleanup(void)
95static int uninorth_configure(void) 95static int uninorth_configure(void)
96{ 96{
97 struct aper_size_info_32 *current_size; 97 struct aper_size_info_32 *current_size;
98 98
99 current_size = A_SIZE_32(agp_bridge->current_size); 99 current_size = A_SIZE_32(agp_bridge->current_size);
100 100
101 printk(KERN_INFO PFX "configuring for size idx: %d\n", 101 printk(KERN_INFO PFX "configuring for size idx: %d\n",
102 current_size->size_value); 102 current_size->size_value);
103 103
104 /* aperture size and gatt addr */ 104 /* aperture size and gatt addr */
105 pci_write_config_dword(agp_bridge->dev, 105 pci_write_config_dword(agp_bridge->dev,
106 UNI_N_CFG_GART_BASE, 106 UNI_N_CFG_GART_BASE,
@@ -127,7 +127,7 @@ static int uninorth_configure(void)
127 UNI_N_CFG_GART_DUMMY_PAGE, 127 UNI_N_CFG_GART_DUMMY_PAGE,
128 agp_bridge->scratch_page_real >> 12); 128 agp_bridge->scratch_page_real >> 12);
129 } 129 }
130 130
131 return 0; 131 return 0;
132} 132}
133 133
@@ -162,7 +162,7 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start,
162 } 162 }
163 (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]); 163 (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]);
164 mb(); 164 mb();
165 flush_dcache_range((unsigned long)&agp_bridge->gatt_table[pg_start], 165 flush_dcache_range((unsigned long)&agp_bridge->gatt_table[pg_start],
166 (unsigned long)&agp_bridge->gatt_table[pg_start + mem->page_count]); 166 (unsigned long)&agp_bridge->gatt_table[pg_start + mem->page_count]);
167 167
168 uninorth_tlbflush(mem); 168 uninorth_tlbflush(mem);
@@ -235,7 +235,7 @@ static void uninorth_agp_enable(struct agp_bridge_data *bridge, u32 mode)
235 235
236 command = agp_collect_device_status(bridge, mode, status); 236 command = agp_collect_device_status(bridge, mode, status);
237 command |= PCI_AGP_COMMAND_AGP; 237 command |= PCI_AGP_COMMAND_AGP;
238 238
239 if (uninorth_rev == 0x21) { 239 if (uninorth_rev == 0x21) {
240 /* 240 /*
241 * Darwin disable AGP 4x on this revision, thus we 241 * Darwin disable AGP 4x on this revision, thus we
@@ -456,7 +456,7 @@ static struct aper_size_info_32 uninorth_sizes[7] =
456 {256, 65536, 6, 64}, 456 {256, 65536, 6, 64},
457 {128, 32768, 5, 32}, 457 {128, 32768, 5, 32},
458 {64, 16384, 4, 16}, 458 {64, 16384, 4, 16},
459#endif 459#endif
460 {32, 8192, 3, 8}, 460 {32, 8192, 3, 8},
461 {16, 4096, 2, 4}, 461 {16, 4096, 2, 4},
462 {8, 2048, 1, 2}, 462 {8, 2048, 1, 2},
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index d745004281d0..abd4c5118a1b 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,
736 intf = ipmi_interfaces[if_num]; 736 intf = ipmi_interfaces[if_num];
737 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) { 737 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
738 spin_unlock_irqrestore(&interfaces_lock, flags); 738 spin_unlock_irqrestore(&interfaces_lock, flags);
739 return -EINVAL; 739 rv = -EINVAL;
740 goto out_kfree;
740 } 741 }
741 742
742 /* Note that each existing user holds a refcount to the interface. */ 743 /* Note that each existing user holds a refcount to the interface. */
@@ -751,14 +752,14 @@ int ipmi_create_user(unsigned int if_num,
751 752
752 if (!try_module_get(intf->handlers->owner)) { 753 if (!try_module_get(intf->handlers->owner)) {
753 rv = -ENODEV; 754 rv = -ENODEV;
754 goto out_err; 755 goto out_kref;
755 } 756 }
756 757
757 if (intf->handlers->inc_usecount) { 758 if (intf->handlers->inc_usecount) {
758 rv = intf->handlers->inc_usecount(intf->send_info); 759 rv = intf->handlers->inc_usecount(intf->send_info);
759 if (rv) { 760 if (rv) {
760 module_put(intf->handlers->owner); 761 module_put(intf->handlers->owner);
761 goto out_err; 762 goto out_kref;
762 } 763 }
763 } 764 }
764 765
@@ -769,9 +770,10 @@ int ipmi_create_user(unsigned int if_num,
769 *user = new_user; 770 *user = new_user;
770 return 0; 771 return 0;
771 772
772 out_err: 773out_kref:
773 kfree(new_user);
774 kref_put(&intf->refcount, intf_free); 774 kref_put(&intf->refcount, intf_free);
775out_kfree:
776 kfree(new_user);
775 return rv; 777 return rv;
776} 778}
777 779
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 49c09ae004bf..e8ed26b77d4c 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -37,15 +37,13 @@
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/string.h> 38#include <linux/string.h>
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/pm.h>
40#include <linux/kdev_t.h> 41#include <linux/kdev_t.h>
41#include <linux/ipmi.h> 42#include <linux/ipmi.h>
42#include <linux/ipmi_smi.h> 43#include <linux/ipmi_smi.h>
43 44
44#define PFX "IPMI poweroff: " 45#define PFX "IPMI poweroff: "
45 46
46/* Where to we insert our poweroff function? */
47extern void (*pm_power_off)(void);
48
49/* Definitions for controlling power off (if the system supports it). It 47/* Definitions for controlling power off (if the system supports it). It
50 * conveniently matches the IPMI chassis control values. */ 48 * conveniently matches the IPMI chassis control values. */
51#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */ 49#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ede128356af2..e5247f85a446 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -378,13 +378,13 @@ MODULE_DESCRIPTION("Stallion Intelligent Multiport Serial Driver");
378MODULE_LICENSE("GPL"); 378MODULE_LICENSE("GPL");
379 379
380 380
381MODULE_PARM(board0, "1-3s"); 381module_param_array(board0, charp, NULL, 0);
382MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,memaddr]"); 382MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,memaddr]");
383MODULE_PARM(board1, "1-3s"); 383module_param_array(board1, charp, NULL, 0);
384MODULE_PARM_DESC(board1, "Board 1 config -> name[,ioaddr[,memaddr]"); 384MODULE_PARM_DESC(board1, "Board 1 config -> name[,ioaddr[,memaddr]");
385MODULE_PARM(board2, "1-3s"); 385module_param_array(board2, charp, NULL, 0);
386MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]"); 386MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]");
387MODULE_PARM(board3, "1-3s"); 387module_param_array(board3, charp, NULL, 0);
388MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]"); 388MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]");
389 389
390#endif 390#endif
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 29c41f4418c0..26d0116b48d4 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,
216 216
217 copied = copy_from_user(ptr, buf, sz); 217 copied = copy_from_user(ptr, buf, sz);
218 if (copied) { 218 if (copied) {
219 ssize_t ret; 219 written += sz - copied;
220 220 if (written)
221 ret = written + (sz - copied); 221 break;
222 if (ret)
223 return ret;
224 return -EFAULT; 222 return -EFAULT;
225 } 223 }
226 buf += sz; 224 buf += sz;
@@ -456,11 +454,9 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
456 454
457 copied = copy_from_user(ptr, buf, sz); 455 copied = copy_from_user(ptr, buf, sz);
458 if (copied) { 456 if (copied) {
459 ssize_t ret; 457 written += sz - copied;
460 458 if (written)
461 ret = written + (sz - copied); 459 break;
462 if (ret)
463 return ret;
464 return -EFAULT; 460 return -EFAULT;
465 } 461 }
466 buf += sz; 462 buf += sz;
@@ -514,11 +510,10 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
514 if (len) { 510 if (len) {
515 written = copy_from_user(kbuf, buf, len); 511 written = copy_from_user(kbuf, buf, len);
516 if (written) { 512 if (written) {
517 ssize_t ret; 513 if (wrote + virtr)
518 514 break;
519 free_page((unsigned long)kbuf); 515 free_page((unsigned long)kbuf);
520 ret = wrote + virtr + (len - written); 516 return -EFAULT;
521 return ret ? ret : -EFAULT;
522 } 517 }
523 } 518 }
524 len = vwrite(kbuf, (char *)p, len); 519 len = vwrite(kbuf, (char *)p, len);
@@ -563,8 +558,11 @@ static ssize_t write_port(struct file * file, const char __user * buf,
563 return -EFAULT; 558 return -EFAULT;
564 while (count-- > 0 && i < 65536) { 559 while (count-- > 0 && i < 65536) {
565 char c; 560 char c;
566 if (__get_user(c, tmp)) 561 if (__get_user(c, tmp)) {
562 if (tmp > buf)
563 break;
567 return -EFAULT; 564 return -EFAULT;
565 }
568 outb(c,i); 566 outb(c,i);
569 i++; 567 i++;
570 tmp++; 568 tmp++;
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index ea725a9964e2..0fb2fb9fb024 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -243,10 +243,10 @@ static int verbose = 0;
243 243
244MODULE_AUTHOR("Casper Yang"); 244MODULE_AUTHOR("Casper Yang");
245MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver"); 245MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver");
246MODULE_PARM(ioaddr, "1-4i"); 246module_param_array(ioaddr, int, NULL, 0);
247MODULE_PARM(ttymajor, "i"); 247module_param(ttymajor, int, 0);
248MODULE_PARM(calloutmajor, "i"); 248module_param(calloutmajor, int, 0);
249MODULE_PARM(verbose, "i"); 249module_param(verbose, bool, 0);
250MODULE_LICENSE("GPL"); 250MODULE_LICENSE("GPL");
251 251
252struct mxser_log { 252struct mxser_log {
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 8a8ca32822ba..e6b714b6390d 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,
4181 } 4181 }
4182 4182
4183 info->params.encoding = new_encoding; 4183 info->params.encoding = new_encoding;
4184 info->params.crc_type = new_crctype;; 4184 info->params.crc_type = new_crctype;
4185 4185
4186 /* if network interface up, reprogram hardware */ 4186 /* if network interface up, reprogram hardware */
4187 if (info->netcount) 4187 if (info->netcount)
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 306ee0f091a4..bee6c47b45bd 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -65,10 +65,11 @@
65#include <linux/parport.h> 65#include <linux/parport.h>
66#include <linux/ctype.h> 66#include <linux/ctype.h>
67#include <linux/poll.h> 67#include <linux/poll.h>
68#include <asm/uaccess.h> 68#include <linux/major.h>
69#include <linux/ppdev.h> 69#include <linux/ppdev.h>
70#include <linux/smp_lock.h> 70#include <linux/smp_lock.h>
71#include <linux/device.h> 71#include <linux/device.h>
72#include <asm/uaccess.h>
72 73
73#define PP_VERSION "ppdev: user-space parallel port driver" 74#define PP_VERSION "ppdev: user-space parallel port driver"
74#define CHRDEV "ppdev" 75#define CHRDEV "ppdev"
diff --git a/drivers/char/rio/Makefile b/drivers/char/rio/Makefile
index bce2bd1204ed..2d1c5a7cba7d 100644
--- a/drivers/char/rio/Makefile
+++ b/drivers/char/rio/Makefile
@@ -9,4 +9,4 @@
9obj-$(CONFIG_RIO) += rio.o 9obj-$(CONFIG_RIO) += rio.o
10 10
11rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \ 11rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \
12 rioparam.o riopcicopy.o rioroute.o riotable.o riotty.o 12 rioparam.o rioroute.o riotable.o riotty.o
diff --git a/drivers/char/rio/board.h b/drivers/char/rio/board.h
index 29c980204098..bdea633a9076 100644
--- a/drivers/char/rio/board.h
+++ b/drivers/char/rio/board.h
@@ -33,10 +33,6 @@
33#ifndef __rio_board_h__ 33#ifndef __rio_board_h__
34#define __rio_board_h__ 34#define __rio_board_h__
35 35
36#ifdef SCCS_LABELS
37static char *_board_h_sccs_ = "@(#)board.h 1.2";
38#endif
39
40/* 36/*
41** board.h contains the definitions for the *hardware* of the host cards. 37** board.h contains the definitions for the *hardware* of the host cards.
42** It describes the memory overlay for the dual port RAM area. 38** It describes the memory overlay for the dual port RAM area.
@@ -53,29 +49,29 @@ static char *_board_h_sccs_ = "@(#)board.h 1.2";
53** The shape of the Host Control area, at offset 0x7C00, Write Only 49** The shape of the Host Control area, at offset 0x7C00, Write Only
54*/ 50*/
55struct s_Ctrl { 51struct s_Ctrl {
56 BYTE DpCtl; /* 7C00 */ 52 u8 DpCtl; /* 7C00 */
57 BYTE Dp_Unused2_[127]; 53 u8 Dp_Unused2_[127];
58 BYTE DpIntSet; /* 7C80 */ 54 u8 DpIntSet; /* 7C80 */
59 BYTE Dp_Unused3_[127]; 55 u8 Dp_Unused3_[127];
60 BYTE DpTpuReset; /* 7D00 */ 56 u8 DpTpuReset; /* 7D00 */
61 BYTE Dp_Unused4_[127]; 57 u8 Dp_Unused4_[127];
62 BYTE DpIntReset; /* 7D80 */ 58 u8 DpIntReset; /* 7D80 */
63 BYTE Dp_Unused5_[127]; 59 u8 Dp_Unused5_[127];
64}; 60};
65 61
66/* 62/*
67** The PROM data area on the host (0x7C00), Read Only 63** The PROM data area on the host (0x7C00), Read Only
68*/ 64*/
69struct s_Prom { 65struct s_Prom {
70 WORD DpSlxCode[2]; 66 u16 DpSlxCode[2];
71 WORD DpRev; 67 u16 DpRev;
72 WORD Dp_Unused6_; 68 u16 Dp_Unused6_;
73 WORD DpUniq[4]; 69 u16 DpUniq[4];
74 WORD DpJahre; 70 u16 DpJahre;
75 WORD DpWoche; 71 u16 DpWoche;
76 WORD DpHwFeature[5]; 72 u16 DpHwFeature[5];
77 WORD DpOemId; 73 u16 DpOemId;
78 WORD DpSiggy[16]; 74 u16 DpSiggy[16];
79}; 75};
80 76
81/* 77/*
@@ -90,19 +86,19 @@ union u_CtrlProm { /* This is the control/PROM area (0x7C00) */
90** The top end of memory! 86** The top end of memory!
91*/ 87*/
92struct s_ParmMapS { /* Area containing Parm Map Pointer */ 88struct s_ParmMapS { /* Area containing Parm Map Pointer */
93 BYTE Dp_Unused8_[DP_PARMMAP_ADDR]; 89 u8 Dp_Unused8_[DP_PARMMAP_ADDR];
94 WORD DpParmMapAd; 90 u16 DpParmMapAd;
95}; 91};
96 92
97struct s_StartUpS { 93struct s_StartUpS {
98 BYTE Dp_Unused9_[DP_STARTUP_ADDR]; 94 u8 Dp_Unused9_[DP_STARTUP_ADDR];
99 BYTE Dp_LongJump[0x4]; 95 u8 Dp_LongJump[0x4];
100 BYTE Dp_Unused10_[2]; 96 u8 Dp_Unused10_[2];
101 BYTE Dp_ShortJump[0x2]; 97 u8 Dp_ShortJump[0x2];
102}; 98};
103 99
104union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */ 100union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
105 BYTE DpSramMem[DP_SRAM2_SIZE]; 101 u8 DpSramMem[DP_SRAM2_SIZE];
106 struct s_ParmMapS DpParmMapS; 102 struct s_ParmMapS DpParmMapS;
107 struct s_StartUpS DpStartUpS; 103 struct s_StartUpS DpStartUpS;
108}; 104};
@@ -111,11 +107,11 @@ union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
111** This is the DP RAM overlay. 107** This is the DP RAM overlay.
112*/ 108*/
113struct DpRam { 109struct DpRam {
114 BYTE DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */ 110 u8 DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */
115 union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */ 111 union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */
116 union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */ 112 union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */
117 BYTE DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */ 113 u8 DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */
118 BYTE DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */ 114 u8 DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */
119}; 115};
120 116
121#define DpControl DpCtrlProm.DpCtrl.DpCtl 117#define DpControl DpCtrlProm.DpCtrl.DpCtl
diff --git a/drivers/char/rio/bootpkt.h b/drivers/char/rio/bootpkt.h
deleted file mode 100644
index 602266e0c085..000000000000
--- a/drivers/char/rio/bootpkt.h
+++ /dev/null
@@ -1,61 +0,0 @@
1
2
3/****************************************************************************
4 ******* *******
5 ******* B O O T P A C K E T H E A D E R F I L E
6 ******* *******
7 ****************************************************************************
8
9 Author : Ian Nandhra
10 Date :
11
12 *
13 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 Version : 0.01
30
31
32 Mods
33 ----------------------------------------------------------------------------
34 Date By Description
35 ----------------------------------------------------------------------------
36
37 ***************************************************************************/
38
39#ifndef _pkt_h
40#define _pkt_h 1
41
42#ifndef lint
43#ifdef SCCS
44static char *_rio_bootpkt_h_sccs = "@(#)bootpkt.h 1.1";
45#endif
46#endif
47
48 /*************************************************
49 * Overlayed onto the Data fields of a regular
50 * Packet
51 ************************************************/
52typedef struct BOOT_PKT BOOT_PKT;
53struct BOOT_PKT {
54 short seq_num;
55 char data[10];
56};
57
58
59#endif
60
61/*********** end of file ***********/
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 89bd94eb45be..f4f837f86829 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,73 +40,7 @@
40#endif 40#endif
41#define _cirrus_h 1 41#define _cirrus_h 1
42 42
43 43/* Bit fields for particular registers shared with driver */
44
45/* Bit fields for particular registers */
46
47/* GCR */
48#define GCR_SERIAL 0x00 /* Configure as serial channel */
49#define GCR_PARALLEL 0x80 /* Configure as parallel channel */
50
51/* RDSR - when status read from FIFO */
52#define RDSR_BREAK 0x08 /* Break received */
53#define RDSR_TIMEOUT 0x80 /* No new data timeout */
54#define RDSR_SC1 0x10 /* Special char 1 (tx XON) matched */
55#define RDSR_SC2 0x20 /* Special char 2 (tx XOFF) matched */
56#define RDSR_SC12_MASK 0x30 /* Mask for special chars 1 and 2 */
57
58/* PPR */
59#define PPR_DEFAULT 0x31 /* Default value - for a 25Mhz clock gives
60 a timeout period of 1ms */
61
62/* LIVR */
63#define LIVR_EXCEPTION 0x07 /* Receive exception interrupt */
64
65/* CCR */
66#define CCR_RESET 0x80 /* Reset channel */
67#define CCR_CHANGE 0x4e /* COR's have changed - NB always change all
68 COR's */
69#define CCR_WFLUSH 0x82 /* Flush transmit FIFO and TSR / THR */
70
71#define CCR_SENDSC1 0x21 /* Send special character one */
72#define CCR_SENDSC2 0x22 /* Send special character two */
73#define CCR_SENDSC3 0x23 /* Send special character three */
74#define CCR_SENDSC4 0x24 /* Send special character four */
75
76#define CCR_TENABLE 0x18 /* Enable transmitter */
77#define CCR_TDISABLE 0x14 /* Disable transmitter */
78#define CCR_RENABLE 0x12 /* Enable receiver */
79#define CCR_RDISABLE 0x11 /* Disable receiver */
80
81#define CCR_READY 0x00 /* CCR is ready for another command */
82
83/* CCSR */
84#define CCSR_TXENABLE 0x08 /* Transmitter enable */
85#define CCSR_RXENABLE 0x80 /* Receiver enable */
86#define CCSR_TXFLOWOFF 0x04 /* Transmit flow off */
87#define CCSR_TXFLOWON 0x02 /* Transmit flow on */
88
89/* SVRR */
90#define SVRR_RECEIVE 0x01 /* Receive interrupt pending */
91#define SVRR_TRANSMIT 0x02 /* Transmit interrupt pending */
92#define SVRR_MODEM 0x04 /* Modem interrupt pending */
93
94/* CAR */
95#define CAR_PORTS 0x03 /* Bit fields for ports */
96
97/* IER */
98#define IER_MODEM 0x80 /* Change in modem status */
99#define IER_RECEIVE 0x10 /* Good data / data exception */
100#define IER_TRANSMITR 0x04 /* Transmit ready (FIFO empty) */
101#define IER_TRANSMITE 0x02 /* Transmit empty */
102#define IER_TIMEOUT 0x01 /* Timeout on no data */
103
104#define IER_DEFAULT 0x94 /* Default values */
105#define IER_PARALLEL 0x84 /* Default for Parallel */
106#define IER_EMPTY 0x92 /* Transmitter empty rather than ready */
107
108/* COR1 - Driver only */
109#define COR1_INPCK 0x10 /* Check parity of received characters */
110 44
111/* COR1 - driver and RTA */ 45/* COR1 - driver and RTA */
112#define COR1_ODD 0x80 /* Odd parity */ 46#define COR1_ODD 0x80 /* Odd parity */
@@ -222,35 +156,6 @@
222 156
223#define MSVR1_HOST 0xf3 /* The bits the host wants */ 157#define MSVR1_HOST 0xf3 /* The bits the host wants */
224 158
225/* MSVR2 */
226#define MSVR2_DSR 0x02 /* DSR output pin (DTR on Cirrus) */
227
228/* MCOR */
229#define MCOR_CD 0x80 /* CD (DSR on Cirrus) */
230#define MCOR_RTS 0x40 /* RTS (CTS on Cirrus) */
231#define MCOR_RI 0x20 /* RI */
232#define MCOR_DTR 0x10 /* DTR (CD on Cirrus) */
233
234#define MCOR_DEFAULT (MCOR_CD | MCOR_RTS | MCOR_RI | MCOR_DTR)
235#define MCOR_FULLMODEM MCOR_DEFAULT
236#define MCOR_RJ45 (MCOR_CD | MCOR_RTS | MCOR_DTR)
237#define MCOR_RESTRICTED (MCOR_CD | MCOR_RTS)
238
239/* More MCOR - H/W Handshake (flowcontrol) stuff */
240#define MCOR_THRESH8 0x08 /* eight characters then we stop */
241#define MCOR_THRESH9 0x09 /* nine characters then we stop */
242#define MCOR_THRESH10 0x0A /* ten characters then we stop */
243#define MCOR_THRESH11 0x0B /* eleven characters then we stop */
244
245#define MCOR_THRESHBITS 0x0F /* mask for ANDing out the above */
246
247#define MCOR_THRESHOLD MCOR_THRESH9 /* MUST BE GREATER THAN COR3_THRESHOLD */
248
249
250/* RTPR */
251#define RTPR_DEFAULT 0x02 /* Default */
252
253
254/* Defines for the subscripts of a CONFIG packet */ 159/* Defines for the subscripts of a CONFIG packet */
255#define CONFIG_COR1 1 /* Option register 1 */ 160#define CONFIG_COR1 1 /* Option register 1 */
256#define CONFIG_COR2 2 /* Option register 2 */ 161#define CONFIG_COR2 2 /* Option register 2 */
@@ -264,19 +169,6 @@
264#define CONFIG_TXBAUD 10 /* Tx baud rate */ 169#define CONFIG_TXBAUD 10 /* Tx baud rate */
265#define CONFIG_RXBAUD 11 /* Rx baud rate */ 170#define CONFIG_RXBAUD 11 /* Rx baud rate */
266 171
267/* Port status stuff */
268#define IDLE_CLOSED 0 /* Closed */
269#define IDLE_OPEN 1 /* Idle open */
270#define IDLE_BREAK 2 /* Idle on break */
271
272/* Subscript of MODEM STATUS packet */
273#define MODEM_VALUE 3 /* Current values of handshake pins */
274/* Subscript of SBREAK packet */
275#define BREAK_LENGTH 1 /* Length of a break in slices of 0.01 seconds
276 0 = stay on break until an EBREAK command
277 is sent */
278
279
280#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */ 172#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */
281 173
282/* Packet types going from Host to remote - with the exception of OPEN, MOPEN, 174/* 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 a9a8c45631d7..c46b2fdb6626 100644
--- a/drivers/char/rio/cmdblk.h
+++ b/drivers/char/rio/cmdblk.h
@@ -48,10 +48,10 @@ struct CmdBlk {
48 struct CmdBlk *NextP; /* Pointer to next command block */ 48 struct CmdBlk *NextP; /* Pointer to next command block */
49 struct PKT Packet; /* A packet, to copy to the rup */ 49 struct PKT Packet; /* A packet, to copy to the rup */
50 /* The func to call to check if OK */ 50 /* The func to call to check if OK */
51 int (*PreFuncP) (int, struct CmdBlk *); 51 int (*PreFuncP) (unsigned long, struct CmdBlk *);
52 int PreArg; /* The arg for the func */ 52 int PreArg; /* The arg for the func */
53 /* The func to call when completed */ 53 /* The func to call when completed */
54 int (*PostFuncP) (int, struct CmdBlk *); 54 int (*PostFuncP) (unsigned long, struct CmdBlk *);
55 int PostArg; /* The arg for the func */ 55 int PostArg; /* The arg for the func */
56}; 56};
57 57
diff --git a/drivers/char/rio/cmdpkt.h b/drivers/char/rio/cmdpkt.h
index 77cee8df68ef..357ae5722436 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";
55** at Data[2] in the actual pkt! 55** at Data[2] in the actual pkt!
56*/ 56*/
57struct BootSequence { 57struct BootSequence {
58 WORD NumPackets; 58 u16 NumPackets;
59 WORD LoadBase; 59 u16 LoadBase;
60 WORD CodeSize; 60 u16 CodeSize;
61}; 61};
62 62
63#define BOOT_SEQUENCE_LEN 8 63#define BOOT_SEQUENCE_LEN 8
64 64
65struct SamTop { 65struct SamTop {
66 BYTE Unit; 66 u8 Unit;
67 BYTE Link; 67 u8 Link;
68}; 68};
69 69
70struct CmdHdr { 70struct CmdHdr {
71 BYTE PcCommand; 71 u8 PcCommand;
72 union { 72 union {
73 BYTE PcPhbNum; 73 u8 PcPhbNum;
74 BYTE PcLinkNum; 74 u8 PcLinkNum;
75 BYTE PcIDNum; 75 u8 PcIDNum;
76 } U0; 76 } U0;
77}; 77};
78 78
@@ -84,28 +84,28 @@ struct PktCmd {
84 struct BootSequence PcBootSequence; 84 struct BootSequence PcBootSequence;
85 } S1; 85 } S1;
86 struct { 86 struct {
87 WORD PcSequence; 87 u16 PcSequence;
88 BYTE PcBootData[RTA_BOOT_DATA_SIZE]; 88 u8 PcBootData[RTA_BOOT_DATA_SIZE];
89 } S2; 89 } S2;
90 struct { 90 struct {
91 WORD __crud__; 91 u16 __crud__;
92 BYTE PcUniqNum[4]; /* this is really a uint. */ 92 u8 PcUniqNum[4]; /* this is really a uint. */
93 BYTE PcModuleTypes; /* what modules are fitted */ 93 u8 PcModuleTypes; /* what modules are fitted */
94 } S3; 94 } S3;
95 struct { 95 struct {
96 struct CmdHdr CmdHdr; 96 struct CmdHdr CmdHdr;
97 BYTE __undefined__; 97 u8 __undefined__;
98 BYTE PcModemStatus; 98 u8 PcModemStatus;
99 BYTE PcPortStatus; 99 u8 PcPortStatus;
100 BYTE PcSubCommand; /* commands like mem or register dump */ 100 u8 PcSubCommand; /* commands like mem or register dump */
101 WORD PcSubAddr; /* Address for command */ 101 u16 PcSubAddr; /* Address for command */
102 BYTE PcSubData[64]; /* Date area for command */ 102 u8 PcSubData[64]; /* Date area for command */
103 } S4; 103 } S4;
104 struct { 104 struct {
105 struct CmdHdr CmdHdr; 105 struct CmdHdr CmdHdr;
106 BYTE PcCommandText[1]; 106 u8 PcCommandText[1];
107 BYTE __crud__[20]; 107 u8 __crud__[20];
108 BYTE PcIDNum2; /* It had to go somewhere! */ 108 u8 PcIDNum2; /* It had to go somewhere! */
109 } S5; 109 } S5;
110 struct { 110 struct {
111 struct CmdHdr CmdHdr; 111 struct CmdHdr CmdHdr;
@@ -118,45 +118,45 @@ struct PktCmd_M {
118 union { 118 union {
119 struct { 119 struct {
120 struct { 120 struct {
121 uchar PcCommand; 121 u8 PcCommand;
122 union { 122 union {
123 uchar PcPhbNum; 123 u8 PcPhbNum;
124 uchar PcLinkNum; 124 u8 PcLinkNum;
125 uchar PcIDNum; 125 u8 PcIDNum;
126 } U0; 126 } U0;
127 } CmdHdr; 127 } CmdHdr;
128 struct { 128 struct {
129 ushort NumPackets; 129 u16 NumPackets;
130 ushort LoadBase; 130 u16 LoadBase;
131 ushort CodeSize; 131 u16 CodeSize;
132 } PcBootSequence; 132 } PcBootSequence;
133 } S1; 133 } S1;
134 struct { 134 struct {
135 ushort PcSequence; 135 u16 PcSequence;
136 uchar PcBootData[RTA_BOOT_DATA_SIZE]; 136 u8 PcBootData[RTA_BOOT_DATA_SIZE];
137 } S2; 137 } S2;
138 struct { 138 struct {
139 ushort __crud__; 139 u16 __crud__;
140 uchar PcUniqNum[4]; /* this is really a uint. */ 140 u8 PcUniqNum[4]; /* this is really a uint. */
141 uchar PcModuleTypes; /* what modules are fitted */ 141 u8 PcModuleTypes; /* what modules are fitted */
142 } S3; 142 } S3;
143 struct { 143 struct {
144 ushort __cmd_hdr__; 144 u16 __cmd_hdr__;
145 uchar __undefined__; 145 u8 __undefined__;
146 uchar PcModemStatus; 146 u8 PcModemStatus;
147 uchar PcPortStatus; 147 u8 PcPortStatus;
148 uchar PcSubCommand; 148 u8 PcSubCommand;
149 ushort PcSubAddr; 149 u16 PcSubAddr;
150 uchar PcSubData[64]; 150 u8 PcSubData[64];
151 } S4; 151 } S4;
152 struct { 152 struct {
153 ushort __cmd_hdr__; 153 u16 __cmd_hdr__;
154 uchar PcCommandText[1]; 154 u8 PcCommandText[1];
155 uchar __crud__[20]; 155 u8 __crud__[20];
156 uchar PcIDNum2; /* Tacked on end */ 156 u8 PcIDNum2; /* Tacked on end */
157 } S5; 157 } S5;
158 struct { 158 struct {
159 ushort __cmd_hdr__; 159 u16 __cmd_hdr__;
160 struct Top Topology[LINKS_PER_UNIT]; 160 struct Top Topology[LINKS_PER_UNIT];
161 } S6; 161 } S6;
162 } U1; 162 } U1;
diff --git a/drivers/char/rio/control.h b/drivers/char/rio/control.h
deleted file mode 100644
index 6853d03304a3..000000000000
--- a/drivers/char/rio/control.h
+++ /dev/null
@@ -1,61 +0,0 @@
1
2
3/****************************************************************************
4 ******* *******
5 ******* C O N T R O L P A C K E T H E A D E R S
6 ******* *******
7 ****************************************************************************
8
9 Author : Jon Brawn
10 Date :
11
12 *
13 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 Version : 0.01
30
31
32 Mods
33 ----------------------------------------------------------------------------
34 Date By Description
35 ----------------------------------------------------------------------------
36
37 ***************************************************************************/
38
39
40#ifndef _control_h
41#define _control_h
42
43#ifndef lint
44/* static char *_rio_control_h_sccs = "@(#)control.h 1.4"; */
45#endif
46
47#define CONTROL '^'
48#define IFOAD ( CONTROL + 1 )
49#define IDENTIFY ( CONTROL + 2 )
50#define ZOMBIE ( CONTROL + 3 )
51#define UFOAD ( CONTROL + 4 )
52#define IWAIT ( CONTROL + 5 )
53
54#define IFOAD_MAGIC 0xF0AD /* of course */
55#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
56#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
57#define IWAIT_MAGIC 0xB1DE /* Bide your time */
58
59#endif
60
61/*********** end of file ***********/
diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h
index 28a991bd4fe6..5818a8aa46e0 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";
45*/ 45*/
46 46
47struct Error { 47struct Error {
48 uint Error; 48 unsigned int Error;
49 uint Entry; 49 unsigned int Entry;
50 uint Other; 50 unsigned int Other;
51}; 51};
52 52
53struct DownLoad { 53struct DownLoad {
54 char *DataP; 54 char *DataP;
55 uint Count; 55 unsigned int Count;
56 uint ProductCode; 56 unsigned int ProductCode;
57}; 57};
58 58
59/* 59/*
@@ -68,69 +68,64 @@ struct DownLoad {
68#endif 68#endif
69 69
70struct PortSetup { 70struct PortSetup {
71 uint From; /* Set/Clear XP & IXANY Control from this port.... */ 71 unsigned int From; /* Set/Clear XP & IXANY Control from this port.... */
72 uint To; /* .... to this port */ 72 unsigned int To; /* .... to this port */
73 uint XpCps; /* at this speed */ 73 unsigned int XpCps; /* at this speed */
74 char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */ 74 char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */
75 char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */ 75 char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */
76 uchar IxAny; /* enable/disable IXANY */ 76 u8 IxAny; /* enable/disable IXANY */
77 uchar IxOn; /* enable/disable IXON */ 77 u8 IxOn; /* enable/disable IXON */
78 uchar Lock; /* lock port params */ 78 u8 Lock; /* lock port params */
79 uchar Store; /* store params across closes */ 79 u8 Store; /* store params across closes */
80 uchar Drain; /* close only when drained */ 80 u8 Drain; /* close only when drained */
81}; 81};
82 82
83struct LpbReq { 83struct LpbReq {
84 uint Host; 84 unsigned int Host;
85 uint Link; 85 unsigned int Link;
86 struct LPB *LpbP; 86 struct LPB *LpbP;
87}; 87};
88 88
89struct RupReq { 89struct RupReq {
90 uint HostNum; 90 unsigned int HostNum;
91 uint RupNum; 91 unsigned int RupNum;
92 struct RUP *RupP; 92 struct RUP *RupP;
93}; 93};
94 94
95struct PortReq { 95struct PortReq {
96 uint SysPort; 96 unsigned int SysPort;
97 struct Port *PortP; 97 struct Port *PortP;
98}; 98};
99 99
100struct StreamInfo { 100struct StreamInfo {
101 uint SysPort; 101 unsigned int SysPort;
102#if 0
103 queue_t RQueue;
104 queue_t WQueue;
105#else
106 int RQueue; 102 int RQueue;
107 int WQueue; 103 int WQueue;
108#endif
109}; 104};
110 105
111struct HostReq { 106struct HostReq {
112 uint HostNum; 107 unsigned int HostNum;
113 struct Host *HostP; 108 struct Host *HostP;
114}; 109};
115 110
116struct HostDpRam { 111struct HostDpRam {
117 uint HostNum; 112 unsigned int HostNum;
118 struct DpRam *DpRamP; 113 struct DpRam *DpRamP;
119}; 114};
120 115
121struct DebugCtrl { 116struct DebugCtrl {
122 uint SysPort; 117 unsigned int SysPort;
123 uint Debug; 118 unsigned int Debug;
124 uint Wait; 119 unsigned int Wait;
125}; 120};
126 121
127struct MapInfo { 122struct MapInfo {
128 uint FirstPort; /* 8 ports, starting from this (tty) number */ 123 unsigned int FirstPort; /* 8 ports, starting from this (tty) number */
129 uint RtaUnique; /* reside on this RTA (unique number) */ 124 unsigned int RtaUnique; /* reside on this RTA (unique number) */
130}; 125};
131 126
132struct MapIn { 127struct MapIn {
133 uint NumEntries; /* How many port sets are we mapping? */ 128 unsigned int NumEntries; /* How many port sets are we mapping? */
134 struct MapInfo *MapInfoP; /* Pointer to (user space) info */ 129 struct MapInfo *MapInfoP; /* Pointer to (user space) info */
135}; 130};
136 131
@@ -147,13 +142,13 @@ struct SpecialRupCmd {
147}; 142};
148 143
149struct IdentifyRta { 144struct IdentifyRta {
150 ulong RtaUnique; 145 unsigned long RtaUnique;
151 uchar ID; 146 u8 ID;
152}; 147};
153 148
154struct KillNeighbour { 149struct KillNeighbour {
155 ulong UniqueNum; 150 unsigned long UniqueNum;
156 uchar Link; 151 u8 Link;
157}; 152};
158 153
159struct rioVersion { 154struct rioVersion {
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
deleted file mode 100644
index d55c2f6a9877..000000000000
--- a/drivers/char/rio/defaults.h
+++ /dev/null
@@ -1,51 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* D E F A U L T S
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef lint
39#ifdef SCCS
40static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
41#endif
42#endif
43
44
45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
46#define SECOND (int) 15625 /* Low priority ticks */
47
48#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
49
50
51/*********** end of file ***********/
diff --git a/drivers/char/rio/error.h b/drivers/char/rio/error.h
deleted file mode 100644
index f20f0789db8f..000000000000
--- a/drivers/char/rio/error.h
+++ /dev/null
@@ -1,82 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* E R R O R H E A D E R F I L E
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef lint
39/* static char *_rio_error_h_sccs = "@(#)error.h 1.3"; */
40#endif
41
42#define E_NO_ERROR ((ushort) 0)
43#define E_PROCESS_NOT_INIT ((ushort) 1)
44#define E_LINK_TIMEOUT ((ushort) 2)
45#define E_NO_ROUTE ((ushort) 3)
46#define E_CONFUSED ((ushort) 4)
47#define E_HOME ((ushort) 5)
48#define E_CSUM_FAIL ((ushort) 6)
49#define E_DISCONNECTED ((ushort) 7)
50#define E_BAD_RUP ((ushort) 8)
51#define E_NO_VIRGIN ((ushort) 9)
52#define E_BOOT_RUP_BUSY ((ushort) 10)
53
54
55
56 /*************************************************
57 * Parsed to mem_halt()
58 ************************************************/
59#define E_CHANALLOC ((ushort) 0x80)
60#define E_POLL_ALLOC ((ushort) 0x81)
61#define E_LTTWAKE ((ushort) 0x82)
62#define E_LTT_ALLOC ((ushort) 0x83)
63#define E_LRT_ALLOC ((ushort) 0x84)
64#define E_CIRRUS ((ushort) 0x85)
65#define E_MONITOR ((ushort) 0x86)
66#define E_PHB_ALLOC ((ushort) 0x87)
67#define E_ARRAY_ALLOC ((ushort) 0x88)
68#define E_QBUF_ALLOC ((ushort) 0x89)
69#define E_PKT_ALLOC ((ushort) 0x8a)
70#define E_GET_TX_Q_BUF ((ushort) 0x8b)
71#define E_GET_RX_Q_BUF ((ushort) 0x8c)
72#define E_MEM_OUT ((ushort) 0x8d)
73#define E_MMU_INIT ((ushort) 0x8e)
74#define E_LTT_INIT ((ushort) 0x8f)
75#define E_LRT_INIT ((ushort) 0x90)
76#define E_LINK_RUN ((ushort) 0x91)
77#define E_MONITOR_ALLOC ((ushort) 0x92)
78#define E_MONITOR_INIT ((ushort) 0x93)
79#define E_POLL_INIT ((ushort) 0x94)
80
81
82/*********** end of file ***********/
diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h
index b4778410ec6e..e64fe9912394 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";
43 43
44/* rioboot.c */ 44/* rioboot.c */
45int RIOBootCodeRTA(struct rio_info *, struct DownLoad *); 45int RIOBootCodeRTA(struct rio_info *, struct DownLoad *);
46int RIOBootCodeHOST(struct rio_info *, register struct DownLoad *); 46int RIOBootCodeHOST(struct rio_info *, struct DownLoad *);
47int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *); 47int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *);
48void msec_timeout(struct Host *); 48void msec_timeout(struct Host *);
49int RIOBootRup(struct rio_info *, uint, struct Host *, struct PKT *); 49int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
50int RIOBootOk(struct rio_info *, struct Host *, ulong); 50int RIOBootOk(struct rio_info *, struct Host *, unsigned long);
51int RIORtaBound(struct rio_info *, uint); 51int RIORtaBound(struct rio_info *, unsigned int);
52void FillSlot(int, int, uint, struct Host *); 52void rio_fill_host_slot(int, int, unsigned int, struct Host *);
53 53
54/* riocmd.c */ 54/* riocmd.c */
55int RIOFoadRta(struct Host *, struct Map *); 55int RIOFoadRta(struct Host *, struct Map *);
56int RIOZombieRta(struct Host *, struct Map *); 56int RIOZombieRta(struct Host *, struct Map *);
57int RIOCommandRta(struct rio_info *, uint, int (*func) (struct Host *, struct Map *)); 57int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *));
58int RIOIdentifyRta(struct rio_info *, caddr_t); 58int RIOIdentifyRta(struct rio_info *, void *);
59int RIOKillNeighbour(struct rio_info *, caddr_t); 59int RIOKillNeighbour(struct rio_info *, void *);
60int RIOSuspendBootRta(struct Host *, int, int); 60int RIOSuspendBootRta(struct Host *, int, int);
61int RIOFoadWakeup(struct rio_info *); 61int RIOFoadWakeup(struct rio_info *);
62struct CmdBlk *RIOGetCmdBlk(void); 62struct CmdBlk *RIOGetCmdBlk(void);
63void RIOFreeCmdBlk(struct CmdBlk *); 63void RIOFreeCmdBlk(struct CmdBlk *);
64int RIOQueueCmdBlk(struct Host *, uint, struct CmdBlk *); 64int RIOQueueCmdBlk(struct Host *, unsigned int, struct CmdBlk *);
65void RIOPollHostCommands(struct rio_info *, struct Host *); 65void RIOPollHostCommands(struct rio_info *, struct Host *);
66int RIOWFlushMark(int, struct CmdBlk *); 66int RIOWFlushMark(unsigned long, struct CmdBlk *);
67int RIORFlushEnable(int, struct CmdBlk *); 67int RIORFlushEnable(unsigned long, struct CmdBlk *);
68int RIOUnUse(int, struct CmdBlk *); 68int RIOUnUse(unsigned long, struct CmdBlk *);
69void ShowPacket(uint, struct PKT *);
70 69
71/* rioctrl.c */ 70/* rioctrl.c */
72int copyin(int, caddr_t, int);
73int riocontrol(struct rio_info *, dev_t, int, caddr_t, int); 71int riocontrol(struct rio_info *, dev_t, int, caddr_t, int);
74int RIOPreemptiveCmd(struct rio_info *, struct Port *, uchar); 72int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char);
75 73
76/* rioinit.c */ 74/* rioinit.c */
77void rioinit(struct rio_info *, struct RioHostInfo *); 75void rioinit(struct rio_info *, struct RioHostInfo *);
@@ -80,19 +78,17 @@ void RIOISAinit(struct rio_info *, int);
80int RIODoAT(struct rio_info *, int, int); 78int RIODoAT(struct rio_info *, int, int);
81caddr_t RIOCheckForATCard(int); 79caddr_t RIOCheckForATCard(int);
82int RIOAssignAT(struct rio_info *, int, caddr_t, int); 80int RIOAssignAT(struct rio_info *, int, caddr_t, int);
83int RIOBoardTest(paddr_t, caddr_t, uchar, int); 81int RIOBoardTest(unsigned long, caddr_t, unsigned char, int);
84void RIOAllocDataStructs(struct rio_info *); 82void RIOAllocDataStructs(struct rio_info *);
85void RIOSetupDataStructs(struct rio_info *); 83void RIOSetupDataStructs(struct rio_info *);
86int RIODefaultName(struct rio_info *, struct Host *, uint); 84int RIODefaultName(struct rio_info *, struct Host *, unsigned int);
87struct rioVersion *RIOVersid(void); 85struct rioVersion *RIOVersid(void);
88int RIOMapin(paddr_t, int, caddr_t *); 86void RIOHostReset(unsigned int, struct DpRam *, unsigned int);
89void RIOMapout(paddr_t, long, caddr_t);
90void RIOHostReset(uint, volatile struct DpRam *, uint);
91 87
92/* riointr.c */ 88/* riointr.c */
93void RIOTxEnable(char *); 89void RIOTxEnable(char *);
94void RIOServiceHost(struct rio_info *, struct Host *, int); 90void RIOServiceHost(struct rio_info *, struct Host *, int);
95int riotproc(struct rio_info *, register struct ttystatics *, int, int); 91int riotproc(struct rio_info *, struct ttystatics *, int, int);
96 92
97/* rioparam.c */ 93/* rioparam.c */
98int RIOParam(struct Port *, int, int, int); 94int RIOParam(struct Port *, int, int, int);
@@ -106,18 +102,18 @@ int can_remove_receive(struct PKT **, struct Port *);
106void remove_receive(struct Port *); 102void remove_receive(struct Port *);
107 103
108/* rioroute.c */ 104/* rioroute.c */
109int RIORouteRup(struct rio_info *, uint, struct Host *, struct PKT *); 105int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
110void RIOFixPhbs(struct rio_info *, struct Host *, uint); 106void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int);
111uint GetUnitType(uint); 107unsigned int GetUnitType(unsigned int);
112int RIOSetChange(struct rio_info *); 108int RIOSetChange(struct rio_info *);
113int RIOFindFreeID(struct rio_info *, struct Host *, uint *, uint *); 109int RIOFindFreeID(struct rio_info *, struct Host *, unsigned int *, unsigned int *);
114 110
115 111
116/* riotty.c */ 112/* riotty.c */
117 113
118int riotopen(struct tty_struct *tty, struct file *filp); 114int riotopen(struct tty_struct *tty, struct file *filp);
119int riotclose(void *ptr); 115int riotclose(void *ptr);
120int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t); 116int riotioctl(struct rio_info *, struct tty_struct *, int, caddr_t);
121void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg); 117void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
122 118
123/* riotable.c */ 119/* riotable.c */
@@ -131,7 +127,7 @@ int RIOChangeName(struct rio_info *, struct Map *);
131#if 0 127#if 0
132/* riodrvr.c */ 128/* riodrvr.c */
133struct rio_info *rio_install(struct RioHostInfo *); 129struct rio_info *rio_install(struct RioHostInfo *);
134int rio_uninstall(register struct rio_info *); 130int rio_uninstall(struct rio_info *);
135int rio_open(struct rio_info *, int, struct file *); 131int rio_open(struct rio_info *, int, struct file *);
136int rio_close(struct rio_info *, struct file *); 132int rio_close(struct rio_info *, struct file *);
137int rio_read(struct rio_info *, struct file *, char *, int); 133int rio_read(struct rio_info *, struct file *, char *, int);
@@ -143,7 +139,7 @@ int rio_isr_thread(char *);
143struct rio_info *rio_info_store(int cmd, struct rio_info *p); 139struct rio_info *rio_info_store(int cmd, struct rio_info *p);
144#endif 140#endif
145 141
146extern int rio_pcicopy(char *src, char *dst, int n); 142extern void rio_copy_to_card(void *to, void *from, int len);
147extern int rio_minor(struct tty_struct *tty); 143extern int rio_minor(struct tty_struct *tty);
148extern int rio_ismodem(struct tty_struct *tty); 144extern int rio_ismodem(struct tty_struct *tty);
149 145
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index f7dfcedf7d45..3ec73d1a279a 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";
50** the host. 50** the host.
51*/ 51*/
52struct Host { 52struct Host {
53 uchar Type; /* RIO_EISA, RIO_MCA, ... */ 53 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */
54 uchar Ivec; /* POLLED or ivec number */ 54 unsigned char Ivec; /* POLLED or ivec number */
55 uchar Mode; /* Control stuff */ 55 unsigned char Mode; /* Control stuff */
56 uchar Slot; /* Slot */ 56 unsigned char Slot; /* Slot */
57 volatile caddr_t Caddr; /* KV address of DPRAM */ 57 caddr_t Caddr; /* KV address of DPRAM */
58 volatile struct DpRam *CardP; /* KV address of DPRAM, with overlay */ 58 struct DpRam *CardP; /* KV address of DPRAM, with overlay */
59 paddr_t PaddrP; /* Phys. address of DPRAM */ 59 unsigned long PaddrP; /* Phys. address of DPRAM */
60 char Name[MAX_NAME_LEN]; /* The name of the host */ 60 char Name[MAX_NAME_LEN]; /* The name of the host */
61 uint UniqueNum; /* host unique number */ 61 unsigned int UniqueNum; /* host unique number */
62 spinlock_t HostLock; /* Lock structure for MPX */ 62 spinlock_t HostLock; /* Lock structure for MPX */
63 /*struct pci_devinfo PciDevInfo; *//* PCI Bus/Device/Function stuff */ 63 unsigned int WorkToBeDone; /* set to true each interrupt */
64 /*struct lockb HostLock; *//* Lock structure for MPX */ 64 unsigned int InIntr; /* Being serviced? */
65 uint WorkToBeDone; /* set to true each interrupt */ 65 unsigned int IntSrvDone; /* host's interrupt has been serviced */
66 uint InIntr; /* Being serviced? */ 66 void (*Copy) (void *, void *, int); /* copy func */
67 uint IntSrvDone; /* host's interrupt has been serviced */
68 int (*Copy) (caddr_t, caddr_t, int); /* copy func */
69 struct timer_list timer; 67 struct timer_list timer;
70 /* 68 /*
71 ** I M P O R T A N T ! 69 ** I M P O R T A N T !
@@ -74,7 +72,7 @@ struct Host {
74 ** a RIO_HOST_FOAD command. 72 ** a RIO_HOST_FOAD command.
75 */ 73 */
76 74
77 ulong Flags; /* Whats going down */ 75 unsigned long Flags; /* Whats going down */
78#define RC_WAITING 0 76#define RC_WAITING 0
79#define RC_STARTUP 1 77#define RC_STARTUP 1
80#define RC_RUNNING 2 78#define RC_RUNNING 2
@@ -88,28 +86,28 @@ struct Host {
88** Boot mode applies to the way in which hosts in this system will 86** Boot mode applies to the way in which hosts in this system will
89** boot RTAs 87** boot RTAs
90*/ 88*/
91#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */ 89#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */
92#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */ 90#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */
93#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */ 91#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */
94 92
95 struct Top Topology[LINKS_PER_UNIT]; /* one per link */ 93 struct Top Topology[LINKS_PER_UNIT]; /* one per link */
96 struct Map Mapping[MAX_RUP]; /* Mappings for host */ 94 struct Map Mapping[MAX_RUP]; /* Mappings for host */
97 struct PHB *PhbP; /* Pointer to the PHB array */ 95 struct PHB *PhbP; /* Pointer to the PHB array */
98 ushort *PhbNumP; /* Ptr to Number of PHB's */ 96 unsigned short *PhbNumP; /* Ptr to Number of PHB's */
99 struct LPB *LinkStrP; /* Link Structure Array */ 97 struct LPB *LinkStrP; /* Link Structure Array */
100 struct RUP *RupP; /* Sixteen real rups here */ 98 struct RUP *RupP; /* Sixteen real rups here */
101 struct PARM_MAP *ParmMapP; /* points to the parmmap */ 99 struct PARM_MAP *ParmMapP; /* points to the parmmap */
102 uint ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */ 100 unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
103 uint NumExtraBooted; /* how many of the above */ 101 unsigned int NumExtraBooted; /* how many of the above */
104 /* 102 /*
105 ** Twenty logical rups. 103 ** Twenty logical rups.
106 ** The first sixteen are the real Rup entries (above), the last four 104 ** The first sixteen are the real Rup entries (above), the last four
107 ** are the link RUPs. 105 ** are the link RUPs.
108 */ 106 */
109 struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT]; 107 struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT];
110 int timeout_id; /* For calling 100 ms delays */ 108 int timeout_id; /* For calling 100 ms delays */
111 int timeout_sem; /* For calling 100 ms delays */ 109 int timeout_sem; /* For calling 100 ms delays */
112 long locks; /* long req'd for set_bit --RR */ 110 long locks; /* long req'd for set_bit --RR */
113 char ____end_marker____; 111 char ____end_marker____;
114}; 112};
115#define Control CardP->DpControl 113#define Control CardP->DpControl
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index 48d68ca7f825..f3bf11a04d41 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -37,38 +37,9 @@
37#ifndef _link_h 37#ifndef _link_h
38#define _link_h 1 38#define _link_h 1
39 39
40#ifndef lint
41#ifdef SCCS_LABELS
42/* static char *_rio_link_h_sccs = "@(#)link.h 1.15"; */
43#endif
44#endif
45
46
47
48/************************************************* 40/*************************************************
49 * Define the Link Status stuff 41 * Define the Link Status stuff
50 ************************************************/ 42 ************************************************/
51#define LRT_ACTIVE ((ushort) 0x01)
52#define LRT_SPARE1 ((ushort) 0x02)
53#define INTRO_RCVD ((ushort) 0x04)
54#define FORCED_DISCONNECT ((ushort) 0x08)
55#define LRT_SPARE2 ((ushort) 0x80)
56
57#define TOP_OF_RTA_RAM ((ushort) 0x7000)
58#define HOST_SERIAL_POINTER (unsigned char **) (TOP_OF_RTA_RAM - 2 * sizeof (ushort))
59
60/* Flags for ltt_status */
61#define WAITING_ACK (ushort) 0x0001
62#define DATA_SENT (ushort) 0x0002
63#define WAITING_RUP (ushort) 0x0004
64#define WAITING_RETRY (ushort) 0x0008
65#define WAITING_TOPOLOGY (ushort) 0x0010
66#define SEND_SYNC (ushort) 0x0020
67#define FOAD_THIS_LINK (ushort) 0x0040
68#define REQUEST_SYNC (ushort) 0x0080
69#define REMOTE_DYING (ushort) 0x0100
70#define DIE_NOW (ushort) 0x0200
71
72/* Boot request stuff */ 43/* Boot request stuff */
73#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */ 44#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */
74#define BOOT_ABORT ((ushort) 1) /* Abort a boot */ 45#define BOOT_ABORT ((ushort) 1) /* Abort a boot */
@@ -76,77 +47,48 @@
76 and load address */ 47 and load address */
77#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */ 48#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */
78 49
79/* States that a link can be in */
80#define LINK_DISCONNECTED ((ushort) 0) /* Disconnected */
81#define LINK_BOOT1 ((ushort) 1) /* Trying to send 1st stage boot */
82#define LINK_BOOT2 ((ushort) 2) /* Trying to send 2nd stage boot */
83#define LINK_BOOT2WAIT ((ushort) 3) /* Waiting for selftest results */
84#define LINK_BOOT3 ((ushort) 4) /* Trying to send 3rd stage boots */
85#define LINK_SYNC ((ushort) 5) /* Syncing */
86
87#define LINK_INTRO ((ushort) 10) /* Introductory packet */
88#define LINK_SUPPLYID ((ushort) 11) /* Trying to supply an ID */
89#define LINK_TOPOLOGY ((ushort) 12) /* Send a topology update */
90#define LINK_REQUESTID ((ushort) 13) /* Waiting for an ID */
91#define LINK_CONNECTED ((ushort) 14) /* Connected */
92
93#define LINK_INTERCONNECT ((ushort) 20) /* Subnets interconnected */
94
95#define LINK_SPARE ((ushort) 40)
96
97/*
98** Set the default timeout for link communications.
99*/
100#define LINKTIMEOUT (400 * MILLISECOND)
101
102/*
103** LED stuff
104*/
105#define LED_SET_COLOUR(colour)
106#define LED_OR_COLOUR(colour)
107#define LED_TIMEOUT(time)
108 50
109struct LPB { 51struct LPB {
110 WORD link_number; /* Link Number */ 52 u16 link_number; /* Link Number */
111 Channel_ptr in_ch; /* Link In Channel */ 53 u16 in_ch; /* Link In Channel */
112 Channel_ptr out_ch; /* Link Out Channel */ 54 u16 out_ch; /* Link Out Channel */
113 BYTE attached_serial[4]; /* Attached serial number */ 55 u8 attached_serial[4]; /* Attached serial number */
114 BYTE attached_host_serial[4]; 56 u8 attached_host_serial[4];
115 /* Serial number of Host who 57 /* Serial number of Host who
116 booted the other end */ 58 booted the other end */
117 WORD descheduled; /* Currently Descheduled */ 59 u16 descheduled; /* Currently Descheduled */
118 WORD state; /* Current state */ 60 u16 state; /* Current state */
119 WORD send_poll; /* Send a Poll Packet */ 61 u16 send_poll; /* Send a Poll Packet */
120 Process_ptr ltt_p; /* Process Descriptor */ 62 u16 ltt_p; /* Process Descriptor */
121 Process_ptr lrt_p; /* Process Descriptor */ 63 u16 lrt_p; /* Process Descriptor */
122 WORD lrt_status; /* Current lrt status */ 64 u16 lrt_status; /* Current lrt status */
123 WORD ltt_status; /* Current ltt status */ 65 u16 ltt_status; /* Current ltt status */
124 WORD timeout; /* Timeout value */ 66 u16 timeout; /* Timeout value */
125 WORD topology; /* Topology bits */ 67 u16 topology; /* Topology bits */
126 WORD mon_ltt; 68 u16 mon_ltt;
127 WORD mon_lrt; 69 u16 mon_lrt;
128 WORD WaitNoBoot; /* Secs to hold off booting */ 70 u16 WaitNoBoot; /* Secs to hold off booting */
129 PKT_ptr add_packet_list; /* Add packets to here */ 71 u16 add_packet_list; /* Add packets to here */
130 PKT_ptr remove_packet_list; /* Send packets from here */ 72 u16 remove_packet_list; /* Send packets from here */
131 73
132 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */ 74 u16 lrt_fail_chan; /* Lrt's failure channel */
133 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */ 75 u16 ltt_fail_chan; /* Ltt's failure channel */
134 76
135 /* RUP structure for HOST to driver communications */ 77 /* RUP structure for HOST to driver communications */
136 struct RUP rup; 78 struct RUP rup;
137 struct RUP link_rup; /* RUP for the link (POLL, 79 struct RUP link_rup; /* RUP for the link (POLL,
138 topology etc.) */ 80 topology etc.) */
139 WORD attached_link; /* Number of attached link */ 81 u16 attached_link; /* Number of attached link */
140 WORD csum_errors; /* csum errors */ 82 u16 csum_errors; /* csum errors */
141 WORD num_disconnects; /* number of disconnects */ 83 u16 num_disconnects; /* number of disconnects */
142 WORD num_sync_rcvd; /* # sync's received */ 84 u16 num_sync_rcvd; /* # sync's received */
143 WORD num_sync_rqst; /* # sync requests */ 85 u16 num_sync_rqst; /* # sync requests */
144 WORD num_tx; /* Num pkts sent */ 86 u16 num_tx; /* Num pkts sent */
145 WORD num_rx; /* Num pkts received */ 87 u16 num_rx; /* Num pkts received */
146 WORD module_attached; /* Module tpyes of attached */ 88 u16 module_attached; /* Module tpyes of attached */
147 WORD led_timeout; /* LED timeout */ 89 u16 led_timeout; /* LED timeout */
148 WORD first_port; /* First port to service */ 90 u16 first_port; /* First port to service */
149 WORD last_port; /* Last port to service */ 91 u16 last_port; /* Last port to service */
150}; 92};
151 93
152#endif 94#endif
diff --git a/drivers/char/rio/linux_compat.h b/drivers/char/rio/linux_compat.h
index 17a14c4a3420..34c0d2899ef1 100644
--- a/drivers/char/rio/linux_compat.h
+++ b/drivers/char/rio/linux_compat.h
@@ -19,56 +19,12 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20 20
21 21
22#define disable(oldspl) save_flags (oldspl)
23#define restore(oldspl) restore_flags (oldspl)
24
25#define sysbrk(x) kmalloc ((x),in_interrupt()? GFP_ATOMIC : GFP_KERNEL)
26#define sysfree(p,size) kfree ((p))
27
28#define WBYTE(p,v) writeb(v, &p)
29#define RBYTE(p) readb (&p)
30#define WWORD(p,v) writew(v, &p)
31#define RWORD(p) readw(&p)
32#define WINDW(p,v) writew(v, p)
33#define RINDW(p) readw(p)
34
35#define DEBUG_ALL 22#define DEBUG_ALL
36 23
37#define cprintf printk
38
39#ifdef __KERNEL__
40#define INKERNEL
41#endif
42
43struct ttystatics { 24struct ttystatics {
44 struct termios tm; 25 struct termios tm;
45}; 26};
46 27
47#define bzero(d, n) memset((d), 0, (n))
48#define bcopy(src, dest, n) memcpy ((dest), (src), (n))
49
50#define SEM_SIGIGNORE 0x1234
51
52#ifdef DEBUG_SEM
53#define swait(a,b) printk ("waiting: " __FILE__ " line %d\n", __LINE__)
54#define ssignal(sem) printk ("signalling: " __FILE__ " line %d\n", __LINE__)
55
56#define sreset(sem) printk ("sreset: " __FILE__ "\n")
57#define sem_init(sem,v) printk ("sreset: " __FILE__ "\n")
58#endif
59
60
61#define getpid() (current->pid)
62
63#define QSIZE SERIAL_XMIT_SIZE
64
65#define pseterr(errno) return (- errno)
66
67#define V_CBAUD CBAUD
68
69/* For one reason or another rioboot.c uses delay instead of RIODelay. */
70#define delay(x,y) RIODelay(NULL, y)
71
72extern int rio_debug; 28extern int rio_debug;
73 29
74#define RIO_DEBUG_INIT 0x000001 30#define RIO_DEBUG_INIT 0x000001
@@ -91,6 +47,7 @@ extern int rio_debug;
91#define RIO_DEBUG_DELAY 0x020000 47#define RIO_DEBUG_DELAY 0x020000
92#define RIO_DEBUG_MOD_COUNT 0x040000 48#define RIO_DEBUG_MOD_COUNT 0x040000
93 49
50
94/* Copied over from riowinif.h . This is ugly. The winif file declares 51/* Copied over from riowinif.h . This is ugly. The winif file declares
95also much other stuff which is incompatible with the headers from 52also much other stuff which is incompatible with the headers from
96the older driver. The older driver includes "brates.h" which shadows 53the 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 79b853140ae5..000000000000
--- a/drivers/char/rio/list.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* L I S T *******
4 ******* *******
5 ****************************************************************************
6
7 Author : Jeremy Rolls.
8 Date : 04-Nov-1990
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34 ***************************************************************************/
35
36#ifndef _list_h
37#define _list_h 1
38
39#ifdef SCCS_LABELS
40#ifndef lint
41static char *_rio_list_h_sccs = "@(#)list.h 1.9";
42#endif
43#endif
44
45#define PKT_IN_USE 0x1
46
47#define ZERO_PTR (ushort) 0x8000
48#define CaD PortP->Caddr
49
50/*
51** We can add another packet to a transmit queue if the packet pointer pointed
52** to by the TxAdd pointer has PKT_IN_USE clear in its address.
53*/
54
55#endif /* ifndef _list.h */
56/*********** end of file ***********/
diff --git a/drivers/char/rio/map.h b/drivers/char/rio/map.h
index 97fe287aab2a..bdbcd09c8b81 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";
47#define MAX_NAME_LEN 32 47#define MAX_NAME_LEN 32
48 48
49struct Map { 49struct Map {
50 uint HostUniqueNum; /* Supporting hosts unique number */ 50 unsigned int HostUniqueNum; /* Supporting hosts unique number */
51 uint RtaUniqueNum; /* Unique number */ 51 unsigned int RtaUniqueNum; /* Unique number */
52 /* 52 /*
53 ** The next two IDs must be swapped on big-endian architectures 53 ** The next two IDs must be swapped on big-endian architectures
54 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when 54 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when
55 ** upgrading for example). 55 ** upgrading for example).
56 */ 56 */
57 ushort ID; /* ID used in the subnet */ 57 unsigned short ID; /* ID used in the subnet */
58 ushort ID2; /* ID of 2nd block of 8 for 16 port */ 58 unsigned short ID2; /* ID of 2nd block of 8 for 16 port */
59 ulong Flags; /* Booted, ID Given, Disconnected */ 59 unsigned long Flags; /* Booted, ID Given, Disconnected */
60 ulong SysPort; /* First tty mapped to this port */ 60 unsigned long SysPort; /* First tty mapped to this port */
61 struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */ 61 struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */
62 char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */ 62 char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */
63}; 63};
diff --git a/drivers/char/rio/param.h b/drivers/char/rio/param.h
index de7e57180c91..675c200b2459 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";
43*/ 43*/
44 44
45struct phb_param { 45struct phb_param {
46 BYTE Cmd; /* It is very important that these line up */ 46 u8 Cmd; /* It is very important that these line up */
47 BYTE Cor1; /* with what is expected at the other end. */ 47 u8 Cor1; /* with what is expected at the other end. */
48 BYTE Cor2; /* to confirm that you've got it right, */ 48 u8 Cor2; /* to confirm that you've got it right, */
49 BYTE Cor4; /* check with cirrus/cirrus.h */ 49 u8 Cor4; /* check with cirrus/cirrus.h */
50 BYTE Cor5; 50 u8 Cor5;
51 BYTE TxXon; /* Transmit X-On character */ 51 u8 TxXon; /* Transmit X-On character */
52 BYTE TxXoff; /* Transmit X-Off character */ 52 u8 TxXoff; /* Transmit X-Off character */
53 BYTE RxXon; /* Receive X-On character */ 53 u8 RxXon; /* Receive X-On character */
54 BYTE RxXoff; /* Receive X-Off character */ 54 u8 RxXoff; /* Receive X-Off character */
55 BYTE LNext; /* Literal-next character */ 55 u8 LNext; /* Literal-next character */
56 BYTE TxBaud; /* Transmit baudrate */ 56 u8 TxBaud; /* Transmit baudrate */
57 BYTE RxBaud; /* Receive baudrate */ 57 u8 RxBaud; /* Receive baudrate */
58}; 58};
59 59
60#endif 60#endif
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index e24acc1d1844..9764ef85c5a6 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -47,40 +47,40 @@
47typedef struct PARM_MAP PARM_MAP; 47typedef struct PARM_MAP PARM_MAP;
48 48
49struct PARM_MAP { 49struct PARM_MAP {
50 PHB_ptr phb_ptr; /* Pointer to the PHB array */ 50 u16 phb_ptr; /* Pointer to the PHB array */
51 WORD_ptr phb_num_ptr; /* Ptr to Number of PHB's */ 51 u16 phb_num_ptr; /* Ptr to Number of PHB's */
52 FREE_LIST_ptr free_list; /* Free List pointer */ 52 u16 free_list; /* Free List pointer */
53 FREE_LIST_ptr free_list_end; /* Free List End pointer */ 53 u16 free_list_end; /* Free List End pointer */
54 Q_BUF_ptr_ptr q_free_list_ptr; /* Ptr to Q_BUF variable */ 54 u16 q_free_list_ptr; /* Ptr to Q_BUF variable */
55 BYTE_ptr unit_id_ptr; /* Unit Id */ 55 u16 unit_id_ptr; /* Unit Id */
56 LPB_ptr link_str_ptr; /* Link Structure Array */ 56 u16 link_str_ptr; /* Link Structure Array */
57 BYTE_ptr bootloader_1; /* 1st Stage Boot Loader */ 57 u16 bootloader_1; /* 1st Stage Boot Loader */
58 BYTE_ptr bootloader_2; /* 2nd Stage Boot Loader */ 58 u16 bootloader_2; /* 2nd Stage Boot Loader */
59 WORD_ptr port_route_map_ptr; /* Port Route Map */ 59 u16 port_route_map_ptr; /* Port Route Map */
60 ROUTE_STR_ptr route_ptr; /* Unit Route Map */ 60 u16 route_ptr; /* Unit Route Map */
61 NUMBER_ptr map_present; /* Route Map present */ 61 u16 map_present; /* Route Map present */
62 NUMBER pkt_num; /* Total number of packets */ 62 s16 pkt_num; /* Total number of packets */
63 NUMBER q_num; /* Total number of Q packets */ 63 s16 q_num; /* Total number of Q packets */
64 WORD buffers_per_port; /* Number of buffers per port */ 64 u16 buffers_per_port; /* Number of buffers per port */
65 WORD heap_size; /* Initial size of heap */ 65 u16 heap_size; /* Initial size of heap */
66 WORD heap_left; /* Current Heap left */ 66 u16 heap_left; /* Current Heap left */
67 WORD error; /* Error code */ 67 u16 error; /* Error code */
68 WORD tx_max; /* Max number of tx pkts per phb */ 68 u16 tx_max; /* Max number of tx pkts per phb */
69 WORD rx_max; /* Max number of rx pkts per phb */ 69 u16 rx_max; /* Max number of rx pkts per phb */
70 WORD rx_limit; /* For high / low watermarks */ 70 u16 rx_limit; /* For high / low watermarks */
71 NUMBER links; /* Links to use */ 71 s16 links; /* Links to use */
72 NUMBER timer; /* Interrupts per second */ 72 s16 timer; /* Interrupts per second */
73 RUP_ptr rups; /* Pointer to the RUPs */ 73 u16 rups; /* Pointer to the RUPs */
74 WORD max_phb; /* Mostly for debugging */ 74 u16 max_phb; /* Mostly for debugging */
75 WORD living; /* Just increments!! */ 75 u16 living; /* Just increments!! */
76 WORD init_done; /* Initialisation over */ 76 u16 init_done; /* Initialisation over */
77 WORD booting_link; 77 u16 booting_link;
78 WORD idle_count; /* Idle time counter */ 78 u16 idle_count; /* Idle time counter */
79 WORD busy_count; /* Busy counter */ 79 u16 busy_count; /* Busy counter */
80 WORD idle_control; /* Control Idle Process */ 80 u16 idle_control; /* Control Idle Process */
81 WORD tx_intr; /* TX interrupt pending */ 81 u16 tx_intr; /* TX interrupt pending */
82 WORD rx_intr; /* RX interrupt pending */ 82 u16 rx_intr; /* RX interrupt pending */
83 WORD rup_intr; /* RUP interrupt pending */ 83 u16 rup_intr; /* RUP interrupt pending */
84}; 84};
85 85
86#endif 86#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 2663ca0306e2..a4c48ae4e365 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -37,13 +37,6 @@
37#ifndef _phb_h 37#ifndef _phb_h
38#define _phb_h 1 38#define _phb_h 1
39 39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_phb_h_sccs = "@(#)phb.h 1.12"; */
43#endif
44#endif
45
46
47/************************************************* 40/*************************************************
48 * Handshake asserted. Deasserted by the LTT(s) 41 * Handshake asserted. Deasserted by the LTT(s)
49 ************************************************/ 42 ************************************************/
@@ -124,23 +117,23 @@
124 * the start. The pointer tx_add points to a SPACE to put a Packet. 117 * the start. The pointer tx_add points to a SPACE to put a Packet.
125 * The pointer tx_remove points to the next Packet to remove 118 * The pointer tx_remove points to the next Packet to remove
126 *************************************************************************/ 119 *************************************************************************/
127typedef struct PHB PHB; 120
128struct PHB { 121struct PHB {
129 WORD source; 122 u8 source;
130 WORD handshake; 123 u8 handshake;
131 WORD status; 124 u8 status;
132 NUMBER timeout; /* Maximum of 1.9 seconds */ 125 u16 timeout; /* Maximum of 1.9 seconds */
133 WORD link; /* Send down this link */ 126 u8 link; /* Send down this link */
134 WORD destination; 127 u8 destination;
135 PKT_ptr_ptr tx_start; 128 u16 tx_start;
136 PKT_ptr_ptr tx_end; 129 u16 tx_end;
137 PKT_ptr_ptr tx_add; 130 u16 tx_add;
138 PKT_ptr_ptr tx_remove; 131 u16 tx_remove;
139 132
140 PKT_ptr_ptr rx_start; 133 u16 rx_start;
141 PKT_ptr_ptr rx_end; 134 u16 rx_end;
142 PKT_ptr_ptr rx_add; 135 u16 rx_add;
143 PKT_ptr_ptr rx_remove; 136 u16 rx_remove;
144 137
145}; 138};
146 139
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 7011e52e82db..a9458164f02f 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -37,14 +37,6 @@
37#ifndef _pkt_h 37#ifndef _pkt_h
38#define _pkt_h 1 38#define _pkt_h 1
39 39
40
41#ifdef SCCS_LABELS
42#ifndef lint
43/* static char *_rio_pkt_h_sccs = "@(#)pkt.h 1.8"; */
44#endif
45#endif
46
47#define MAX_TTL 0xf
48#define PKT_CMD_BIT ((ushort) 0x080) 40#define PKT_CMD_BIT ((ushort) 0x080)
49#define PKT_CMD_DATA ((ushort) 0x080) 41#define PKT_CMD_DATA ((ushort) 0x080)
50 42
@@ -70,15 +62,15 @@
70#define CONTROL_DATA_WNDW (DATA_WNDW << 8) 62#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
71 63
72struct PKT { 64struct PKT {
73 BYTE dest_unit; /* Destination Unit Id */ 65 u8 dest_unit; /* Destination Unit Id */
74 BYTE dest_port; /* Destination POrt */ 66 u8 dest_port; /* Destination POrt */
75 BYTE src_unit; /* Source Unit Id */ 67 u8 src_unit; /* Source Unit Id */
76 BYTE src_port; /* Source POrt */ 68 u8 src_port; /* Source POrt */
77 BYTE len; 69 u8 len;
78 BYTE control; 70 u8 control;
79 BYTE data[PKT_MAX_DATA_LEN]; 71 u8 data[PKT_MAX_DATA_LEN];
80 /* Actual data :-) */ 72 /* Actual data :-) */
81 WORD csum; /* C-SUM */ 73 u16 csum; /* C-SUM */
82}; 74};
83#endif 75#endif
84 76
diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h
index c99b1e70fdc8..9b5fa3eb0402 100644
--- a/drivers/char/rio/port.h
+++ b/drivers/char/rio/port.h
@@ -33,91 +33,37 @@
33#ifndef __rio_port_h__ 33#ifndef __rio_port_h__
34#define __rio_port_h__ 34#define __rio_port_h__
35 35
36#ifdef SCCS_LABELS
37static char *_port_h_sccs_ = "@(#)port.h 1.3";
38#endif
39
40
41#undef VPIX
42
43
44/*
45** the port data structure - one per port in the system
46*/
47
48#ifdef STATS
49struct RIOStats {
50 /*
51 ** interrupt statistics
52 */
53 uint BreakIntCnt;
54 uint ModemOffCnt;
55 uint ModemOnCnt;
56 uint RxIntCnt;
57 uint TxIntCnt;
58 /*
59 ** throughput statistics
60 */
61 uint RxCharCnt;
62 uint RxPktCnt;
63 uint RxSaveCnt;
64 uint TxCharCnt;
65 uint TxPktCnt;
66 /*
67 ** driver entry statistics
68 */
69 uint CloseCnt;
70 uint IoctlCnt;
71 uint OpenCnt;
72 uint ReadCnt;
73 uint WriteCnt;
74 /*
75 ** proc statistics
76 */
77 uint BlockCnt;
78 uint OutputCnt;
79 uint ResumeCnt;
80 uint RflushCnt;
81 uint SuspendCnt;
82 uint TbreakCnt;
83 uint TimeoutCnt;
84 uint UnblockCnt;
85 uint WflushCnt;
86 uint WFBodgeCnt;
87};
88#endif
89
90/* 36/*
91** Port data structure 37** Port data structure
92*/ 38*/
93struct Port { 39struct Port {
94 struct gs_port gs; 40 struct gs_port gs;
95 int PortNum; /* RIO port no., 0-511 */ 41 int PortNum; /* RIO port no., 0-511 */
96 struct Host *HostP; 42 struct Host *HostP;
97 volatile caddr_t Caddr; 43 caddr_t Caddr;
98 ushort HostPort; /* Port number on host card */ 44 unsigned short HostPort; /* Port number on host card */
99 uchar RupNum; /* Number of RUP for port */ 45 unsigned char RupNum; /* Number of RUP for port */
100 uchar ID2; /* Second ID of RTA for port */ 46 unsigned char ID2; /* Second ID of RTA for port */
101 ulong State; /* FLAGS for open & xopen */ 47 unsigned long State; /* FLAGS for open & xopen */
102#define RIO_LOPEN 0x00001 /* Local open */ 48#define RIO_LOPEN 0x00001 /* Local open */
103#define RIO_MOPEN 0x00002 /* Modem open */ 49#define RIO_MOPEN 0x00002 /* Modem open */
104#define RIO_WOPEN 0x00004 /* Waiting for open */ 50#define RIO_WOPEN 0x00004 /* Waiting for open */
105#define RIO_CLOSING 0x00008 /* The port is being close */ 51#define RIO_CLOSING 0x00008 /* The port is being close */
106#define RIO_XPBUSY 0x00010 /* Transparent printer busy */ 52#define RIO_XPBUSY 0x00010 /* Transparent printer busy */
107#define RIO_BREAKING 0x00020 /* Break in progress */ 53#define RIO_BREAKING 0x00020 /* Break in progress */
108#define RIO_DIRECT 0x00040 /* Doing Direct output */ 54#define RIO_DIRECT 0x00040 /* Doing Direct output */
109#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */ 55#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */
110#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */ 56#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */
111#define RIO_CARR_ON 0x00200 /* Stream has carrier present */ 57#define RIO_CARR_ON 0x00200 /* Stream has carrier present */
112#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */ 58#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */
113#define RIO_RBLK 0x00800 /* Stream is read-blocked */ 59#define RIO_RBLK 0x00800 /* Stream is read-blocked */
114#define RIO_BUSY 0x01000 /* Stream is BUSY for write */ 60#define RIO_BUSY 0x01000 /* Stream is BUSY for write */
115#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */ 61#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */
116#define RIO_TXSTOP 0x04000 /* Stream output is stopped */ 62#define RIO_TXSTOP 0x04000 /* Stream output is stopped */
117#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */ 63#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */
118#define RIO_DYNOROD 0x10000 /* Drain failed */ 64#define RIO_DYNOROD 0x10000 /* Drain failed */
119#define RIO_DELETED 0x20000 /* RTA has been deleted */ 65#define RIO_DELETED 0x20000 /* RTA has been deleted */
120#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */ 66#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */
121#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */ 67#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */
122#define RIO_CAN_COOK 0x200000 /* This line can do cooking */ 68#define RIO_CAN_COOK 0x200000 /* This line can do cooking */
123#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */ 69#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */
@@ -125,15 +71,15 @@ struct Port {
125#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */ 71#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */
126#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */ 72#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */
127 73
128 ulong Config; /* FLAGS for NOREAD.... */ 74 unsigned long Config; /* FLAGS for NOREAD.... */
129#define RIO_NOREAD 0x0001 /* Are not allowed to read port */ 75#define RIO_NOREAD 0x0001 /* Are not allowed to read port */
130#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */ 76#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */
131#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */ 77#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */
132#define RIO_NOMASK 0x0007 /* All not allowed things */ 78#define RIO_NOMASK 0x0007 /* All not allowed things */
133#define RIO_IXANY 0x0008 /* Port is allowed ixany */ 79#define RIO_IXANY 0x0008 /* Port is allowed ixany */
134#define RIO_MODEM 0x0010 /* Stream is a modem device */ 80#define RIO_MODEM 0x0010 /* Stream is a modem device */
135#define RIO_IXON 0x0020 /* Port is allowed ixon */ 81#define RIO_IXON 0x0020 /* Port is allowed ixon */
136#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */ 82#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */
137#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */ 83#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */
138#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */ 84#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */
139 85
@@ -142,36 +88,36 @@ struct Port {
142** As LynxOS does not appear to support Hardware Flow Control ..... 88** As LynxOS does not appear to support Hardware Flow Control .....
143** Define our own flow control flags in 'Config'. 89** Define our own flow control flags in 'Config'.
144*/ 90*/
145#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */ 91#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */
146#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */ 92#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
147 93
148 94
149 struct PHB *PhbP; /* pointer to PHB for port */ 95 struct PHB *PhbP; /* pointer to PHB for port */
150 WORD *TxAdd; /* Add packets here */ 96 u16 *TxAdd; /* Add packets here */
151 WORD *TxStart; /* Start of add array */ 97 u16 *TxStart; /* Start of add array */
152 WORD *TxEnd; /* End of add array */ 98 u16 *TxEnd; /* End of add array */
153 WORD *RxRemove; /* Remove packets here */ 99 u16 *RxRemove; /* Remove packets here */
154 WORD *RxStart; /* Start of remove array */ 100 u16 *RxStart; /* Start of remove array */
155 WORD *RxEnd; /* End of remove array */ 101 u16 *RxEnd; /* End of remove array */
156 uint RtaUniqueNum; /* Unique number of RTA */ 102 unsigned int RtaUniqueNum; /* Unique number of RTA */
157 ushort PortState; /* status of port */ 103 unsigned short PortState; /* status of port */
158 ushort ModemState; /* status of modem lines */ 104 unsigned short ModemState; /* status of modem lines */
159 ulong ModemLines; /* Modem bits sent to RTA */ 105 unsigned long ModemLines; /* Modem bits sent to RTA */
160 uchar CookMode; /* who expands CR/LF? */ 106 unsigned char CookMode; /* who expands CR/LF? */
161 uchar ParamSem; /* Prevent write during param */ 107 unsigned char ParamSem; /* Prevent write during param */
162 uchar Mapped; /* if port mapped onto host */ 108 unsigned char Mapped; /* if port mapped onto host */
163 uchar SecondBlock; /* if port belongs to 2nd block 109 unsigned char SecondBlock; /* if port belongs to 2nd block
164 of 16 port RTA */ 110 of 16 port RTA */
165 uchar InUse; /* how many pre-emptive cmds */ 111 unsigned char InUse; /* how many pre-emptive cmds */
166 uchar Lock; /* if params locked */ 112 unsigned char Lock; /* if params locked */
167 uchar Store; /* if params stored across closes */ 113 unsigned char Store; /* if params stored across closes */
168 uchar FirstOpen; /* TRUE if first time port opened */ 114 unsigned char FirstOpen; /* TRUE if first time port opened */
169 uchar FlushCmdBodge; /* if doing a (non)flush */ 115 unsigned char FlushCmdBodge; /* if doing a (non)flush */
170 uchar MagicFlags; /* require intr processing */ 116 unsigned char MagicFlags; /* require intr processing */
171#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */ 117#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */
172#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */ 118#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */
173#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */ 119#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */
174 uchar WflushFlag; /* 1 How many WFLUSHs active */ 120 unsigned char WflushFlag; /* 1 How many WFLUSHs active */
175/* 121/*
176** Transparent print stuff 122** Transparent print stuff
177*/ 123*/
@@ -179,63 +125,55 @@ struct Port {
179#ifndef MAX_XP_CTRL_LEN 125#ifndef MAX_XP_CTRL_LEN
180#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */ 126#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */
181#endif 127#endif
182 uint XpCps; 128 unsigned int XpCps;
183 char XpOn[MAX_XP_CTRL_LEN]; 129 char XpOn[MAX_XP_CTRL_LEN];
184 char XpOff[MAX_XP_CTRL_LEN]; 130 char XpOff[MAX_XP_CTRL_LEN];
185 ushort XpLen; /* strlen(XpOn)+strlen(XpOff) */ 131 unsigned short XpLen; /* strlen(XpOn)+strlen(XpOff) */
186 uchar XpActive; 132 unsigned char XpActive;
187 uchar XpLastTickOk; /* TRUE if we can process */ 133 unsigned char XpLastTickOk; /* TRUE if we can process */
188#define XP_OPEN 00001 134#define XP_OPEN 00001
189#define XP_RUNABLE 00002 135#define XP_RUNABLE 00002
190 struct ttystatics *XttyP; 136 struct ttystatics *XttyP;
191 } Xprint; 137 } Xprint;
192#ifdef VPIX 138 unsigned char RxDataStart;
193 v86_t *StashP; 139 unsigned char Cor2Copy; /* copy of COR2 */
194 uint IntMask; 140 char *Name; /* points to the Rta's name */
195 struct termss VpixSs;
196 uchar ModemStatusReg; /* Modem status register */
197#endif
198 uchar RxDataStart;
199 uchar Cor2Copy; /* copy of COR2 */
200 char *Name; /* points to the Rta's name */
201#ifdef STATS
202 struct RIOStats Stat; /* ports statistics */
203#endif
204 char *TxRingBuffer; 141 char *TxRingBuffer;
205 ushort TxBufferIn; /* New data arrives here */ 142 unsigned short TxBufferIn; /* New data arrives here */
206 ushort TxBufferOut; /* Intr removes data here */ 143 unsigned short TxBufferOut; /* Intr removes data here */
207 ushort OldTxBufferOut; /* Indicates if draining */ 144 unsigned short OldTxBufferOut; /* Indicates if draining */
208 int TimeoutId; /* Timeout ID */ 145 int TimeoutId; /* Timeout ID */
209 uint Debug; 146 unsigned int Debug;
210 uchar WaitUntilBooted; /* True if open should block */ 147 unsigned char WaitUntilBooted; /* True if open should block */
211 uint statsGather; /* True if gathering stats */ 148 unsigned int statsGather; /* True if gathering stats */
212 ulong txchars; /* Chars transmitted */ 149 unsigned long txchars; /* Chars transmitted */
213 ulong rxchars; /* Chars received */ 150 unsigned long rxchars; /* Chars received */
214 ulong opens; /* port open count */ 151 unsigned long opens; /* port open count */
215 ulong closes; /* port close count */ 152 unsigned long closes; /* port close count */
216 ulong ioctls; /* ioctl count */ 153 unsigned long ioctls; /* ioctl count */
217 uchar LastRxTgl; /* Last state of rx toggle bit */ 154 unsigned char LastRxTgl; /* Last state of rx toggle bit */
218 spinlock_t portSem; /* Lock using this sem */ 155 spinlock_t portSem; /* Lock using this sem */
219 int MonitorTstate; /* Monitoring ? */ 156 int MonitorTstate; /* Monitoring ? */
220 int timeout_id; /* For calling 100 ms delays */ 157 int timeout_id; /* For calling 100 ms delays */
221 int timeout_sem; /* For calling 100 ms delays */ 158 int timeout_sem; /* For calling 100 ms delays */
222 int firstOpen; /* First time open ? */ 159 int firstOpen; /* First time open ? */
223 char *p; /* save the global struc here .. */ 160 char *p; /* save the global struc here .. */
224}; 161};
225 162
226struct ModuleInfo { 163struct ModuleInfo {
227 char *Name; 164 char *Name;
228 uint Flags[4]; /* one per port on a module */ 165 unsigned int Flags[4]; /* one per port on a module */
229}; 166};
230#endif
231 167
232/* 168/*
233** This struct is required because trying to grab an entire Port structure 169** This struct is required because trying to grab an entire Port structure
234** runs into problems with differing struct sizes between driver and config. 170** runs into problems with differing struct sizes between driver and config.
235*/ 171*/
236struct PortParams { 172struct PortParams {
237 uint Port; 173 unsigned int Port;
238 ulong Config; 174 unsigned long Config;
239 ulong State; 175 unsigned long State;
240 struct ttystatics *TtyP; 176 struct ttystatics *TtyP;
241}; 177};
178
179#endif
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
deleted file mode 100644
index 391ffc335535..000000000000
--- a/drivers/char/rio/qbuf.h
+++ /dev/null
@@ -1,62 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* Q U E U E B U F F E R S T R U C T U R E S
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra / Jeremy Rolls
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef _qbuf_h
39#define _qbuf_h 1
40
41#ifndef lint
42#ifdef SCCS_LABELS
43static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
44#endif
45#endif
46
47
48
49#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
50
51typedef struct Q_BUF Q_BUF;
52struct Q_BUF {
53 Q_BUF_ptr next;
54 Q_BUF_ptr prev;
55 PKT_ptr buf[PKTS_PER_BUFFER];
56};
57
58
59#endif
60
61
62/*********** end of file ***********/
diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h
index 7f45e1ab5332..b4c91871ba28 100644
--- a/drivers/char/rio/rio.h
+++ b/drivers/char/rio/rio.h
@@ -33,38 +33,6 @@
33#ifndef __rio_rio_h__ 33#ifndef __rio_rio_h__
34#define __rio_rio_h__ 34#define __rio_rio_h__
35 35
36#ifdef SCCS_LABELS
37static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
38#endif
39
40/*
41** 30.09.1998 ARG -
42** Introduced driver version and host card type strings
43*/
44#define RIO_DRV_STR "Specialix RIO Driver"
45#define RIO_AT_HOST_STR "ISA"
46#define RIO_PCI_HOST_STR "PCI"
47
48
49/*
50** rio_info_store() commands (arbitary values) :
51*/
52#define RIO_INFO_PUT 0xA4B3C2D1
53#define RIO_INFO_GET 0xF1E2D3C4
54
55
56/*
57** anything that I couldn't cram in somewhere else
58*/
59/*
60#ifndef RIODEBUG
61#define debug
62#else
63#define debug rioprint
64#endif
65*/
66
67
68/* 36/*
69** Maximum numbers of things 37** Maximum numbers of things
70*/ 38*/
@@ -101,9 +69,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
101/* 69/*
102** Flag values returned by functions 70** Flag values returned by functions
103*/ 71*/
72
104#define RIO_FAIL -1 73#define RIO_FAIL -1
105#define RIO_SUCCESS 0
106#define COPYFAIL -1 /* copy[in|out] failed */
107 74
108/* 75/*
109** SysPort value for something that hasn't any ports 76** SysPort value for something that hasn't any ports
@@ -142,30 +109,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
142/* 109/*
143** Generally useful constants 110** Generally useful constants
144*/ 111*/
145#define HALF_A_SECOND ((HZ)>>1) 112
146#define A_SECOND (HZ) 113#define HUNDRED_MS ((HZ/10)?(HZ/10):1)
147#define HUNDRED_HZ ((HZ/100)?(HZ/100):1)
148#define FIFTY_HZ ((HZ/50)?(HZ/50):1)
149#define TWENTY_HZ ((HZ/20)?(HZ/20):1)
150#define TEN_HZ ((HZ/10)?(HZ/10):1)
151#define FIVE_HZ ((HZ/5)?(HZ/5):1)
152#define HUNDRED_MS TEN_HZ
153#define FIFTY_MS TWENTY_HZ
154#define TWENTY_MS FIFTY_HZ
155#define TEN_MS HUNDRED_HZ
156#define TWO_SECONDS ((A_SECOND)*2)
157#define FIVE_SECONDS ((A_SECOND)*5)
158#define TEN_SECONDS ((A_SECOND)*10)
159#define FIFTEEN_SECONDS ((A_SECOND)*15)
160#define TWENTY_SECONDS ((A_SECOND)*20)
161#define HALF_A_MINUTE (A_MINUTE>>1)
162#define A_MINUTE (A_SECOND*60)
163#define FIVE_MINUTES (A_MINUTE*5)
164#define QUARTER_HOUR (A_MINUTE*15)
165#define HALF_HOUR (A_MINUTE*30)
166#define HOUR (A_MINUTE*60)
167
168#define SIXTEEN_MEG 0x1000000
169#define ONE_MEG 0x100000 114#define ONE_MEG 0x100000
170#define SIXTY_FOUR_K 0x10000 115#define SIXTY_FOUR_K 0x10000
171 116
@@ -173,8 +118,6 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
173#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K 118#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K
174#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K 119#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K
175 120
176#define POLL_VECTOR 0x100
177
178#define COOK_WELL 0 121#define COOK_WELL 0
179#define COOK_MEDIUM 1 122#define COOK_MEDIUM 1
180#define COOK_RAW 2 123#define COOK_RAW 2
@@ -186,69 +129,26 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
186** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and 129** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
187** returns the offset into the DP RAM area. 130** returns the offset into the DP RAM area.
188*/ 131*/
189#define RIO_PTR(C,O) (((caddr_t)(C))+(0xFFFF&(O))) 132#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O)))
190#define RIO_OFF(C,O) ((int)(O)-(int)(C)) 133#define RIO_OFF(C,O) ((long)(O)-(long)(C))
191 134
192/* 135/*
193** How to convert from various different device number formats: 136** How to convert from various different device number formats:
194** DEV is a dev number, as passed to open, close etc - NOT a minor 137** DEV is a dev number, as passed to open, close etc - NOT a minor
195** number! 138** number!
196** 139**/
197** Note: LynxOS only gives us 8 bits for the device minor number, 140
198** so all this crap here to deal with 'modem' bits etc. is
199** just a load of irrelevant old bunkum!
200** This however does not stop us needing to define a value
201** for RIO_MODEMOFFSET which is required by the 'riomkdev'
202** utility in the New Config Utilities suite.
203*/
204/* 0-511: direct 512-1023: modem */
205#define RIO_MODEMOFFSET 0x200 /* doesn't mean anything */
206#define RIO_MODEM_MASK 0x1FF 141#define RIO_MODEM_MASK 0x1FF
207#define RIO_MODEM_BIT 0x200 142#define RIO_MODEM_BIT 0x200
208#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK) 143#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK)
209#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT) 144#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT)
210#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \ 145#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
211 + MINOR(DEV) 146 + MINOR(DEV)
212 147#define CSUM(pkt_ptr) (((u16 *)(pkt_ptr))[0] + ((u16 *)(pkt_ptr))[1] + \
213#define splrio spltty 148 ((u16 *)(pkt_ptr))[2] + ((u16 *)(pkt_ptr))[3] + \
214 149 ((u16 *)(pkt_ptr))[4] + ((u16 *)(pkt_ptr))[5] + \
215#define RIO_IPL 5 150 ((u16 *)(pkt_ptr))[6] + ((u16 *)(pkt_ptr))[7] + \
216#define RIO_PRI (PZERO+10) 151 ((u16 *)(pkt_ptr))[8] + ((u16 *)(pkt_ptr))[9] )
217#define RIO_CLOSE_PRI PZERO-1 /* uninterruptible sleeps for close */
218
219typedef struct DbInf {
220 uint Flag;
221 char Name[8];
222} DbInf;
223
224#ifndef TRUE
225#define TRUE (1==1)
226#endif
227#ifndef FALSE
228#define FALSE (!TRUE)
229#endif
230
231#define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \
232 ((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \
233 ((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \
234 ((ushort *)(pkt_ptr))[6] + ((ushort *)(pkt_ptr))[7] + \
235 ((ushort *)(pkt_ptr))[8] + ((ushort *)(pkt_ptr))[9] )
236
237/*
238** This happy little macro copies SIZE bytes of data from FROM to TO
239** quite well. SIZE must be a constant.
240*/
241#define CCOPY( FROM, TO, SIZE ) { *(struct s { char data[SIZE]; } *)(TO) = *(struct s *)(FROM); }
242
243/*
244** increment a buffer pointer modulo the size of the buffer...
245*/
246#define BUMP( P, I ) ((P) = (((P)+(I)) & RIOBufferMask))
247
248#define INIT_PACKET( PK, PP ) \
249{ \
250 *((uint *)PK) = PP->PacketInfo; \
251}
252 152
253#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */ 153#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */
254 /* prevent a really stupid race condition. */ 154 /* prevent a really stupid race condition. */
@@ -267,27 +167,42 @@ typedef struct DbInf {
267#define DISCONNECT 0 167#define DISCONNECT 0
268#define CONNECT 1 168#define CONNECT 1
269 169
170/* ------ Control Codes ------ */
270 171
271/* 172#define CONTROL '^'
272** Machine types - these must NOT overlap with product codes 0-15 173#define IFOAD ( CONTROL + 1 )
273*/ 174#define IDENTIFY ( CONTROL + 2 )
274#define RIO_MIPS_R3230 31 175#define ZOMBIE ( CONTROL + 3 )
275#define RIO_MIPS_R4030 32 176#define UFOAD ( CONTROL + 4 )
177#define IWAIT ( CONTROL + 5 )
178
179#define IFOAD_MAGIC 0xF0AD /* of course */
180#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
181#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
182#define IWAIT_MAGIC 0xB1DE /* Bide your time */
183
184/* ------ Error Codes ------ */
185
186#define E_NO_ERROR ((ushort) 0)
187
188/* ------ Free Lists ------ */
276 189
277#define RIO_IO_UNKNOWN -2 190struct rio_free_list {
191 u16 next;
192 u16 prev;
193};
278 194
279#undef MODERN 195/* NULL for card side linked lists */
280#define ERROR( E ) do { u.u_error = E; return OPENFAIL } while ( 0 ) 196#define TPNULL ((ushort)(0x8000))
197/* We can add another packet to a transmit queue if the packet pointer pointed
198 * to by the TxAdd pointer has PKT_IN_USE clear in its address. */
199#define PKT_IN_USE 0x1
281 200
282/* Defines for MPX line discipline routines */ 201/* ------ Topology ------ */
283 202
284#define DIST_LINESW_OPEN 0x01 203struct Top {
285#define DIST_LINESW_CLOSE 0x02 204 u8 Unit;
286#define DIST_LINESW_READ 0x04 205 u8 Link;
287#define DIST_LINESW_WRITE 0x08 206};
288#define DIST_LINESW_IOCTL 0x10
289#define DIST_LINESW_INPUT 0x20
290#define DIST_LINESW_OUTPUT 0x40
291#define DIST_LINESW_MDMINT 0x80
292 207
293#endif /* __rio_h__ */ 208#endif /* __rio_h__ */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index c9af283a811d..78dd856534ce 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -57,15 +57,12 @@
57#include <asm/uaccess.h> 57#include <asm/uaccess.h>
58 58
59#include "linux_compat.h" 59#include "linux_compat.h"
60#include "typdef.h"
61#include "pkt.h" 60#include "pkt.h"
62#include "daemon.h" 61#include "daemon.h"
63#include "rio.h" 62#include "rio.h"
64#include "riospace.h" 63#include "riospace.h"
65#include "top.h"
66#include "cmdpkt.h" 64#include "cmdpkt.h"
67#include "map.h" 65#include "map.h"
68#include "riotypes.h"
69#include "rup.h" 66#include "rup.h"
70#include "port.h" 67#include "port.h"
71#include "riodrvr.h" 68#include "riodrvr.h"
@@ -78,17 +75,13 @@
78#include "unixrup.h" 75#include "unixrup.h"
79#include "board.h" 76#include "board.h"
80#include "host.h" 77#include "host.h"
81#include "error.h"
82#include "phb.h" 78#include "phb.h"
83#include "link.h" 79#include "link.h"
84#include "cmdblk.h" 80#include "cmdblk.h"
85#include "route.h" 81#include "route.h"
86#include "control.h"
87#include "cirrus.h" 82#include "cirrus.h"
88#include "rioioctl.h" 83#include "rioioctl.h"
89#include "param.h" 84#include "param.h"
90#include "list.h"
91#include "sam.h"
92#include "protsts.h" 85#include "protsts.h"
93#include "rioboard.h" 86#include "rioboard.h"
94 87
@@ -297,7 +290,7 @@ static void my_hd(void *ad, int len)
297 unsigned char *addr = ad; 290 unsigned char *addr = ad;
298 291
299 for (i = 0; i < len; i += 16) { 292 for (i = 0; i < len; i += 16) {
300 rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i); 293 rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i);
301 for (j = 0; j < 16; j++) { 294 for (j = 0; j < 16; j++) {
302 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : ""); 295 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
303 } 296 }
@@ -340,34 +333,19 @@ int RIODelay_ni(struct Port *PortP, int njiffies)
340 return !RIO_FAIL; 333 return !RIO_FAIL;
341} 334}
342 335
343 336void rio_copy_to_card(void *to, void *from, int len)
344int rio_minor(struct tty_struct *tty)
345{ 337{
346 return tty->index + (tty->driver == rio_driver) ? 0 : 256; 338 rio_memcpy_toio(NULL, to, from, len);
347} 339}
348 340
349 341int rio_minor(struct tty_struct *tty)
350int rio_ismodem(struct tty_struct *tty)
351{ 342{
352 return 1; 343 return tty->index + (tty->driver == rio_driver) ? 0 : 256;
353} 344}
354 345
355
356static int rio_set_real_termios(void *ptr) 346static int rio_set_real_termios(void *ptr)
357{ 347{
358 int rv, modem; 348 return RIOParam((struct Port *) ptr, CONFIG, 1, 1);
359 struct tty_struct *tty;
360 func_enter();
361
362 tty = ((struct Port *) ptr)->gs.tty;
363
364 modem = rio_ismodem(tty);
365
366 rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1);
367
368 func_exit();
369
370 return rv;
371} 349}
372 350
373 351
@@ -379,7 +357,7 @@ static void rio_reset_interrupt(struct Host *HostP)
379 case RIO_AT: 357 case RIO_AT:
380 case RIO_MCA: 358 case RIO_MCA:
381 case RIO_PCI: 359 case RIO_PCI:
382 WBYTE(HostP->ResetInt, 0xff); 360 writeb(0xFF, &HostP->ResetInt);
383 } 361 }
384 362
385 func_exit(); 363 func_exit();
@@ -397,9 +375,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
397 /* AAargh! The order in which to do these things is essential and 375 /* AAargh! The order in which to do these things is essential and
398 not trivial. 376 not trivial.
399 377
400 - Rate limit goes before "recursive". Otherwise a series of
401 recursive calls will hang the machine in the interrupt routine.
402
403 - hardware twiddling goes before "recursive". Otherwise when we 378 - hardware twiddling goes before "recursive". Otherwise when we
404 poll the card, and a recursive interrupt happens, we won't 379 poll the card, and a recursive interrupt happens, we won't
405 ack the card, so it might keep on interrupting us. (especially 380 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)
414 - The initialized test goes before recursive. 389 - The initialized test goes before recursive.
415 */ 390 */
416 391
417
418
419#ifdef IRQ_RATE_LIMIT
420 /* Aaargh! I'm ashamed. This costs more lines-of-code than the
421 actual interrupt routine!. (Well, used to when I wrote that comment) */
422 {
423 static int lastjif;
424 static int nintr = 0;
425
426 if (lastjif == jiffies) {
427 if (++nintr > IRQ_RATE_LIMIT) {
428 free_irq(HostP->Ivec, ptr);
429 printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec);
430 }
431 } else {
432 lastjif = jiffies;
433 nintr = 0;
434 }
435 }
436#endif
437 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); 392 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
438 if (HostP->Ivec == irq) { 393 if (HostP->Ivec == irq) {
439 /* Tell the card we've noticed the interrupt. */ 394 /* 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)
444 return IRQ_HANDLED; 399 return IRQ_HANDLED;
445 400
446 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { 401 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
447 printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec); 402 printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec);
448 return IRQ_HANDLED; 403 return IRQ_HANDLED;
449 } 404 }
450 405
451 RIOServiceHost(p, HostP, irq); 406 RIOServiceHost(p, HostP, irq);
452 407
453 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type); 408 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type);
454 409
455 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); 410 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
456 rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); 411 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)
873#define HOST_SZ sizeof(struct Host) 828#define HOST_SZ sizeof(struct Host)
874#define PORT_SZ sizeof(struct Port *) 829#define PORT_SZ sizeof(struct Port *)
875#define TMIO_SZ sizeof(struct termios *) 830#define TMIO_SZ sizeof(struct termios *)
876 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); 831 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);
877 832
878 if (!(p = ckmalloc(RI_SZ))) 833 if (!(p = ckmalloc(RI_SZ)))
879 goto free0; 834 goto free0;
@@ -963,22 +918,21 @@ static void __exit rio_release_drivers(void)
963 918
964static void fix_rio_pci(struct pci_dev *pdev) 919static void fix_rio_pci(struct pci_dev *pdev)
965{ 920{
966 unsigned int hwbase; 921 unsigned long hwbase;
967 unsigned long rebase; 922 unsigned char *rebase;
968 unsigned int t; 923 unsigned int t;
969 924
970#define CNTRL_REG_OFFSET 0x50 925#define CNTRL_REG_OFFSET 0x50
971#define CNTRL_REG_GOODVALUE 0x18260000 926#define CNTRL_REG_GOODVALUE 0x18260000
972 927
973 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); 928 hwbase = pci_resource_start(pdev, 0);
974 hwbase &= PCI_BASE_ADDRESS_MEM_MASK; 929 rebase = ioremap(hwbase, 0x80);
975 rebase = (ulong) ioremap(hwbase, 0x80);
976 t = readl(rebase + CNTRL_REG_OFFSET); 930 t = readl(rebase + CNTRL_REG_OFFSET);
977 if (t != CNTRL_REG_GOODVALUE) { 931 if (t != CNTRL_REG_GOODVALUE) {
978 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); 932 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
979 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); 933 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
980 } 934 }
981 iounmap((char *) rebase); 935 iounmap(rebase);
982} 936}
983#endif 937#endif
984 938
@@ -994,7 +948,6 @@ static int __init rio_init(void)
994 948
995#ifdef CONFIG_PCI 949#ifdef CONFIG_PCI
996 struct pci_dev *pdev = NULL; 950 struct pci_dev *pdev = NULL;
997 unsigned int tint;
998 unsigned short tshort; 951 unsigned short tshort;
999#endif 952#endif
1000 953
@@ -1019,6 +972,8 @@ static int __init rio_init(void)
1019#ifdef CONFIG_PCI 972#ifdef CONFIG_PCI
1020 /* First look for the JET devices: */ 973 /* First look for the JET devices: */
1021 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { 974 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
975 u32 tint;
976
1022 if (pci_enable_device(pdev)) 977 if (pci_enable_device(pdev))
1023 continue; 978 continue;
1024 979
@@ -1029,7 +984,6 @@ static int __init rio_init(void)
1029 Also, reading a non-aligned dword doesn't work. So we read the 984 Also, reading a non-aligned dword doesn't work. So we read the
1030 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) 985 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
1031 ourselves */ 986 ourselves */
1032 /* I don't know why the define doesn't work, constant 0x2c does --REW */
1033 pci_read_config_dword(pdev, 0x2c, &tint); 987 pci_read_config_dword(pdev, 0x2c, &tint);
1034 tshort = (tint >> 16) & 0xffff; 988 tshort = (tint >> 16) & 0xffff;
1035 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); 989 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
@@ -1039,33 +993,31 @@ static int __init rio_init(void)
1039 } 993 }
1040 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n"); 994 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
1041 995
1042 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
1043
1044 hp = &p->RIOHosts[p->RIONumHosts]; 996 hp = &p->RIOHosts[p->RIONumHosts];
1045 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; 997 hp->PaddrP = pci_resource_start(pdev, 2);
1046 hp->Ivec = pdev->irq; 998 hp->Ivec = pdev->irq;
1047 if (((1 << hp->Ivec) & rio_irqmask) == 0) 999 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1048 hp->Ivec = 0; 1000 hp->Ivec = 0;
1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1001 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1050 hp->CardP = (struct DpRam *) hp->Caddr; 1002 hp->CardP = (struct DpRam *) hp->Caddr;
1051 hp->Type = RIO_PCI; 1003 hp->Type = RIO_PCI;
1052 hp->Copy = rio_pcicopy; 1004 hp->Copy = rio_copy_to_card;
1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1005 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1054 spin_lock_init(&hp->HostLock); 1006 spin_lock_init(&hp->HostLock);
1055 rio_reset_interrupt(hp); 1007 rio_reset_interrupt(hp);
1056 rio_start_card_running(hp); 1008 rio_start_card_running(hp);
1057 1009
1058 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); 1010 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1059 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { 1011 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
1060 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n"); 1012 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
1061 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); 1013 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
1062 p->RIOHosts[p->RIONumHosts].UniqueNum = 1014 p->RIOHosts[p->RIONumHosts].UniqueNum =
1063 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | 1015 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1064 ((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); 1016 ((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);
1065 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1066 1018
1067 fix_rio_pci(pdev); 1019 fix_rio_pci(pdev);
1068 p->RIOLastPCISearch = RIO_SUCCESS; 1020 p->RIOLastPCISearch = 0;
1069 p->RIONumHosts++; 1021 p->RIONumHosts++;
1070 found++; 1022 found++;
1071 } else { 1023 } else {
@@ -1088,10 +1040,8 @@ static int __init rio_init(void)
1088 continue; 1040 continue;
1089 1041
1090#ifdef CONFIG_RIO_OLDPCI 1042#ifdef CONFIG_RIO_OLDPCI
1091 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
1092
1093 hp = &p->RIOHosts[p->RIONumHosts]; 1043 hp = &p->RIOHosts[p->RIONumHosts];
1094 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; 1044 hp->PaddrP = pci_resource_start(pdev, 0);
1095 hp->Ivec = pdev->irq; 1045 hp->Ivec = pdev->irq;
1096 if (((1 << hp->Ivec) & rio_irqmask) == 0) 1046 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1097 hp->Ivec = 0; 1047 hp->Ivec = 0;
@@ -1099,7 +1049,7 @@ static int __init rio_init(void)
1099 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1100 hp->CardP = (struct DpRam *) hp->Caddr; 1050 hp->CardP = (struct DpRam *) hp->Caddr;
1101 hp->Type = RIO_PCI; 1051 hp->Type = RIO_PCI;
1102 hp->Copy = rio_pcicopy; 1052 hp->Copy = rio_copy_to_card;
1103 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1104 spin_lock_init(&hp->HostLock); 1054 spin_lock_init(&hp->HostLock);
1105 1055
@@ -1109,14 +1059,14 @@ static int __init rio_init(void)
1109 rio_reset_interrupt(hp); 1059 rio_reset_interrupt(hp);
1110 rio_start_card_running(hp); 1060 rio_start_card_running(hp);
1111 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); 1061 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1112 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { 1062 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
1113 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); 1063 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
1114 p->RIOHosts[p->RIONumHosts].UniqueNum = 1064 p->RIOHosts[p->RIONumHosts].UniqueNum =
1115 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | 1065 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1116 ((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); 1066 ((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);
1117 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1067 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1118 1068
1119 p->RIOLastPCISearch = RIO_SUCCESS; 1069 p->RIOLastPCISearch = 0;
1120 p->RIONumHosts++; 1070 p->RIONumHosts++;
1121 found++; 1071 found++;
1122 } else { 1072 } else {
@@ -1137,8 +1087,8 @@ static int __init rio_init(void)
1137 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1087 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1138 hp->CardP = (struct DpRam *) hp->Caddr; 1088 hp->CardP = (struct DpRam *) hp->Caddr;
1139 hp->Type = RIO_AT; 1089 hp->Type = RIO_AT;
1140 hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL 1090 hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
1141 * -- YES! this is now a normal copy. Only the 1091 * -- YES! this is now a normal copy. Only the
1142 * old PCI card uses the special PCI copy. 1092 * old PCI card uses the special PCI copy.
1143 * Moreover, the ISA card will work with the 1093 * Moreover, the ISA card will work with the
1144 * special PCI copy anyway. -- REW */ 1094 * special PCI copy anyway. -- REW */
@@ -1150,7 +1100,7 @@ static int __init rio_init(void)
1150 okboard = 0; 1100 okboard = 0;
1151 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)) { 1101 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)) {
1152 /* Board is present... */ 1102 /* Board is present... */
1153 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) { 1103 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) {
1154 /* ... and feeling fine!!!! */ 1104 /* ... and feeling fine!!!! */
1155 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1105 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1156 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { 1106 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
@@ -1252,24 +1202,3 @@ static void __exit rio_exit(void)
1252 1202
1253module_init(rio_init); 1203module_init(rio_init);
1254module_exit(rio_exit); 1204module_exit(rio_exit);
1255
1256/*
1257 * Anybody who knows why this doesn't work for me, please tell me -- REW.
1258 * Snatched from scsi.c (fixed one spelling error):
1259 * Overrides for Emacs so that we follow Linus' tabbing style.
1260 * Emacs will notice this stuff at the end of the file and automatically
1261 * adjust the settings for this buffer only. This must remain at the end
1262 * of the file.
1263 * ---------------------------------------------------------------------------
1264 * Local Variables:
1265 * c-indent-level: 4
1266 * c-brace-imaginary-offset: 0
1267 * c-brace-offset: -4
1268 * c-argdecl-indent: 4
1269 * c-label-offset: -4
1270 * c-continued-statement-offset: 4
1271 * c-continued-brace-offset: 0
1272 * indent-tabs-mode: nil
1273 * tab-width: 8
1274 * End:
1275 */
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index 92df43552f15..acda9326c2ef 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -30,38 +30,29 @@
30** ----------------------------------------------------------------------------- 30** -----------------------------------------------------------------------------
31*/ 31*/
32 32
33#ifdef SCCS_LABELS
34static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
35#endif
36
37#include <linux/module.h> 33#include <linux/module.h>
38#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/termios.h>
36#include <linux/serial.h>
37#include <asm/semaphore.h>
38#include <linux/generic_serial.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/delay.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/system.h> 43#include <asm/system.h>
43#include <asm/string.h> 44#include <asm/string.h>
44#include <asm/semaphore.h> 45#include <asm/uaccess.h>
45
46
47#include <linux/termios.h>
48#include <linux/serial.h>
49
50#include <linux/generic_serial.h>
51
52 46
53 47
54#include "linux_compat.h" 48#include "linux_compat.h"
55#include "rio_linux.h" 49#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h" 50#include "pkt.h"
58#include "daemon.h" 51#include "daemon.h"
59#include "rio.h" 52#include "rio.h"
60#include "riospace.h" 53#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h" 54#include "cmdpkt.h"
63#include "map.h" 55#include "map.h"
64#include "riotypes.h"
65#include "rup.h" 56#include "rup.h"
66#include "port.h" 57#include "port.h"
67#include "riodrvr.h" 58#include "riodrvr.h"
@@ -74,161 +65,130 @@ static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
74#include "unixrup.h" 65#include "unixrup.h"
75#include "board.h" 66#include "board.h"
76#include "host.h" 67#include "host.h"
77#include "error.h"
78#include "phb.h" 68#include "phb.h"
79#include "link.h" 69#include "link.h"
80#include "cmdblk.h" 70#include "cmdblk.h"
81#include "route.h" 71#include "route.h"
82 72
83static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP ); 73static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP);
84 74
85static uchar 75static const unsigned char RIOAtVec2Ctrl[] = {
86RIOAtVec2Ctrl[] = 76 /* 0 */ INTERRUPT_DISABLE,
87{ 77 /* 1 */ INTERRUPT_DISABLE,
88 /* 0 */ INTERRUPT_DISABLE, 78 /* 2 */ INTERRUPT_DISABLE,
89 /* 1 */ INTERRUPT_DISABLE, 79 /* 3 */ INTERRUPT_DISABLE,
90 /* 2 */ INTERRUPT_DISABLE, 80 /* 4 */ INTERRUPT_DISABLE,
91 /* 3 */ INTERRUPT_DISABLE, 81 /* 5 */ INTERRUPT_DISABLE,
92 /* 4 */ INTERRUPT_DISABLE, 82 /* 6 */ INTERRUPT_DISABLE,
93 /* 5 */ INTERRUPT_DISABLE, 83 /* 7 */ INTERRUPT_DISABLE,
94 /* 6 */ INTERRUPT_DISABLE, 84 /* 8 */ INTERRUPT_DISABLE,
95 /* 7 */ INTERRUPT_DISABLE, 85 /* 9 */ IRQ_9 | INTERRUPT_ENABLE,
96 /* 8 */ INTERRUPT_DISABLE,
97 /* 9 */ IRQ_9|INTERRUPT_ENABLE,
98 /* 10 */ INTERRUPT_DISABLE, 86 /* 10 */ INTERRUPT_DISABLE,
99 /* 11 */ IRQ_11|INTERRUPT_ENABLE, 87 /* 11 */ IRQ_11 | INTERRUPT_ENABLE,
100 /* 12 */ IRQ_12|INTERRUPT_ENABLE, 88 /* 12 */ IRQ_12 | INTERRUPT_ENABLE,
101 /* 13 */ INTERRUPT_DISABLE, 89 /* 13 */ INTERRUPT_DISABLE,
102 /* 14 */ INTERRUPT_DISABLE, 90 /* 14 */ INTERRUPT_DISABLE,
103 /* 15 */ IRQ_15|INTERRUPT_ENABLE 91 /* 15 */ IRQ_15 | INTERRUPT_ENABLE
104}; 92};
105 93
106/* 94/**
107** Load in the RTA boot code. 95 * RIOBootCodeRTA - Load RTA boot code
108*/ 96 * @p: RIO to load
109int 97 * @rbp: Download descriptor
110RIOBootCodeRTA(p, rbp) 98 *
111struct rio_info * p; 99 * Called when the user process initiates booting of the card firmware.
112struct DownLoad * rbp; 100 * Lads the firmware
101 */
102
103int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp)
113{ 104{
114 int offset; 105 int offset;
115 106
116 func_enter (); 107 func_enter();
117 108
118 /* Linux doesn't allow you to disable interrupts during a 109 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP);
119 "copyin". (Crash when a pagefault occurs). */
120 /* disable(oldspl); */
121
122 rio_dprintk (RIO_DEBUG_BOOT, "Data at user address 0x%x\n",(int)rbp->DataP);
123 110
124 /* 111 /*
125 ** Check that we have set asside enough memory for this 112 ** Check that we have set asside enough memory for this
126 */ 113 */
127 if ( rbp->Count > SIXTY_FOUR_K ) { 114 if (rbp->Count > SIXTY_FOUR_K) {
128 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n"); 115 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
129 p->RIOError.Error = HOST_FILE_TOO_LARGE; 116 p->RIOError.Error = HOST_FILE_TOO_LARGE;
130 /* restore(oldspl); */ 117 func_exit();
131 func_exit ();
132 return -ENOMEM; 118 return -ENOMEM;
133 } 119 }
134 120
135 if ( p->RIOBooting ) { 121 if (p->RIOBooting) {
136 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n"); 122 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
137 p->RIOError.Error = BOOT_IN_PROGRESS; 123 p->RIOError.Error = BOOT_IN_PROGRESS;
138 /* restore(oldspl); */ 124 func_exit();
139 func_exit ();
140 return -EBUSY; 125 return -EBUSY;
141 } 126 }
142 127
143 /* 128 /*
144 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary, 129 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
145 ** so calculate how far we have to move the data up the buffer 130 ** so calculate how far we have to move the data up the buffer
146 ** to achieve this. 131 ** to achieve this.
147 */ 132 */
148 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % 133 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
149 RTA_BOOT_DATA_SIZE;
150 134
151 /* 135 /*
152 ** Be clean, and clear the 'unused' portion of the boot buffer, 136 ** Be clean, and clear the 'unused' portion of the boot buffer,
153 ** because it will (eventually) be part of the Rta run time environment 137 ** because it will (eventually) be part of the Rta run time environment
154 ** and so should be zeroed. 138 ** and so should be zeroed.
155 */ 139 */
156 bzero( (caddr_t)p->RIOBootPackets, offset ); 140 memset(p->RIOBootPackets, 0, offset);
157 141
158 /* 142 /*
159 ** Copy the data from user space. 143 ** Copy the data from user space into the array
160 */ 144 */
161 145
162 if ( copyin((int)rbp->DataP,((caddr_t)(p->RIOBootPackets))+offset, 146 if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) {
163 rbp->Count) ==COPYFAIL ) { 147 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
164 rio_dprintk (RIO_DEBUG_BOOT, "Bad data copy from user space\n");
165 p->RIOError.Error = COPYIN_FAILED; 148 p->RIOError.Error = COPYIN_FAILED;
166 /* restore(oldspl); */ 149 func_exit();
167 func_exit ();
168 return -EFAULT; 150 return -EFAULT;
169 } 151 }
170 152
171 /* 153 /*
172 ** Make sure that our copy of the size includes that offset we discussed 154 ** Make sure that our copy of the size includes that offset we discussed
173 ** earlier. 155 ** earlier.
174 */ 156 */
175 p->RIONumBootPkts = (rbp->Count+offset)/RTA_BOOT_DATA_SIZE; 157 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
176 p->RIOBootCount = rbp->Count; 158 p->RIOBootCount = rbp->Count;
177 159
178 /* restore(oldspl); */
179 func_exit(); 160 func_exit();
180 return 0; 161 return 0;
181} 162}
182 163
183void rio_start_card_running (struct Host * HostP) 164/**
184{ 165 * rio_start_card_running - host card start
185 func_enter (); 166 * @HostP: The RIO to kick off
167 *
168 * Start a RIO processor unit running. Encapsulates the knowledge
169 * of the card type.
170 */
186 171
187 switch ( HostP->Type ) { 172void rio_start_card_running(struct Host *HostP)
173{
174 switch (HostP->Type) {
188 case RIO_AT: 175 case RIO_AT:
189 rio_dprintk (RIO_DEBUG_BOOT, "Start ISA card running\n"); 176 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
190 WBYTE(HostP->Control, 177 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control);
191 BOOT_FROM_RAM | EXTERNAL_BUS_ON
192 | HostP->Mode
193 | RIOAtVec2Ctrl[HostP->Ivec & 0xF] );
194 break;
195
196#ifdef FUTURE_RELEASE
197 case RIO_MCA:
198 /*
199 ** MCA handles IRQ vectors differently, so we don't write
200 ** them to this register.
201 */
202 rio_dprintk (RIO_DEBUG_BOOT, "Start MCA card running\n");
203 WBYTE(HostP->Control, McaTpBootFromRam | McaTpBusEnable | HostP->Mode);
204 break; 178 break;
205
206 case RIO_EISA:
207 /*
208 ** EISA is totally different and expects OUTBZs to turn it on.
209 */
210 rio_dprintk (RIO_DEBUG_BOOT, "Start EISA card running\n");
211 OUTBZ( HostP->Slot, EISA_CONTROL_PORT, HostP->Mode | RIOEisaVec2Ctrl[HostP->Ivec] | EISA_TP_RUN | EISA_TP_BUS_ENABLE | EISA_TP_BOOT_FROM_RAM );
212 break;
213#endif
214
215 case RIO_PCI: 179 case RIO_PCI:
216 /* 180 /*
217 ** PCI is much the same as MCA. Everything is once again memory 181 ** PCI is much the same as MCA. Everything is once again memory
218 ** mapped, so we are writing to memory registers instead of io 182 ** mapped, so we are writing to memory registers instead of io
219 ** ports. 183 ** ports.
220 */ 184 */
221 rio_dprintk (RIO_DEBUG_BOOT, "Start PCI card running\n"); 185 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
222 WBYTE(HostP->Control, PCITpBootFromRam | PCITpBusEnable | HostP->Mode); 186 writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control);
223 break; 187 break;
224 default: 188 default:
225 rio_dprintk (RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type); 189 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
226 break; 190 break;
227 } 191 }
228/*
229 printk (KERN_INFO "Done with starting the card\n");
230 func_exit ();
231*/
232 return; 192 return;
233} 193}
234 194
@@ -239,370 +199,350 @@ void rio_start_card_running (struct Host * HostP)
239** Put your rubber pants on before messing with this code - even the magic 199** Put your rubber pants on before messing with this code - even the magic
240** numbers have trouble understanding what they are doing here. 200** numbers have trouble understanding what they are doing here.
241*/ 201*/
242int 202
243RIOBootCodeHOST(p, rbp) 203int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
244struct rio_info * p;
245register struct DownLoad *rbp;
246{ 204{
247 register struct Host *HostP; 205 struct Host *HostP;
248 register caddr_t Cad; 206 u8 *Cad;
249 register PARM_MAP *ParmMapP; 207 PARM_MAP *ParmMapP;
250 register int RupN; 208 int RupN;
251 int PortN; 209 int PortN;
252 uint host; 210 unsigned int host;
253 caddr_t StartP; 211 u8 *StartP;
254 BYTE *DestP; 212 u8 *DestP;
255 int wait_count; 213 int wait_count;
256 ushort OldParmMap; 214 u16 OldParmMap;
257 ushort offset; /* It is very important that this is a ushort */ 215 u16 offset; /* It is very important that this is a u16 */
258 /* uint byte; */ 216 u8 *DownCode = NULL;
259 caddr_t DownCode = NULL;
260 unsigned long flags; 217 unsigned long flags;
261 218
262 HostP = NULL; /* Assure the compiler we've initialized it */ 219 HostP = NULL; /* Assure the compiler we've initialized it */
263 for ( host=0; host<p->RIONumHosts; host++ ) { 220
264 rio_dprintk (RIO_DEBUG_BOOT, "Attempt to boot host %d\n",host); 221
222 /* Walk the hosts */
223 for (host = 0; host < p->RIONumHosts; host++) {
224 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
265 HostP = &p->RIOHosts[host]; 225 HostP = &p->RIOHosts[host];
266
267 rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n",
268 HostP->Type, HostP->Mode, HostP->Ivec);
269 226
227 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
270 228
271 if ( (HostP->Flags & RUN_STATE) != RC_WAITING ) { 229 /* Don't boot hosts already running */
272 rio_dprintk (RIO_DEBUG_BOOT, "%s %d already running\n","Host",host); 230 if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
231 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
273 continue; 232 continue;
274 } 233 }
275 234
276 /* 235 /*
277 ** Grab a 32 bit pointer to the card. 236 ** Grab a pointer to the card (ioremapped)
278 */ 237 */
279 Cad = HostP->Caddr; 238 Cad = HostP->Caddr;
280 239
281 /* 240 /*
282 ** We are going to (try) and load in rbp->Count bytes. 241 ** We are going to (try) and load in rbp->Count bytes.
283 ** The last byte will reside at p->RIOConf.HostLoadBase-1; 242 ** The last byte will reside at p->RIOConf.HostLoadBase-1;
284 ** Therefore, we need to start copying at address 243 ** Therefore, we need to start copying at address
285 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count) 244 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
286 */ 245 */
287 StartP = (caddr_t)&Cad[p->RIOConf.HostLoadBase-rbp->Count]; 246 StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count];
288 247
289 rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for host is 0x%x\n", (int)Cad ); 248 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad);
290 rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for download is 0x%x\n", (int)StartP); 249 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP);
291 rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase); 250 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
292 rio_dprintk (RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count); 251 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
293 252
294 if ( p->RIOConf.HostLoadBase < rbp->Count ) { 253 /* Make sure it fits */
295 rio_dprintk (RIO_DEBUG_BOOT, "Bin too large\n"); 254 if (p->RIOConf.HostLoadBase < rbp->Count) {
255 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
296 p->RIOError.Error = HOST_FILE_TOO_LARGE; 256 p->RIOError.Error = HOST_FILE_TOO_LARGE;
297 func_exit (); 257 func_exit();
298 return -EFBIG; 258 return -EFBIG;
299 } 259 }
300 /* 260 /*
301 ** Ensure that the host really is stopped. 261 ** Ensure that the host really is stopped.
302 ** Disable it's external bus & twang its reset line. 262 ** Disable it's external bus & twang its reset line.
303 */ 263 */
304 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); 264 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
305
306 /*
307 ** Copy the data directly from user space to the SRAM.
308 ** This ain't going to be none too clever if the download
309 ** code is bigger than this segment.
310 */
311 rio_dprintk (RIO_DEBUG_BOOT, "Copy in code\n");
312 265
313 /* 266 /*
314 ** PCI hostcard can't cope with 32 bit accesses and so need to copy 267 ** Copy the data directly from user space to the SRAM.
315 ** data to a local buffer, and then dripfeed the card. 268 ** This ain't going to be none too clever if the download
316 */ 269 ** code is bigger than this segment.
317 if ( HostP->Type == RIO_PCI ) { 270 */
318 /* int offset; */ 271 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
319 272
320 DownCode = sysbrk(rbp->Count); 273 /* Buffer to local memory as we want to use I/O space and
321 if ( !DownCode ) { 274 some cards only do 8 or 16 bit I/O */
322 rio_dprintk (RIO_DEBUG_BOOT, "No system memory available\n"); 275
323 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY; 276 DownCode = vmalloc(rbp->Count);
324 func_exit (); 277 if (!DownCode) {
325 return -ENOMEM; 278 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
326 } 279 func_exit();
327 bzero(DownCode, rbp->Count); 280 return -ENOMEM;
328
329 if ( copyin((int)rbp->DataP,DownCode,rbp->Count)==COPYFAIL ) {
330 rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
331 sysfree( DownCode, rbp->Count );
332 p->RIOError.Error = COPYIN_FAILED;
333 func_exit ();
334 return -EFAULT;
335 }
336
337 HostP->Copy( DownCode, StartP, rbp->Count );
338
339 sysfree( DownCode, rbp->Count );
340 } 281 }
341 else if ( copyin((int)rbp->DataP,StartP,rbp->Count)==COPYFAIL ) { 282 if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) {
342 rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n"); 283 kfree(DownCode);
343 p->RIOError.Error = COPYIN_FAILED; 284 p->RIOError.Error = COPYIN_FAILED;
344 func_exit (); 285 func_exit();
345 return -EFAULT; 286 return -EFAULT;
346 } 287 }
288 HostP->Copy(DownCode, StartP, rbp->Count);
289 vfree(DownCode);
347 290
348 rio_dprintk (RIO_DEBUG_BOOT, "Copy completed\n"); 291 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
349 292
350 /* 293 /*
351 ** S T O P ! 294 ** S T O P !
352 ** 295 **
353 ** Upto this point the code has been fairly rational, and possibly 296 ** Upto this point the code has been fairly rational, and possibly
354 ** even straight forward. What follows is a pile of crud that will 297 ** even straight forward. What follows is a pile of crud that will
355 ** magically turn into six bytes of transputer assembler. Normally 298 ** magically turn into six bytes of transputer assembler. Normally
356 ** you would expect an array or something, but, being me, I have 299 ** you would expect an array or something, but, being me, I have
357 ** chosen [been told] to use a technique whereby the startup code 300 ** chosen [been told] to use a technique whereby the startup code
358 ** will be correct if we change the loadbase for the code. Which 301 ** will be correct if we change the loadbase for the code. Which
359 ** brings us onto another issue - the loadbase is the *end* of the 302 ** brings us onto another issue - the loadbase is the *end* of the
360 ** code, not the start. 303 ** code, not the start.
361 ** 304 **
362 ** If I were you I wouldn't start from here. 305 ** If I were you I wouldn't start from here.
363 */ 306 */
364 307
365 /* 308 /*
366 ** We now need to insert a short boot section into 309 ** We now need to insert a short boot section into
367 ** the memory at the end of Sram2. This is normally (de)composed 310 ** the memory at the end of Sram2. This is normally (de)composed
368 ** of the last eight bytes of the download code. The 311 ** of the last eight bytes of the download code. The
369 ** download has been assembled/compiled to expect to be 312 ** download has been assembled/compiled to expect to be
370 ** loaded from 0x7FFF downwards. We have loaded it 313 ** loaded from 0x7FFF downwards. We have loaded it
371 ** at some other address. The startup code goes into the small 314 ** at some other address. The startup code goes into the small
372 ** ram window at Sram2, in the last 8 bytes, which are really 315 ** ram window at Sram2, in the last 8 bytes, which are really
373 ** at addresses 0x7FF8-0x7FFF. 316 ** at addresses 0x7FF8-0x7FFF.
374 ** 317 **
375 ** If the loadbase is, say, 0x7C00, then we need to branch to 318 ** If the loadbase is, say, 0x7C00, then we need to branch to
376 ** address 0x7BFE to run the host.bin startup code. We assemble 319 ** address 0x7BFE to run the host.bin startup code. We assemble
377 ** this jump manually. 320 ** this jump manually.
378 ** 321 **
379 ** The two byte sequence 60 08 is loaded into memory at address 322 ** The two byte sequence 60 08 is loaded into memory at address
380 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0, 323 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
381 ** which adds '0' to the .O register, complements .O, and then shifts 324 ** which adds '0' to the .O register, complements .O, and then shifts
382 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will 325 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
383 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new 326 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
384 ** location. Now, the branch starts from the value of .PC (or .IP or 327 ** location. Now, the branch starts from the value of .PC (or .IP or
385 ** whatever the bloody register is called on this chip), and the .PC 328 ** whatever the bloody register is called on this chip), and the .PC
386 ** will be pointing to the location AFTER the branch, in this case 329 ** will be pointing to the location AFTER the branch, in this case
387 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8. 330 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
388 ** 331 **
389 ** A long branch is coded at 0x7FF8. This consists of loading a four 332 ** A long branch is coded at 0x7FF8. This consists of loading a four
390 ** byte offset into .O using nfix (as above) and pfix operators. The 333 ** byte offset into .O using nfix (as above) and pfix operators. The
391 ** pfix operates in exactly the same way as the nfix operator, but 334 ** pfix operates in exactly the same way as the nfix operator, but
392 ** without the complement operation. The offset, of course, must be 335 ** without the complement operation. The offset, of course, must be
393 ** relative to the address of the byte AFTER the branch instruction, 336 ** relative to the address of the byte AFTER the branch instruction,
394 ** which will be (urm) 0x7FFC, so, our final destination of the branch 337 ** which will be (urm) 0x7FFC, so, our final destination of the branch
395 ** (loadbase-2), has to be reached from here. Imagine that the loadbase 338 ** (loadbase-2), has to be reached from here. Imagine that the loadbase
396 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which 339 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
397 ** is the first byte of the initial two byte short local branch of the 340 ** is the first byte of the initial two byte short local branch of the
398 ** download code). 341 ** download code).
399 ** 342 **
400 ** To code a jump from 0x7FFC (which is where the branch will start 343 ** To code a jump from 0x7FFC (which is where the branch will start
401 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)= 344 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
402 ** 0x7BFE. 345 ** 0x7BFE.
403 ** This will be coded as four bytes: 346 ** This will be coded as four bytes:
404 ** 60 2C 20 02 347 ** 60 2C 20 02
405 ** being nfix .O+0 348 ** being nfix .O+0
406 ** pfix .O+C 349 ** pfix .O+C
407 ** pfix .O+0 350 ** pfix .O+0
408 ** jump .O+2 351 ** jump .O+2
409 ** 352 **
410 ** The nfix operator is used, so that the startup code will be 353 ** The nfix operator is used, so that the startup code will be
411 ** compatible with the whole Tp family. (lies, damn lies, it'll never 354 ** compatible with the whole Tp family. (lies, damn lies, it'll never
412 ** work in a month of Sundays). 355 ** work in a month of Sundays).
413 ** 356 **
414 ** The nfix nyble is the 1s complement of the nyble value you 357 ** The nfix nyble is the 1s complement of the nyble value you
415 ** want to load - in this case we wanted 'F' so we nfix loaded '0'. 358 ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
416 */ 359 */
417 360
418 361
419 /* 362 /*
420 ** Dest points to the top 8 bytes of Sram2. The Tp jumps 363 ** Dest points to the top 8 bytes of Sram2. The Tp jumps
421 ** to 0x7FFE at reset time, and starts executing. This is 364 ** to 0x7FFE at reset time, and starts executing. This is
422 ** a short branch to 0x7FF8, where a long branch is coded. 365 ** a short branch to 0x7FF8, where a long branch is coded.
423 */ 366 */
424 367
425 DestP = (BYTE *)&Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ 368 DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
426 369
427#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ 370#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
428#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ 371#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
429#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */ 372#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
430 373
431 /* 374 /*
432 ** 0x7FFC is the address of the location following the last byte of 375 ** 0x7FFC is the address of the location following the last byte of
433 ** the four byte jump instruction. 376 ** the four byte jump instruction.
434 ** READ THE ABOVE COMMENTS 377 ** READ THE ABOVE COMMENTS
435 ** 378 **
436 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about. 379 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
437 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned, 380 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
438 ** cos I don't understand 2's complement). 381 ** cos I don't understand 2's complement).
439 */ 382 */
440 offset = (p->RIOConf.HostLoadBase-2)-0x7FFC; 383 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
441 WBYTE( DestP[0] , NFIX(((ushort)(~offset) >> (ushort)12) & 0xF) ); 384
442 WBYTE( DestP[1] , PFIX(( offset >> 8) & 0xF) ); 385 writeb(NFIX(((unsigned short) (~offset) >> (unsigned short) 12) & 0xF), DestP);
443 WBYTE( DestP[2] , PFIX(( offset >> 4) & 0xF) ); 386 writeb(PFIX((offset >> 8) & 0xF), DestP + 1);
444 WBYTE( DestP[3] , JUMP( offset & 0xF) ); 387 writeb(PFIX((offset >> 4) & 0xF), DestP + 2);
445 388 writeb(JUMP(offset & 0xF), DestP + 3);
446 WBYTE( DestP[6] , NFIX(0) ); 389
447 WBYTE( DestP[7] , JUMP(8) ); 390 writeb(NFIX(0), DestP + 6);
448 391 writeb(JUMP(8), DestP + 7);
449 rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase); 392
450 rio_dprintk (RIO_DEBUG_BOOT, "startup offset is 0x%x\n",offset); 393 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
394 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
451 395
452 /* 396 /*
453 ** Flag what is going on 397 ** Flag what is going on
454 */ 398 */
455 HostP->Flags &= ~RUN_STATE; 399 HostP->Flags &= ~RUN_STATE;
456 HostP->Flags |= RC_STARTUP; 400 HostP->Flags |= RC_STARTUP;
457 401
458 /* 402 /*
459 ** Grab a copy of the current ParmMap pointer, so we 403 ** Grab a copy of the current ParmMap pointer, so we
460 ** can tell when it has changed. 404 ** can tell when it has changed.
461 */ 405 */
462 OldParmMap = RWORD(HostP->__ParmMapR); 406 OldParmMap = readw(&HostP->__ParmMapR);
463 407
464 rio_dprintk (RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n",OldParmMap); 408 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
465 409
466 /* 410 /*
467 ** And start it running (I hope). 411 ** And start it running (I hope).
468 ** As there is nothing dodgy or obscure about the 412 ** As there is nothing dodgy or obscure about the
469 ** above code, this is guaranteed to work every time. 413 ** above code, this is guaranteed to work every time.
470 */ 414 */
471 rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", 415 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
472 HostP->Type, HostP->Mode, HostP->Ivec);
473 416
474 rio_start_card_running(HostP); 417 rio_start_card_running(HostP);
475 418
476 rio_dprintk (RIO_DEBUG_BOOT, "Set control port\n"); 419 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
477 420
478 /* 421 /*
479 ** Now, wait for upto five seconds for the Tp to setup the parmmap 422 ** Now, wait for upto five seconds for the Tp to setup the parmmap
480 ** pointer: 423 ** pointer:
481 */ 424 */
482 for ( wait_count=0; (wait_count<p->RIOConf.StartupTime)&& 425 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) {
483 (RWORD(HostP->__ParmMapR)==OldParmMap); wait_count++ ) { 426 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR));
484 rio_dprintk (RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n",wait_count,RWORD(HostP->__ParmMapR)); 427 mdelay(100);
485 delay(HostP, HUNDRED_MS);
486 428
487 } 429 }
488 430
489 /* 431 /*
490 ** If the parmmap pointer is unchanged, then the host code 432 ** If the parmmap pointer is unchanged, then the host code
491 ** has crashed & burned in a really spectacular way 433 ** has crashed & burned in a really spectacular way
492 */ 434 */
493 if ( RWORD(HostP->__ParmMapR) == OldParmMap ) { 435 if (readw(&HostP->__ParmMapR) == OldParmMap) {
494 rio_dprintk (RIO_DEBUG_BOOT, "parmmap 0x%x\n", RWORD(HostP->__ParmMapR)); 436 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR));
495 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); 437 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
496 438 HostP->Flags &= ~RUN_STATE;
497#define HOST_DISABLE \ 439 HostP->Flags |= RC_STUFFED;
498 HostP->Flags &= ~RUN_STATE; \ 440 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
499 HostP->Flags |= RC_STUFFED; \ 441 continue;
500 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );\
501 continue
502
503 HOST_DISABLE;
504 } 442 }
505 443
506 rio_dprintk (RIO_DEBUG_BOOT, "Running 0x%x\n", RWORD(HostP->__ParmMapR)); 444 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR));
507 445
508 /* 446 /*
509 ** Well, the board thought it was OK, and setup its parmmap 447 ** Well, the board thought it was OK, and setup its parmmap
510 ** pointer. For the time being, we will pretend that this 448 ** pointer. For the time being, we will pretend that this
511 ** board is running, and check out what the error flag says. 449 ** board is running, and check out what the error flag says.
512 */ 450 */
513 451
514 /* 452 /*
515 ** Grab a 32 bit pointer to the parmmap structure 453 ** Grab a 32 bit pointer to the parmmap structure
516 */ 454 */
517 ParmMapP = (PARM_MAP *)RIO_PTR(Cad,RWORD(HostP->__ParmMapR)); 455 ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
518 rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP); 456 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
519 ParmMapP = (PARM_MAP *)((unsigned long)Cad + 457 ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR));
520 (unsigned long)((RWORD((HostP->__ParmMapR))) & 0xFFFF)); 458 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
521 rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP);
522 459
523 /* 460 /*
524 ** The links entry should be 0xFFFF; we set it up 461 ** The links entry should be 0xFFFF; we set it up
525 ** with a mask to say how many PHBs to use, and 462 ** with a mask to say how many PHBs to use, and
526 ** which links to use. 463 ** which links to use.
527 */ 464 */
528 if ( (RWORD(ParmMapP->links) & 0xFFFF) != 0xFFFF ) { 465 if (readw(&ParmMapP->links) != 0xFFFF) {
529 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 466 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
530 rio_dprintk (RIO_DEBUG_BOOT, "Links = 0x%x\n",RWORD(ParmMapP->links)); 467 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
531 HOST_DISABLE; 468 HostP->Flags &= ~RUN_STATE;
469 HostP->Flags |= RC_STUFFED;
470 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
471 continue;
532 } 472 }
533 473
534 WWORD(ParmMapP->links , RIO_LINK_ENABLE); 474 writew(RIO_LINK_ENABLE, &ParmMapP->links);
535 475
536 /* 476 /*
537 ** now wait for the card to set all the parmmap->XXX stuff 477 ** now wait for the card to set all the parmmap->XXX stuff
538 ** this is a wait of upto two seconds.... 478 ** this is a wait of upto two seconds....
539 */ 479 */
540 rio_dprintk (RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n",p->RIOConf.StartupTime); 480 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
541 HostP->timeout_id = 0; 481 HostP->timeout_id = 0;
542 for ( wait_count=0; (wait_count<p->RIOConf.StartupTime) && 482 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
543 !RWORD(ParmMapP->init_done); wait_count++ ) { 483 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
544 rio_dprintk (RIO_DEBUG_BOOT, "Waiting for init_done\n"); 484 mdelay(100);
545 delay(HostP, HUNDRED_MS);
546 } 485 }
547 rio_dprintk (RIO_DEBUG_BOOT, "OK! init_done!\n"); 486 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
548 487
549 if (RWORD(ParmMapP->error) != E_NO_ERROR || 488 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
550 !RWORD(ParmMapP->init_done) ) { 489 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
551 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 490 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
552 rio_dprintk (RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); 491 HostP->Flags &= ~RUN_STATE;
553 HOST_DISABLE; 492 HostP->Flags |= RC_STUFFED;
493 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
494 continue;
554 } 495 }
555 496
556 rio_dprintk (RIO_DEBUG_BOOT, "Got init_done\n"); 497 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
557 498
558 /* 499 /*
559 ** It runs! It runs! 500 ** It runs! It runs!
560 */ 501 */
561 rio_dprintk (RIO_DEBUG_BOOT, "Host ID %x Running\n",HostP->UniqueNum); 502 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
562 503
563 /* 504 /*
564 ** set the time period between interrupts. 505 ** set the time period between interrupts.
565 */ 506 */
566 WWORD(ParmMapP->timer, (short)p->RIOConf.Timer ); 507 writew(p->RIOConf.Timer, &ParmMapP->timer);
567 508
568 /* 509 /*
569 ** Translate all the 16 bit pointers in the __ParmMapR into 510 ** Translate all the 16 bit pointers in the __ParmMapR into
570 ** 32 bit pointers for the driver. 511 ** 32 bit pointers for the driver in ioremap space.
571 */ 512 */
572 HostP->ParmMapP = ParmMapP; 513 HostP->ParmMapP = ParmMapP;
573 HostP->PhbP = (PHB*)RIO_PTR(Cad,RWORD(ParmMapP->phb_ptr)); 514 HostP->PhbP = (struct PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
574 HostP->RupP = (RUP*)RIO_PTR(Cad,RWORD(ParmMapP->rups)); 515 HostP->RupP = (struct RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups));
575 HostP->PhbNumP = (ushort*)RIO_PTR(Cad,RWORD(ParmMapP->phb_num_ptr)); 516 HostP->PhbNumP = (unsigned short *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
576 HostP->LinkStrP = (LPB*)RIO_PTR(Cad,RWORD(ParmMapP->link_str_ptr)); 517 HostP->LinkStrP = (struct LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
577 518
578 /* 519 /*
579 ** point the UnixRups at the real Rups 520 ** point the UnixRups at the real Rups
580 */ 521 */
581 for ( RupN = 0; RupN<MAX_RUP; RupN++ ) { 522 for (RupN = 0; RupN < MAX_RUP; RupN++) {
582 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN]; 523 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
583 HostP->UnixRups[RupN].Id = RupN+1; 524 HostP->UnixRups[RupN].Id = RupN + 1;
584 HostP->UnixRups[RupN].BaseSysPort = NO_PORT; 525 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
585 spin_lock_init(&HostP->UnixRups[RupN].RupLock); 526 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
586 } 527 }
587 528
588 for ( RupN = 0; RupN<LINKS_PER_UNIT; RupN++ ) { 529 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
589 HostP->UnixRups[RupN+MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup; 530 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
590 HostP->UnixRups[RupN+MAX_RUP].Id = 0; 531 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
591 HostP->UnixRups[RupN+MAX_RUP].BaseSysPort = NO_PORT; 532 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
592 spin_lock_init(&HostP->UnixRups[RupN+MAX_RUP].RupLock); 533 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
593 } 534 }
594 535
595 /* 536 /*
596 ** point the PortP->Phbs at the real Phbs 537 ** point the PortP->Phbs at the real Phbs
597 */ 538 */
598 for ( PortN=p->RIOFirstPortsMapped; 539 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
599 PortN<p->RIOLastPortsMapped+PORTS_PER_RTA; PortN++ ) { 540 if (p->RIOPortp[PortN]->HostP == HostP) {
600 if ( p->RIOPortp[PortN]->HostP == HostP ) {
601 struct Port *PortP = p->RIOPortp[PortN]; 541 struct Port *PortP = p->RIOPortp[PortN];
602 struct PHB *PhbP; 542 struct PHB *PhbP;
603 /* int oldspl; */ 543 /* int oldspl; */
604 544
605 if ( !PortP->Mapped ) 545 if (!PortP->Mapped)
606 continue; 546 continue;
607 547
608 PhbP = &HostP->PhbP[PortP->HostPort]; 548 PhbP = &HostP->PhbP[PortP->HostPort];
@@ -610,641 +550,522 @@ register struct DownLoad *rbp;
610 550
611 PortP->PhbP = PhbP; 551 PortP->PhbP = PhbP;
612 552
613 PortP->TxAdd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_add)); 553 PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add));
614 PortP->TxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_start)); 554 PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start));
615 PortP->TxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_end)); 555 PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end));
616 PortP->RxRemove = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_remove)); 556 PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
617 PortP->RxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_start)); 557 PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start));
618 PortP->RxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_end)); 558 PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end));
619 559
620 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 560 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
621 /* 561 /*
622 ** point the UnixRup at the base SysPort 562 ** point the UnixRup at the base SysPort
623 */ 563 */
624 if ( !(PortN % PORTS_PER_RTA) ) 564 if (!(PortN % PORTS_PER_RTA))
625 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN; 565 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
626 } 566 }
627 } 567 }
628 568
629 rio_dprintk (RIO_DEBUG_BOOT, "Set the card running... \n"); 569 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
630 /* 570 /*
631 ** last thing - show the world that everything is in place 571 ** last thing - show the world that everything is in place
632 */ 572 */
633 HostP->Flags &= ~RUN_STATE; 573 HostP->Flags &= ~RUN_STATE;
634 HostP->Flags |= RC_RUNNING; 574 HostP->Flags |= RC_RUNNING;
635 } 575 }
636 /* 576 /*
637 ** MPX always uses a poller. This is actually patched into the system 577 ** MPX always uses a poller. This is actually patched into the system
638 ** configuration and called directly from each clock tick. 578 ** configuration and called directly from each clock tick.
639 ** 579 **
640 */ 580 */
641 p->RIOPolling = 1; 581 p->RIOPolling = 1;
642 582
643 p->RIOSystemUp++; 583 p->RIOSystemUp++;
644 584
645 rio_dprintk (RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec); 585 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
646 func_exit (); 586 func_exit();
647 return 0; 587 return 0;
648} 588}
649 589
650 590
651 591
652/* 592/**
653** Boot an RTA. If we have successfully processed this boot, then 593 * RIOBootRup - Boot an RTA
654** return 1. If we havent, then return 0. 594 * @p: rio we are working with
655*/ 595 * @Rup: Rup number
656int 596 * @HostP: host object
657RIOBootRup( p, Rup, HostP, PacketP) 597 * @PacketP: packet to use
658struct rio_info * p; 598 *
659uint Rup; 599 * If we have successfully processed this boot, then
660struct Host *HostP; 600 * return 1. If we havent, then return 0.
661struct PKT *PacketP; 601 */
602
603int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP)
662{ 604{
663 struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data; 605 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
664 struct PktCmd_M *PktReplyP; 606 struct PktCmd_M *PktReplyP;
665 struct CmdBlk *CmdBlkP; 607 struct CmdBlk *CmdBlkP;
666 uint sequence; 608 unsigned int sequence;
667 609
668 /* 610 /*
669 ** If we haven't been told what to boot, we can't boot it. 611 ** If we haven't been told what to boot, we can't boot it.
670 */ 612 */
671 if ( p->RIONumBootPkts == 0 ) { 613 if (p->RIONumBootPkts == 0) {
672 rio_dprintk (RIO_DEBUG_BOOT, "No RTA code to download yet\n"); 614 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
673 return 0; 615 return 0;
674 } 616 }
675 617
676 /* rio_dprint(RIO_DEBUG_BOOT, NULL,DBG_BOOT,"Incoming command packet\n"); */
677 /* ShowPacket( DBG_BOOT, PacketP ); */
678
679 /* 618 /*
680 ** Special case of boot completed - if we get one of these then we 619 ** Special case of boot completed - if we get one of these then we
681 ** don't need a command block. For all other cases we do, so handle 620 ** don't need a command block. For all other cases we do, so handle
682 ** this first and then get a command block, then handle every other 621 ** this first and then get a command block, then handle every other
683 ** case, relinquishing the command block if disaster strikes! 622 ** case, relinquishing the command block if disaster strikes!
684 */ 623 */
685 if ( (RBYTE(PacketP->len) & PKT_CMD_BIT) && 624 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
686 (RBYTE(PktCmdP->Command)==BOOT_COMPLETED) ) 625 return RIOBootComplete(p, HostP, Rup, PktCmdP);
687 return RIOBootComplete(p, HostP, Rup, PktCmdP );
688 626
689 /* 627 /*
690 ** try to unhook a command block from the command free list. 628 ** Try to allocate a command block. This is in kernel space
691 */ 629 */
692 if ( !(CmdBlkP = RIOGetCmdBlk()) ) { 630 if (!(CmdBlkP = RIOGetCmdBlk())) {
693 rio_dprintk (RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n"); 631 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
694 return 0; 632 return 0;
695 } 633 }
696 634
697 /* 635 /*
698 ** Fill in the default info on the command block 636 ** Fill in the default info on the command block
699 */ 637 */
700 CmdBlkP->Packet.dest_unit = Rup < (ushort)MAX_RUP ? Rup : 0; 638 CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0;
701 CmdBlkP->Packet.dest_port = BOOT_RUP; 639 CmdBlkP->Packet.dest_port = BOOT_RUP;
702 CmdBlkP->Packet.src_unit = 0; 640 CmdBlkP->Packet.src_unit = 0;
703 CmdBlkP->Packet.src_port = BOOT_RUP; 641 CmdBlkP->Packet.src_port = BOOT_RUP;
704 642
705 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL; 643 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
706 PktReplyP = (struct PktCmd_M *)CmdBlkP->Packet.data; 644 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
707 645
708 /* 646 /*
709 ** process COMMANDS on the boot rup! 647 ** process COMMANDS on the boot rup!
710 */ 648 */
711 if ( RBYTE(PacketP->len) & PKT_CMD_BIT ) { 649 if (readb(&PacketP->len) & PKT_CMD_BIT) {
712 /* 650 /*
713 ** We only expect one type of command - a BOOT_REQUEST! 651 ** We only expect one type of command - a BOOT_REQUEST!
714 */ 652 */
715 if ( RBYTE(PktCmdP->Command) != BOOT_REQUEST ) { 653 if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
716 rio_dprintk (RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %d\n", 654 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
717 PktCmdP->Command,Rup,HostP-p->RIOHosts); 655 RIOFreeCmdBlk(CmdBlkP);
718 ShowPacket( DBG_BOOT, PacketP );
719 RIOFreeCmdBlk( CmdBlkP );
720 return 1; 656 return 1;
721 } 657 }
722 658
723 /* 659 /*
724 ** Build a Boot Sequence command block 660 ** Build a Boot Sequence command block
725 ** 661 **
726 ** 02.03.1999 ARG - ESIL 0820 fix 662 ** We no longer need to use "Boot Mode", we'll always allow
727 ** We no longer need to use "Boot Mode", we'll always allow 663 ** boot requests - the boot will not complete if the device
728 ** boot requests - the boot will not complete if the device 664 ** appears in the bindings table.
729 ** appears in the bindings table. 665 **
730 ** So, this conditional is not required ... 666 ** We'll just (always) set the command field in packet reply
731 ** 667 ** to allow an attempted boot sequence :
732 if (p->RIOBootMode == RC_BOOT_NONE) 668 */
733 **
734 ** If the system is in slave mode, and a boot request is
735 ** received, set command to BOOT_ABORT so that the boot
736 ** will not complete.
737 **
738 PktReplyP->Command = BOOT_ABORT;
739 else
740 **
741 ** We'll just (always) set the command field in packet reply
742 ** to allow an attempted boot sequence :
743 */
744 PktReplyP->Command = BOOT_SEQUENCE; 669 PktReplyP->Command = BOOT_SEQUENCE;
745 670
746 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts; 671 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
747 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase; 672 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
748 PktReplyP->BootSequence.CodeSize = p->RIOBootCount; 673 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
749 674
750 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT; 675 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
751 676
752 bcopy("BOOT",(void *)&CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN],4); 677 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
753 678
754 rio_dprintk (RIO_DEBUG_BOOT, "Boot RTA on Host %d Rup %d - %d (0x%x) packets to 0x%x\n", 679 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);
755 HostP-p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts,
756 p->RIOConf.RtaLoadBase);
757 680
758 /* 681 /*
759 ** If this host is in slave mode, send the RTA an invalid boot 682 ** If this host is in slave mode, send the RTA an invalid boot
760 ** sequence command block to force it to kill the boot. We wait 683 ** sequence command block to force it to kill the boot. We wait
761 ** for half a second before sending this packet to prevent the RTA 684 ** for half a second before sending this packet to prevent the RTA
762 ** attempting to boot too often. The master host should then grab 685 ** attempting to boot too often. The master host should then grab
763 ** the RTA and make it its own. 686 ** the RTA and make it its own.
764 */ 687 */
765 p->RIOBooting++; 688 p->RIOBooting++;
766 RIOQueueCmdBlk( HostP, Rup, CmdBlkP ); 689 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
767 return 1; 690 return 1;
768 } 691 }
769 692
770 /* 693 /*
771 ** It is a request for boot data. 694 ** It is a request for boot data.
772 */ 695 */
773 sequence = RWORD(PktCmdP->Sequence); 696 sequence = readw(&PktCmdP->Sequence);
774 697
775 rio_dprintk (RIO_DEBUG_BOOT, "Boot block %d on Host %d Rup%d\n",sequence,HostP-p->RIOHosts,Rup); 698 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
776 699
777 if ( sequence >= p->RIONumBootPkts ) { 700 if (sequence >= p->RIONumBootPkts) {
778 rio_dprintk (RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, 701 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
779 p->RIONumBootPkts);
780 ShowPacket( DBG_BOOT, PacketP );
781 } 702 }
782 703
783 PktReplyP->Sequence = sequence; 704 PktReplyP->Sequence = sequence;
784 705 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
785 bcopy( p->RIOBootPackets[ p->RIONumBootPkts - sequence - 1 ],
786 PktReplyP->BootData, RTA_BOOT_DATA_SIZE );
787
788 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN; 706 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
789 ShowPacket( DBG_BOOT, &CmdBlkP->Packet ); 707 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
790 RIOQueueCmdBlk( HostP, Rup, CmdBlkP );
791 return 1; 708 return 1;
792} 709}
793 710
794/* 711/**
795** This function is called when an RTA been booted. 712 * RIOBootComplete - RTA boot is done
796** If booted by a host, HostP->HostUniqueNum is the booting host. 713 * @p: RIO we are working with
797** If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA. 714 * @HostP: Host structure
798** RtaUniq is the booted RTA. 715 * @Rup: RUP being used
799*/ 716 * @PktCmdP: Packet command that was used
800static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP ) 717 *
718 * This function is called when an RTA been booted.
719 * If booted by a host, HostP->HostUniqueNum is the booting host.
720 * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
721 * RtaUniq is the booted RTA.
722 */
723
724static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP)
801{ 725{
802 struct Map *MapP = NULL; 726 struct Map *MapP = NULL;
803 struct Map *MapP2 = NULL; 727 struct Map *MapP2 = NULL;
804 int Flag; 728 int Flag;
805 int found; 729 int found;
806 int host, rta; 730 int host, rta;
807 int EmptySlot = -1; 731 int EmptySlot = -1;
808 int entry, entry2; 732 int entry, entry2;
809 char *MyType, *MyName; 733 char *MyType, *MyName;
810 uint MyLink; 734 unsigned int MyLink;
811 ushort RtaType; 735 unsigned short RtaType;
812 uint RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + 736 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
813 (RBYTE(PktCmdP->UniqNum[1]) << 8) + 737
814 (RBYTE(PktCmdP->UniqNum[2]) << 16) +
815 (RBYTE(PktCmdP->UniqNum[3]) << 24);
816
817 /* Was RIOBooting-- . That's bad. If an RTA sends two of them, the
818 driver will never think that the RTA has booted... -- REW */
819 p->RIOBooting = 0; 738 p->RIOBooting = 0;
820 739
821 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting); 740 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
822 741
823 /* 742 /*
824 ** Determine type of unit (16/8 port RTA). 743 ** Determine type of unit (16/8 port RTA).
825 */ 744 */
745
826 RtaType = GetUnitType(RtaUniq); 746 RtaType = GetUnitType(RtaUniq);
827 if ( Rup >= (ushort)MAX_RUP ) { 747 if (Rup >= (unsigned short) MAX_RUP)
828 rio_dprintk (RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", 748 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');
829 HostP->Name, 8 * RtaType, RBYTE(PktCmdP->LinkNum)+'A'); 749 else
830 } else { 750 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');
831 rio_dprintk (RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n",
832 HostP->Mapping[Rup].Name, 8 * RtaType,
833 RBYTE(PktCmdP->LinkNum)+'A');
834 }
835 751
836 rio_dprintk (RIO_DEBUG_BOOT, "UniqNum is 0x%x\n",RtaUniq); 752 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
837 753
838 if ( ( RtaUniq == 0x00000000 ) || ( RtaUniq == 0xffffffff ) ) 754 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
839 { 755 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
840 rio_dprintk (RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n"); 756 return 1;
841 return TRUE;
842 } 757 }
843 758
844 /* 759 /*
845 ** If this RTA has just booted an RTA which doesn't belong to this 760 ** If this RTA has just booted an RTA which doesn't belong to this
846 ** system, or the system is in slave mode, do not attempt to create 761 ** system, or the system is in slave mode, do not attempt to create
847 ** a new table entry for it. 762 ** a new table entry for it.
848 */ 763 */
849 if (!RIOBootOk(p, HostP, RtaUniq)) 764
850 { 765 if (!RIOBootOk(p, HostP, RtaUniq)) {
851 MyLink = RBYTE(PktCmdP->LinkNum); 766 MyLink = readb(&PktCmdP->LinkNum);
852 if (Rup < (ushort) MAX_RUP) 767 if (Rup < (unsigned short) MAX_RUP) {
853 { 768 /*
854 /* 769 ** RtaUniq was clone booted (by this RTA). Instruct this RTA
855 ** RtaUniq was clone booted (by this RTA). Instruct this RTA 770 ** to hold off further attempts to boot on this link for 30
856 ** to hold off further attempts to boot on this link for 30 771 ** seconds.
857 ** seconds. 772 */
858 */ 773 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
859 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) 774 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
860 { 775 }
861 rio_dprintk (RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 776 } else
862 'A' + MyLink); 777 /*
863 } 778 ** RtaUniq was booted by this host. Set the booting link
864 } 779 ** to hold off for 30 seconds to give another unit a
865 else 780 ** chance to boot it.
866 { 781 */
867 /* 782 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
868 ** RtaUniq was booted by this host. Set the booting link 783 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);
869 ** to hold off for 30 seconds to give another unit a 784 return 1;
870 ** chance to boot it.
871 */
872 WWORD(HostP->LinkStrP[MyLink].WaitNoBoot, 30);
873 }
874 rio_dprintk (RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n",
875 RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
876 return TRUE;
877 } 785 }
878 786
879 /* 787 /*
880 ** Check for a SLOT_IN_USE entry for this RTA attached to the 788 ** Check for a SLOT_IN_USE entry for this RTA attached to the
881 ** current host card in the driver table. 789 ** current host card in the driver table.
882 ** 790 **
883 ** If it exists, make a note that we have booted it. Other parts of 791 ** If it exists, make a note that we have booted it. Other parts of
884 ** the driver are interested in this information at a later date, 792 ** the driver are interested in this information at a later date,
885 ** in particular when the booting RTA asks for an ID for this unit, 793 ** in particular when the booting RTA asks for an ID for this unit,
886 ** we must have set the BOOTED flag, and the NEWBOOT flag is used 794 ** we must have set the BOOTED flag, and the NEWBOOT flag is used
887 ** to force an open on any ports that where previously open on this 795 ** to force an open on any ports that where previously open on this
888 ** unit. 796 ** unit.
889 */ 797 */
890 for ( entry=0; entry<MAX_RUP; entry++ ) 798 for (entry = 0; entry < MAX_RUP; entry++) {
891 { 799 unsigned int sysport;
892 uint sysport; 800
893 801 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
894 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && 802 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
895 (HostP->Mapping[entry].RtaUniqueNum==RtaUniq)) 803 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
896 { 804 if (sysport < p->RIOFirstPortsBooted)
897 HostP->Mapping[entry].Flags |= RTA_BOOTED|RTA_NEWBOOT; 805 p->RIOFirstPortsBooted = sysport;
898#ifdef NEED_TO_FIX 806 if (sysport > p->RIOLastPortsBooted)
899 RIO_SV_BROADCAST(HostP->svFlags[entry]); 807 p->RIOLastPortsBooted = sysport;
900#endif 808 /*
901 if ( (sysport=HostP->Mapping[entry].SysPort) != NO_PORT ) 809 ** For a 16 port RTA, check the second bank of 8 ports
902 { 810 */
903 if ( sysport < p->RIOFirstPortsBooted ) 811 if (RtaType == TYPE_RTA16) {
904 p->RIOFirstPortsBooted = sysport; 812 entry2 = HostP->Mapping[entry].ID2 - 1;
905 if ( sysport > p->RIOLastPortsBooted ) 813 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
906 p->RIOLastPortsBooted = sysport; 814 sysport = HostP->Mapping[entry2].SysPort;
907 /* 815 if (sysport < p->RIOFirstPortsBooted)
908 ** For a 16 port RTA, check the second bank of 8 ports 816 p->RIOFirstPortsBooted = sysport;
909 */ 817 if (sysport > p->RIOLastPortsBooted)
910 if (RtaType == TYPE_RTA16) 818 p->RIOLastPortsBooted = sysport;
911 { 819 }
912 entry2 = HostP->Mapping[entry].ID2 - 1; 820 }
913 HostP->Mapping[entry2].Flags |= RTA_BOOTED|RTA_NEWBOOT; 821 if (RtaType == TYPE_RTA16)
914#ifdef NEED_TO_FIX 822 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
915 RIO_SV_BROADCAST(HostP->svFlags[entry2]); 823 else
916#endif 824 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
917 sysport = HostP->Mapping[entry2].SysPort; 825 return 1;
918 if ( sysport < p->RIOFirstPortsBooted )
919 p->RIOFirstPortsBooted = sysport;
920 if ( sysport > p->RIOLastPortsBooted )
921 p->RIOLastPortsBooted = sysport;
922 }
923 }
924 if (RtaType == TYPE_RTA16) {
925 rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n",
926 entry+1, entry2+1);
927 } else {
928 rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given ID %d\n",entry+1);
929 } 826 }
930 return TRUE;
931 }
932 } 827 }
933 828
934 rio_dprintk (RIO_DEBUG_BOOT, "RTA not configured for this host\n"); 829 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
935 830
936 if ( Rup >= (ushort)MAX_RUP ) 831 if (Rup >= (unsigned short) MAX_RUP) {
937 { 832 /*
938 /* 833 ** It was a host that did the booting
939 ** It was a host that did the booting 834 */
940 */ 835 MyType = "Host";
941 MyType = "Host"; 836 MyName = HostP->Name;
942 MyName = HostP->Name; 837 } else {
943 } 838 /*
944 else 839 ** It was an RTA that did the booting
945 { 840 */
946 /* 841 MyType = "RTA";
947 ** It was an RTA that did the booting 842 MyName = HostP->Mapping[Rup].Name;
948 */
949 MyType = "RTA";
950 MyName = HostP->Mapping[Rup].Name;
951 } 843 }
952 MyLink = RBYTE(PktCmdP->LinkNum); 844 MyLink = readb(&PktCmdP->LinkNum);
953 845
954 /* 846 /*
955 ** There is no SLOT_IN_USE entry for this RTA attached to the current 847 ** There is no SLOT_IN_USE entry for this RTA attached to the current
956 ** host card in the driver table. 848 ** host card in the driver table.
957 ** 849 **
958 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the 850 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
959 ** current host card in the driver table. 851 ** current host card in the driver table.
960 ** 852 **
961 ** If we find one, then we re-use that slot. 853 ** If we find one, then we re-use that slot.
962 */ 854 */
963 for ( entry=0; entry<MAX_RUP; entry++ ) 855 for (entry = 0; entry < MAX_RUP; entry++) {
964 { 856 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
965 if ( (HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && 857 if (RtaType == TYPE_RTA16) {
966 (HostP->Mapping[entry].RtaUniqueNum == RtaUniq) ) 858 entry2 = HostP->Mapping[entry].ID2 - 1;
967 { 859 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
968 if (RtaType == TYPE_RTA16) 860 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
969 { 861 else
970 entry2 = HostP->Mapping[entry].ID2 - 1; 862 continue;
971 if ( (HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && 863 } else
972 (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq) ) 864 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
973 rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", 865 if (!p->RIONoMessage)
974 entry, entry2); 866 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
975 else 867 return 1;
976 continue;
977 } 868 }
978 else
979 rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n",entry);
980 if (! p->RIONoMessage)
981 cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
982 return TRUE;
983 }
984 } 869 }
985 870
986 /* 871 /*
987 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 872 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
988 ** attached to the current host card in the driver table. 873 ** attached to the current host card in the driver table.
989 ** 874 **
990 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another 875 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
991 ** host for this RTA in the driver table. 876 ** host for this RTA in the driver table.
992 ** 877 **
993 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA 878 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
994 ** entry from the other host and add it to this host (using some of 879 ** entry from the other host and add it to this host (using some of
995 ** the functions from table.c which do this). 880 ** the functions from table.c which do this).
996 ** For a SLOT_TENTATIVE entry on another host, we must cope with the 881 ** For a SLOT_TENTATIVE entry on another host, we must cope with the
997 ** following scenario: 882 ** following scenario:
998 ** 883 **
999 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry 884 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
1000 ** in table) 885 ** in table)
1001 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE 886 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
1002 ** entries) 887 ** entries)
1003 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) 888 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
1004 ** + Unplug RTA and plug back into host A. 889 ** + Unplug RTA and plug back into host A.
1005 ** + Configure RTA on host A. We now have the same RTA configured 890 ** + Configure RTA on host A. We now have the same RTA configured
1006 ** with different ports on two different hosts. 891 ** with different ports on two different hosts.
1007 */ 892 */
1008 rio_dprintk (RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq ); 893 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
1009 found = 0; 894 found = 0;
1010 Flag = 0; /* Convince the compiler this variable is initialized */ 895 Flag = 0; /* Convince the compiler this variable is initialized */
1011 for ( host = 0; !found && (host < p->RIONumHosts); host++ ) 896 for (host = 0; !found && (host < p->RIONumHosts); host++) {
1012 { 897 for (rta = 0; rta < MAX_RUP; rta++) {
1013 for ( rta=0; rta<MAX_RUP; rta++ ) 898 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
1014 { 899 Flag = p->RIOHosts[host].Mapping[rta].Flags;
1015 if ((p->RIOHosts[host].Mapping[rta].Flags & 900 MapP = &p->RIOHosts[host].Mapping[rta];
1016 (SLOT_IN_USE | SLOT_TENTATIVE)) && 901 if (RtaType == TYPE_RTA16) {
1017 (p->RIOHosts[host].Mapping[rta].RtaUniqueNum==RtaUniq)) 902 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
1018 { 903 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
1019 Flag = p->RIOHosts[host].Mapping[rta].Flags; 904 } else
1020 MapP = &p->RIOHosts[host].Mapping[rta]; 905 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
1021 if (RtaType == TYPE_RTA16) 906 found = 1;
1022 { 907 break;
1023 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; 908 }
1024 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n",
1025 rta+1, MapP->ID2, p->RIOHosts[host].Name);
1026 }
1027 else
1028 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n",
1029 rta+1, p->RIOHosts[host].Name);
1030 found = 1;
1031 break;
1032 } 909 }
1033 }
1034 } 910 }
1035 911
1036 /* 912 /*
1037 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 913 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1038 ** attached to the current host card in the driver table. 914 ** attached to the current host card in the driver table.
1039 ** 915 **
1040 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on 916 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
1041 ** another host for this RTA in the driver table... 917 ** another host for this RTA in the driver table...
1042 ** 918 **
1043 ** Check for a SLOT_IN_USE entry for this RTA in the config table. 919 ** Check for a SLOT_IN_USE entry for this RTA in the config table.
1044 */ 920 */
1045 if ( !MapP ) 921 if (!MapP) {
1046 { 922 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
1047 rio_dprintk (RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n",RtaUniq); 923 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
1048 for ( rta=0; rta < TOTAL_MAP_ENTRIES; rta++ ) 924 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
1049 { 925
1050 rio_dprintk (RIO_DEBUG_BOOT, "Check table entry %d (%x)", 926 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
1051 rta, 927 MapP = &p->RIOSavedTable[rta];
1052 p->RIOSavedTable[rta].RtaUniqueNum); 928 Flag = p->RIOSavedTable[rta].Flags;
1053 929 if (RtaType == TYPE_RTA16) {
1054 if ( (p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && 930 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
1055 (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq) ) 931 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
1056 { 932 break;
1057 MapP = &p->RIOSavedTable[rta]; 933 }
1058 Flag = p->RIOSavedTable[rta].Flags; 934 MapP2 = &p->RIOSavedTable[entry2];
1059 if (RtaType == TYPE_RTA16) 935 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
1060 { 936 } else
1061 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; 937 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
1062 entry2++) 938 break;
1063 { 939 }
1064 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
1065 break;
1066 }
1067 MapP2 = &p->RIOSavedTable[entry2];
1068 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n",
1069 rta, entry2);
1070 }
1071 else
1072 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
1073 break;
1074 } 940 }
1075 }
1076 } 941 }
1077 942
1078 /* 943 /*
1079 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 944 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1080 ** attached to the current host card in the driver table. 945 ** attached to the current host card in the driver table.
1081 ** 946 **
1082 ** We may have found a SLOT_IN_USE entry on another host for this 947 ** We may have found a SLOT_IN_USE entry on another host for this
1083 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry 948 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
1084 ** on another host for this RTA in the driver table. 949 ** on another host for this RTA in the driver table.
1085 ** 950 **
1086 ** Check the driver table for room to fit this newly discovered RTA. 951 ** Check the driver table for room to fit this newly discovered RTA.
1087 ** RIOFindFreeID() first looks for free slots and if it does not 952 ** RIOFindFreeID() first looks for free slots and if it does not
1088 ** find any free slots it will then attempt to oust any 953 ** find any free slots it will then attempt to oust any
1089 ** tentative entry in the table. 954 ** tentative entry in the table.
1090 */ 955 */
1091 EmptySlot = 1; 956 EmptySlot = 1;
1092 if (RtaType == TYPE_RTA16) 957 if (RtaType == TYPE_RTA16) {
1093 { 958 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
1094 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) 959 RIODefaultName(p, HostP, entry);
1095 { 960 rio_fill_host_slot(entry, entry2, RtaUniq, HostP);
1096 RIODefaultName(p, HostP, entry); 961 EmptySlot = 0;
1097 FillSlot(entry, entry2, RtaUniq, HostP); 962 }
1098 EmptySlot = 0; 963 } else {
1099 } 964 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
1100 } 965 RIODefaultName(p, HostP, entry);
1101 else 966 rio_fill_host_slot(entry, 0, RtaUniq, HostP);
1102 { 967 EmptySlot = 0;
1103 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) 968 }
1104 {
1105 RIODefaultName(p, HostP, entry);
1106 FillSlot(entry, 0, RtaUniq, HostP);
1107 EmptySlot = 0;
1108 }
1109 } 969 }
1110 970
1111 /* 971 /*
1112 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 972 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1113 ** attached to the current host card in the driver table. 973 ** attached to the current host card in the driver table.
1114 ** 974 **
1115 ** If we found a SLOT_IN_USE entry on another host for this 975 ** If we found a SLOT_IN_USE entry on another host for this
1116 ** RTA in the config or driver table, and there are enough free 976 ** RTA in the config or driver table, and there are enough free
1117 ** slots in the driver table, then we need to move it over and 977 ** slots in the driver table, then we need to move it over and
1118 ** delete it from the other host. 978 ** delete it from the other host.
1119 ** If we found a SLOT_TENTATIVE entry on another host for this 979 ** If we found a SLOT_TENTATIVE entry on another host for this
1120 ** RTA in the driver table, just delete the other host entry. 980 ** RTA in the driver table, just delete the other host entry.
1121 */ 981 */
1122 if (EmptySlot == 0) 982 if (EmptySlot == 0) {
1123 { 983 if (MapP) {
1124 if ( MapP ) 984 if (Flag & SLOT_IN_USE) {
1125 { 985 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
1126 if (Flag & SLOT_IN_USE) 986 HostP->Mapping[entry].SysPort = MapP->SysPort;
1127 { 987 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
1128 rio_dprintk (RIO_DEBUG_BOOT, 988 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
1129 "This RTA configured on another host - move entry to current host (1)\n"); 989 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
1130 HostP->Mapping[entry].SysPort = MapP->SysPort; 990 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
1131 CCOPY( MapP->Name, HostP->Mapping[entry].Name, MAX_NAME_LEN ); 991 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
1132 HostP->Mapping[entry].Flags = 992 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
1133 SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT; 993 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
1134#ifdef NEED_TO_FIX 994 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
1135 RIO_SV_BROADCAST(HostP->svFlags[entry]); 995 } else {
1136#endif 996 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
1137 RIOReMapPorts( p, HostP, &HostP->Mapping[entry] ); 997 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
1138 if ( HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted ) 998 }
1139 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; 999 if (RtaType == TYPE_RTA16) {
1140 if ( HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted ) 1000 if (Flag & SLOT_IN_USE) {
1141 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; 1001 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1142 rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",(int)MapP->SysPort,MapP->Name); 1002 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1143 } 1003 /*
1144 else 1004 ** Map second block of ttys for 16 port RTA
1145 { 1005 */
1146 rio_dprintk (RIO_DEBUG_BOOT, 1006 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1147 "This RTA has a tentative entry on another host - delete that entry (1)\n"); 1007 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1148 HostP->Mapping[entry].Flags = 1008 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1149 SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT; 1009 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1150#ifdef NEED_TO_FIX 1010 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1151 RIO_SV_BROADCAST(HostP->svFlags[entry]); 1011 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1152#endif 1012 } else
1153 } 1013 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1154 if (RtaType == TYPE_RTA16) 1014 memset(MapP2, 0, sizeof(struct Map));
1155 { 1015 }
1156 if (Flag & SLOT_IN_USE) 1016 memset(MapP, 0, sizeof(struct Map));
1157 { 1017 if (!p->RIONoMessage)
1158 HostP->Mapping[entry2].Flags = SLOT_IN_USE | 1018 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
1159 RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; 1019 } else if (!p->RIONoMessage)
1160#ifdef NEED_TO_FIX 1020 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
1161 RIO_SV_BROADCAST(HostP->svFlags[entry2]); 1021 RIOSetChange(p);
1162#endif 1022 return 1;
1163 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1164 /*
1165 ** Map second block of ttys for 16 port RTA
1166 */
1167 RIOReMapPorts( p, HostP, &HostP->Mapping[entry2] );
1168 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1169 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1170 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1171 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1172 rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",
1173 (int)HostP->Mapping[entry2].SysPort,
1174 HostP->Mapping[entry].Name);
1175 }
1176 else
1177 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE |
1178 RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1179#ifdef NEED_TO_FIX
1180 RIO_SV_BROADCAST(HostP->svFlags[entry2]);
1181#endif
1182 bzero( (caddr_t)MapP2, sizeof(struct Map) );
1183 }
1184 bzero( (caddr_t)MapP, sizeof(struct Map) );
1185 if (! p->RIONoMessage)
1186 cprintf("An orphaned RTA has been adopted by %s '%s' (%c).\n",MyType,MyName,MyLink+'A');
1187 }
1188 else if (! p->RIONoMessage)
1189 cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
1190 RIOSetChange(p);
1191 return TRUE;
1192 } 1023 }
1193 1024
1194 /* 1025 /*
1195 ** There is no room in the driver table to make an entry for the 1026 ** There is no room in the driver table to make an entry for the
1196 ** booted RTA. Keep a note of its Uniq Num in the overflow table, 1027 ** booted RTA. Keep a note of its Uniq Num in the overflow table,
1197 ** so we can ignore it's ID requests. 1028 ** so we can ignore it's ID requests.
1198 */ 1029 */
1199 if (! p->RIONoMessage) 1030 if (!p->RIONoMessage)
1200 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'); 1031 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');
1201 for ( entry=0; entry<HostP->NumExtraBooted; entry++ ) 1032 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1202 { 1033 if (HostP->ExtraUnits[entry] == RtaUniq) {
1203 if ( HostP->ExtraUnits[entry] == RtaUniq ) 1034 /*
1204 { 1035 ** already got it!
1205 /* 1036 */
1206 ** already got it! 1037 return 1;
1207 */ 1038 }
1208 return TRUE;
1209 }
1210 } 1039 }
1211 /* 1040 /*
1212 ** If there is room, add the unit to the list of extras 1041 ** If there is room, add the unit to the list of extras
1213 */ 1042 */
1214 if ( HostP->NumExtraBooted < MAX_EXTRA_UNITS ) 1043 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1215 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; 1044 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
1216 return TRUE; 1045 return 1;
1217} 1046}
1218 1047
1219 1048
1220/* 1049/*
1221** If the RTA or its host appears in the RIOBindTab[] structure then 1050** If the RTA or its host appears in the RIOBindTab[] structure then
1222** we mustn't boot the RTA and should return FALSE. 1051** we mustn't boot the RTA and should return 0.
1223** This operation is slightly different from the other drivers for RIO 1052** This operation is slightly different from the other drivers for RIO
1224** in that this is designed to work with the new utilities 1053** in that this is designed to work with the new utilities
1225** not config.rio and is FAR SIMPLER. 1054** not config.rio and is FAR SIMPLER.
1226** We no longer support the RIOBootMode variable. It is all done from the 1055** We no longer support the RIOBootMode variable. It is all done from the
1227** "boot/noboot" field in the rio.cf file. 1056** "boot/noboot" field in the rio.cf file.
1228*/ 1057*/
1229int 1058int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
1230RIOBootOk(p, HostP, RtaUniq)
1231struct rio_info * p;
1232struct Host * HostP;
1233ulong RtaUniq;
1234{ 1059{
1235 int Entry; 1060 int Entry;
1236 uint HostUniq = HostP->UniqueNum; 1061 unsigned int HostUniq = HostP->UniqueNum;
1237 1062
1238 /* 1063 /*
1239 ** Search bindings table for RTA or its parent. 1064 ** Search bindings table for RTA or its parent.
1240 ** If it exists, return 0, else 1. 1065 ** If it exists, return 0, else 1.
1241 */ 1066 */
1242 for (Entry = 0; 1067 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1243 ( Entry < MAX_RTA_BINDINGS ) && ( p->RIOBindTab[Entry] != 0 ); 1068 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
1244 Entry++)
1245 {
1246 if ( (p->RIOBindTab[Entry] == HostUniq) ||
1247 (p->RIOBindTab[Entry] == RtaUniq) )
1248 return 0; 1069 return 0;
1249 } 1070 }
1250 return 1; 1071 return 1;
@@ -1255,45 +1076,38 @@ ulong RtaUniq;
1255** slots tentative, and the second one RTA_SECOND_SLOT as well. 1076** slots tentative, and the second one RTA_SECOND_SLOT as well.
1256*/ 1077*/
1257 1078
1258void 1079void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host)
1259FillSlot(entry, entry2, RtaUniq, HostP)
1260int entry;
1261int entry2;
1262uint RtaUniq;
1263struct Host *HostP;
1264{ 1080{
1265 int link; 1081 int link;
1266 1082
1267 rio_dprintk (RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq); 1083 rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq);
1268 1084
1269 HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); 1085 host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1270 HostP->Mapping[entry].SysPort = NO_PORT; 1086 host->Mapping[entry].SysPort = NO_PORT;
1271 HostP->Mapping[entry].RtaUniqueNum = RtaUniq; 1087 host->Mapping[entry].RtaUniqueNum = rta_uniq;
1272 HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum; 1088 host->Mapping[entry].HostUniqueNum = host->UniqueNum;
1273 HostP->Mapping[entry].ID = entry + 1; 1089 host->Mapping[entry].ID = entry + 1;
1274 HostP->Mapping[entry].ID2 = 0; 1090 host->Mapping[entry].ID2 = 0;
1275 if (entry2) { 1091 if (entry2) {
1276 HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | 1092 host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
1277 SLOT_TENTATIVE | RTA16_SECOND_SLOT); 1093 host->Mapping[entry2].SysPort = NO_PORT;
1278 HostP->Mapping[entry2].SysPort = NO_PORT; 1094 host->Mapping[entry2].RtaUniqueNum = rta_uniq;
1279 HostP->Mapping[entry2].RtaUniqueNum = RtaUniq; 1095 host->Mapping[entry2].HostUniqueNum = host->UniqueNum;
1280 HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum; 1096 host->Mapping[entry2].Name[0] = '\0';
1281 HostP->Mapping[entry2].Name[0] = '\0'; 1097 host->Mapping[entry2].ID = entry2 + 1;
1282 HostP->Mapping[entry2].ID = entry2 + 1; 1098 host->Mapping[entry2].ID2 = entry + 1;
1283 HostP->Mapping[entry2].ID2 = entry + 1; 1099 host->Mapping[entry].ID2 = entry2 + 1;
1284 HostP->Mapping[entry].ID2 = entry2 + 1;
1285 } 1100 }
1286 /* 1101 /*
1287 ** Must set these up, so that utilities show 1102 ** Must set these up, so that utilities show
1288 ** topology of 16 port RTAs correctly 1103 ** topology of 16 port RTAs correctly
1289 */ 1104 */
1290 for ( link=0; link<LINKS_PER_UNIT; link++ ) { 1105 for (link = 0; link < LINKS_PER_UNIT; link++) {
1291 HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; 1106 host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1292 HostP->Mapping[entry].Topology[link].Link = NO_LINK; 1107 host->Mapping[entry].Topology[link].Link = NO_LINK;
1293 if (entry2) { 1108 if (entry2) {
1294 HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; 1109 host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1295 HostP->Mapping[entry2].Topology[link].Link = NO_LINK; 1110 host->Mapping[entry2].Topology[link].Link = NO_LINK;
1296 } 1111 }
1297 } 1112 }
1298} 1113}
1299
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 694bfb9d9378..e6d2b14b5e65 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";
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h> 44#include <asm/semaphore.h>
45#include <asm/uaccess.h>
45 46
46#include <linux/termios.h> 47#include <linux/termios.h>
47#include <linux/serial.h> 48#include <linux/serial.h>
@@ -50,15 +51,12 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
50 51
51#include "linux_compat.h" 52#include "linux_compat.h"
52#include "rio_linux.h" 53#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 54#include "pkt.h"
55#include "daemon.h" 55#include "daemon.h"
56#include "rio.h" 56#include "rio.h"
57#include "riospace.h" 57#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 58#include "cmdpkt.h"
60#include "map.h" 59#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 60#include "rup.h"
63#include "port.h" 61#include "port.h"
64#include "riodrvr.h" 62#include "riodrvr.h"
@@ -71,12 +69,10 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
71#include "unixrup.h" 69#include "unixrup.h"
72#include "board.h" 70#include "board.h"
73#include "host.h" 71#include "host.h"
74#include "error.h"
75#include "phb.h" 72#include "phb.h"
76#include "link.h" 73#include "link.h"
77#include "cmdblk.h" 74#include "cmdblk.h"
78#include "route.h" 75#include "route.h"
79#include "control.h"
80#include "cirrus.h" 76#include "cirrus.h"
81 77
82 78
@@ -143,17 +139,17 @@ int RIOZombieRta(struct Host *HostP, struct Map *MapP)
143 return 0; 139 return 0;
144} 140}
145 141
146int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP)) 142int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
147{ 143{
148 uint Host; 144 unsigned int Host;
149 145
150 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int) func); 146 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
151 147
152 if (!RtaUnique) 148 if (!RtaUnique)
153 return (0); 149 return (0);
154 150
155 for (Host = 0; Host < p->RIONumHosts; Host++) { 151 for (Host = 0; Host < p->RIONumHosts; Host++) {
156 uint Rta; 152 unsigned int Rta;
157 struct Host *HostP = &p->RIOHosts[Host]; 153 struct Host *HostP = &p->RIOHosts[Host];
158 154
159 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 155 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -170,7 +166,7 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
170 ** any connections, we can get to it. 166 ** any connections, we can get to it.
171 */ 167 */
172 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 168 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
173 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 169 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
174 /* 170 /*
175 ** Its worth trying the operation... 171 ** Its worth trying the operation...
176 */ 172 */
@@ -184,18 +180,18 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
184} 180}
185 181
186 182
187int RIOIdentifyRta(struct rio_info *p, caddr_t arg) 183int RIOIdentifyRta(struct rio_info *p, void * arg)
188{ 184{
189 uint Host; 185 unsigned int Host;
190 186
191 if (copyin((int) arg, (caddr_t) & IdRta, sizeof(IdRta)) == COPYFAIL) { 187 if (copy_from_user(&IdRta, arg, sizeof(IdRta))) {
192 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n"); 188 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
193 p->RIOError.Error = COPYIN_FAILED; 189 p->RIOError.Error = COPYIN_FAILED;
194 return -EFAULT; 190 return -EFAULT;
195 } 191 }
196 192
197 for (Host = 0; Host < p->RIONumHosts; Host++) { 193 for (Host = 0; Host < p->RIONumHosts; Host++) {
198 uint Rta; 194 unsigned int Rta;
199 struct Host *HostP = &p->RIOHosts[Host]; 195 struct Host *HostP = &p->RIOHosts[Host];
200 196
201 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 197 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -211,7 +207,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
211 ** any connections, we can get to it. 207 ** any connections, we can get to it.
212 */ 208 */
213 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 209 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
214 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 210 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
215 /* 211 /*
216 ** Its worth trying the operation... 212 ** Its worth trying the operation...
217 */ 213 */
@@ -249,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
249} 245}
250 246
251 247
252int RIOKillNeighbour(struct rio_info *p, caddr_t arg) 248int RIOKillNeighbour(struct rio_info *p, void * arg)
253{ 249{
254 uint Host; 250 uint Host;
255 uint ID; 251 uint ID;
@@ -258,7 +254,7 @@ int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
258 254
259 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n"); 255 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
260 256
261 if (copyin((int) arg, (caddr_t) & KillUnit, sizeof(KillUnit)) == COPYFAIL) { 257 if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) {
262 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n"); 258 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
263 p->RIOError.Error = COPYIN_FAILED; 259 p->RIOError.Error = COPYIN_FAILED;
264 return -EFAULT; 260 return -EFAULT;
@@ -344,7 +340,7 @@ int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
344int RIOFoadWakeup(struct rio_info *p) 340int RIOFoadWakeup(struct rio_info *p)
345{ 341{
346 int port; 342 int port;
347 register struct Port *PortP; 343 struct Port *PortP;
348 unsigned long flags; 344 unsigned long flags;
349 345
350 for (port = 0; port < RIO_PORTS; port++) { 346 for (port = 0; port < RIO_PORTS; port++) {
@@ -374,15 +370,15 @@ int RIOFoadWakeup(struct rio_info *p)
374/* 370/*
375** Incoming command on the COMMAND_RUP to be processed. 371** Incoming command on the COMMAND_RUP to be processed.
376*/ 372*/
377static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 373static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP)
378{ 374{
379 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 375 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
380 struct Port *PortP; 376 struct Port *PortP;
381 struct UnixRup *UnixRupP; 377 struct UnixRup *UnixRupP;
382 ushort SysPort; 378 unsigned short SysPort;
383 ushort ReportedModemStatus; 379 unsigned short ReportedModemStatus;
384 ushort rup; 380 unsigned short rup;
385 ushort subCommand; 381 unsigned short subCommand;
386 unsigned long flags; 382 unsigned long flags;
387 383
388 func_enter(); 384 func_enter();
@@ -395,18 +391,18 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
395 ** we can use PhbNum to get the rup number for the appropriate 8 port 391 ** we can use PhbNum to get the rup number for the appropriate 8 port
396 ** block (for the first block, this should be equal to 'Rup'). 392 ** block (for the first block, this should be equal to 'Rup').
397 */ 393 */
398 rup = RBYTE(PktCmdP->PhbNum) / (ushort) PORTS_PER_RTA; 394 rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA;
399 UnixRupP = &HostP->UnixRups[rup]; 395 UnixRupP = &HostP->UnixRups[rup];
400 SysPort = UnixRupP->BaseSysPort + (RBYTE(PktCmdP->PhbNum) % (ushort) PORTS_PER_RTA); 396 SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA);
401 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort); 397 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
402 398
403 if (UnixRupP->BaseSysPort == NO_PORT) { 399 if (UnixRupP->BaseSysPort == NO_PORT) {
404 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n"); 400 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
405 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n"); 401 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); 402 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
407 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); 403 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup);
408 404
409 if (Rup >= (ushort) MAX_RUP) { 405 if (Rup >= (unsigned short) MAX_RUP) {
410 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); 406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
411 } else 407 } else
412 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); 408 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 *
417 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control); 413 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control);
418 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum); 414 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum);
419 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command); 415 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command);
420 return TRUE; 416 return 1;
421 } 417 }
422 PortP = p->RIOPortp[SysPort]; 418 PortP = p->RIOPortp[SysPort];
423 rio_spin_lock_irqsave(&PortP->portSem, flags); 419 rio_spin_lock_irqsave(&PortP->portSem, flags);
424 switch (RBYTE(PktCmdP->Command)) { 420 switch (readb(&PktCmdP->Command)) {
425 case BREAK_RECEIVED: 421 case BREAK_RECEIVED:
426 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); 422 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
427 /* If the current line disc. is not multi-threading and 423 /* If the current line disc. is not multi-threading and
428 the current processor is not the default, reset rup_intr 424 the current processor is not the default, reset rup_intr
429 and return FALSE to ensure that the command packet is 425 and return 0 to ensure that the command packet is
430 not freed. */ 426 not freed. */
431 /* Call tmgr HANGUP HERE */ 427 /* Call tmgr HANGUP HERE */
432 /* Fix this later when every thing works !!!! RAMRAJ */ 428 /* 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 *
434 break; 430 break;
435 431
436 case COMPLETE: 432 case COMPLETE:
437 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %d\n", RBYTE(PktCmdP->PhbNum), HostP - p->RIOHosts); 433 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts);
438 subCommand = 1; 434 subCommand = 1;
439 switch (RBYTE(PktCmdP->SubCommand)) { 435 switch (readb(&PktCmdP->SubCommand)) {
440 case MEMDUMP: 436 case MEMDUMP:
441 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr)); 437 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr));
442 break; 438 break;
443 case READ_REGISTER: 439 case READ_REGISTER:
444 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr)); 440 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr));
445 p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST); 441 p->CdRegister = (readb(&PktCmdP->ModemStatus) & MSVR1_HOST);
446 break; 442 break;
447 default: 443 default:
448 subCommand = 0; 444 subCommand = 0;
@@ -450,10 +446,10 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
450 } 446 }
451 if (subCommand) 447 if (subCommand)
452 break; 448 break;
453 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", RBYTE(PktCmdP->PortStatus), PortP->PortState); 449 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState);
454 if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) { 450 if (PortP->PortState != readb(&PktCmdP->PortStatus)) {
455 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n"); 451 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n");
456 PortP->PortState = RBYTE(PktCmdP->PortStatus); 452 PortP->PortState = readb(&PktCmdP->PortStatus);
457 /* What should we do here ... 453 /* What should we do here ...
458 wakeup( &PortP->PortState ); 454 wakeup( &PortP->PortState );
459 */ 455 */
@@ -467,7 +463,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
467 ** to the check for modem status change (they're just there because 463 ** to the check for modem status change (they're just there because
468 ** it's a convenient place to put them!). 464 ** it's a convenient place to put them!).
469 */ 465 */
470 ReportedModemStatus = RBYTE(PktCmdP->ModemStatus); 466 ReportedModemStatus = readb(&PktCmdP->ModemStatus);
471 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) { 467 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) {
472 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); 468 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
473 /* 469 /*
@@ -514,9 +510,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
514 */ 510 */
515 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN)) 511 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
516 wake_up_interruptible(&PortP->gs.open_wait); 512 wake_up_interruptible(&PortP->gs.open_wait);
517#ifdef STATS
518 PortP->Stat.ModemOnCnt++;
519#endif
520 } 513 }
521 } else { 514 } else {
522 /* 515 /*
@@ -527,9 +520,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
527 tty_hangup(PortP->gs.tty); 520 tty_hangup(PortP->gs.tty);
528 PortP->State &= ~RIO_CARR_ON; 521 PortP->State &= ~RIO_CARR_ON;
529 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n"); 522 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
530#ifdef STATS
531 PortP->Stat.ModemOffCnt++;
532#endif
533 } 523 }
534 } 524 }
535 } 525 }
@@ -539,14 +529,14 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
539 break; 529 break;
540 530
541 default: 531 default:
542 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n", RBYTE(PktCmdP->Command), HostP - p->RIOHosts); 532 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts);
543 break; 533 break;
544 } 534 }
545 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 535 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
546 536
547 func_exit(); 537 func_exit();
548 538
549 return TRUE; 539 return 1;
550} 540}
551 541
552/* 542/*
@@ -566,10 +556,9 @@ struct CmdBlk *RIOGetCmdBlk(void)
566{ 556{
567 struct CmdBlk *CmdBlkP; 557 struct CmdBlk *CmdBlkP;
568 558
569 CmdBlkP = (struct CmdBlk *) sysbrk(sizeof(struct CmdBlk)); 559 CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
570 if (CmdBlkP) 560 if (CmdBlkP)
571 bzero(CmdBlkP, sizeof(struct CmdBlk)); 561 memset(CmdBlkP, 0, sizeof(struct CmdBlk));
572
573 return CmdBlkP; 562 return CmdBlkP;
574} 563}
575 564
@@ -578,7 +567,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
578*/ 567*/
579void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP) 568void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
580{ 569{
581 sysfree((void *) CmdBlkP, sizeof(struct CmdBlk)); 570 kfree(CmdBlkP);
582} 571}
583 572
584/* 573/*
@@ -591,7 +580,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
591 struct UnixRup *UnixRupP; 580 struct UnixRup *UnixRupP;
592 unsigned long flags; 581 unsigned long flags;
593 582
594 if (Rup >= (ushort) (MAX_RUP + LINKS_PER_UNIT)) { 583 if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) {
595 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup); 584 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
596 RIOFreeCmdBlk(CmdBlkP); 585 RIOFreeCmdBlk(CmdBlkP);
597 return RIO_FAIL; 586 return RIO_FAIL;
@@ -605,14 +594,14 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
605 ** If the RUP is currently inactive, then put the request 594 ** If the RUP is currently inactive, then put the request
606 ** straight on the RUP.... 595 ** straight on the RUP....
607 */ 596 */
608 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) 597 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
609 : TRUE)) { 598 : 1)) {
610 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]); 599 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
611 600
612 /* 601 /*
613 ** Whammy! blat that pack! 602 ** Whammy! blat that pack!
614 */ 603 */
615 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 604 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
616 605
617 /* 606 /*
618 ** place command packet on the pending position. 607 ** place command packet on the pending position.
@@ -622,11 +611,11 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
622 /* 611 /*
623 ** set the command register 612 ** set the command register
624 */ 613 */
625 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 614 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
626 615
627 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 616 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
628 617
629 return RIO_SUCCESS; 618 return 0;
630 } 619 }
631 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n"); 620 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
632 621
@@ -634,20 +623,20 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
634 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n"); 623 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
635 if (UnixRupP->CmdPendingP != NULL) 624 if (UnixRupP->CmdPendingP != NULL)
636 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n"); 625 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
637 if (RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE) 626 if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
638 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n"); 627 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
639 628
640 Base = &UnixRupP->CmdsWaitingP; 629 Base = &UnixRupP->CmdsWaitingP;
641 630
642 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 631 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base);
643 632
644 while (*Base) { 633 while (*Base) {
645 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int) (*Base)); 634 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base);
646 Base = &((*Base)->NextP); 635 Base = &((*Base)->NextP);
647 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 636 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base);
648 } 637 }
649 638
650 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 639 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base);
651 640
652 *Base = CmdBlkP; 641 *Base = CmdBlkP;
653 642
@@ -655,7 +644,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
655 644
656 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 645 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
657 646
658 return RIO_SUCCESS; 647 return 0;
659} 648}
660 649
661/* 650/*
@@ -664,10 +653,10 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
664*/ 653*/
665void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) 654void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
666{ 655{
667 register struct CmdBlk *CmdBlkP; 656 struct CmdBlk *CmdBlkP;
668 register struct UnixRup *UnixRupP; 657 struct UnixRup *UnixRupP;
669 struct PKT *PacketP; 658 struct PKT *PacketP;
670 ushort Rup; 659 unsigned short Rup;
671 unsigned long flags; 660 unsigned long flags;
672 661
673 662
@@ -684,16 +673,14 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
684 /* 673 /*
685 ** First check for incoming commands: 674 ** First check for incoming commands:
686 */ 675 */
687 if (RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { 676 if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
688 int FreeMe; 677 int FreeMe;
689 678
690 PacketP = (PKT *) RIO_PTR(HostP->Caddr, RWORD(UnixRupP->RupP->rxpkt)); 679 PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
691 680
692 ShowPacket(DBG_CMD, PacketP); 681 switch (readb(&PacketP->dest_port)) {
693
694 switch (RBYTE(PacketP->dest_port)) {
695 case BOOT_RUP: 682 case BOOT_RUP:
696 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", RBYTE(PacketP->len) & 0x80 ? "Command" : "Data", RBYTE(PacketP->data[0])); 683 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0]));
697 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 684 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
698 FreeMe = RIOBootRup(p, Rup, HostP, PacketP); 685 FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
699 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 686 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -708,7 +695,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
708 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 695 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
709 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); 696 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
710 if (PacketP->data[5] == MEMDUMP) { 697 if (PacketP->data[5] == MEMDUMP) {
711 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(ushort *) & (PacketP->data[6])); 698 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6]));
712 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32); 699 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32);
713 } 700 }
714 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 701 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -721,7 +708,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
721 break; 708 break;
722 709
723 default: 710 default:
724 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port)); 711 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port));
725 FreeMe = 1; 712 FreeMe = 1;
726 break; 713 break;
727 } 714 }
@@ -730,11 +717,11 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
730 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n"); 717 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
731 put_free_end(HostP, PacketP); 718 put_free_end(HostP, PacketP);
732 719
733 WWORD(UnixRupP->RupP->rxcontrol, RX_RUP_INACTIVE); 720 writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol);
734 721
735 if (RWORD(UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) { 722 if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
736 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup); 723 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
737 WWORD(UnixRupP->RupP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 724 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake);
738 } 725 }
739 } 726 }
740 } 727 }
@@ -744,7 +731,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
744 ** and it has completed, then tidy it up. 731 ** and it has completed, then tidy it up.
745 */ 732 */
746 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */ 733 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
747 (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 734 (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
748 /* 735 /*
749 ** we are idle. 736 ** we are idle.
750 ** there is a command in pending. 737 ** there is a command in pending.
@@ -755,7 +742,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
755 if (CmdBlkP->Packet.dest_port == BOOT_RUP) 742 if (CmdBlkP->Packet.dest_port == BOOT_RUP)
756 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]); 743 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
757 744
758 rio_dprintk(RIO_DEBUG_CMD, "Command 0x%x completed\n", (int) CmdBlkP); 745 rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP);
759 746
760 /* 747 /*
761 ** Clear the Rup lock to prevent mutual exclusion. 748 ** Clear the Rup lock to prevent mutual exclusion.
@@ -782,20 +769,20 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
782 ** is idle, then process the command 769 ** is idle, then process the command
783 */ 770 */
784 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */ 771 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */
785 (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 772 (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
786 /* 773 /*
787 ** if the pre-function is non-zero, call it. 774 ** if the pre-function is non-zero, call it.
788 ** If it returns RIO_FAIL then don't 775 ** If it returns RIO_FAIL then don't
789 ** send this command yet! 776 ** send this command yet!
790 */ 777 */
791 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : TRUE)) { 778 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) {
792 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command 0x%x\n", (int) CmdBlkP); 779 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP);
793 } else { 780 } else {
794 rio_dprintk(RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n", (int) CmdBlkP, CmdBlkP->Packet.data[0]); 781 rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]);
795 /* 782 /*
796 ** Whammy! blat that pack! 783 ** Whammy! blat that pack!
797 */ 784 */
798 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 785 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
799 786
800 /* 787 /*
801 ** remove the command from the rup command queue... 788 ** remove the command from the rup command queue...
@@ -810,7 +797,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
810 /* 797 /*
811 ** set the command register 798 ** set the command register
812 */ 799 */
813 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 800 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
814 801
815 /* 802 /*
816 ** the command block will be freed 803 ** the command block will be freed
@@ -822,7 +809,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
822 } while (Rup); 809 } while (Rup);
823} 810}
824 811
825int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP) 812int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP)
826{ 813{
827 struct Port *PortP = (struct Port *) iPortP; 814 struct Port *PortP = (struct Port *) iPortP;
828 unsigned long flags; 815 unsigned long flags;
@@ -834,33 +821,32 @@ int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
834 return RIOUnUse(iPortP, CmdBlkP); 821 return RIOUnUse(iPortP, CmdBlkP);
835} 822}
836 823
837int RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP) 824int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
838{ 825{
839 struct Port *PortP = (struct Port *) iPortP; 826 struct Port *PortP = (struct Port *) iPortP;
840 PKT *PacketP; 827 struct PKT *PacketP;
841 unsigned long flags; 828 unsigned long flags;
842 829
843 rio_spin_lock_irqsave(&PortP->portSem, flags); 830 rio_spin_lock_irqsave(&PortP->portSem, flags);
844 831
845 while (can_remove_receive(&PacketP, PortP)) { 832 while (can_remove_receive(&PacketP, PortP)) {
846 remove_receive(PortP); 833 remove_receive(PortP);
847 ShowPacket(DBG_PROC, PacketP);
848 put_free_end(PortP->HostP, PacketP); 834 put_free_end(PortP->HostP, PacketP);
849 } 835 }
850 836
851 if (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) { 837 if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
852 /* 838 /*
853 ** MAGIC! (Basically, handshake the RX buffer, so that 839 ** MAGIC! (Basically, handshake the RX buffer, so that
854 ** the RTAs upstream can be re-enabled.) 840 ** the RTAs upstream can be re-enabled.)
855 */ 841 */
856 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n"); 842 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
857 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 843 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
858 } 844 }
859 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 845 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
860 return RIOUnUse(iPortP, CmdBlkP); 846 return RIOUnUse(iPortP, CmdBlkP);
861} 847}
862 848
863int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP) 849int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
864{ 850{
865 struct Port *PortP = (struct Port *) iPortP; 851 struct Port *PortP = (struct Port *) iPortP;
866 unsigned long flags; 852 unsigned long flags;
@@ -890,7 +876,7 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
890 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data 876 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
891 ** hanging around in the transmit buffer is sent immediately. 877 ** hanging around in the transmit buffer is sent immediately.
892 */ 878 */
893 WWORD(PortP->HostP->ParmMapP->tx_intr, 1); 879 writew(1, &PortP->HostP->ParmMapP->tx_intr);
894 /* What to do here .. 880 /* What to do here ..
895 wakeup( (caddr_t)&(PortP->InUse) ); 881 wakeup( (caddr_t)&(PortP->InUse) );
896 */ 882 */
@@ -898,10 +884,6 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
898 return 0; 884 return 0;
899} 885}
900 886
901void ShowPacket(uint Flags, struct PKT *PacketP)
902{
903}
904
905/* 887/*
906** 888**
907** How to use this file: 889** How to use this file:
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index fcf18a061228..d31aba62bb7f 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";
51 51
52#include "linux_compat.h" 52#include "linux_compat.h"
53#include "rio_linux.h" 53#include "rio_linux.h"
54#include "typdef.h"
55#include "pkt.h" 54#include "pkt.h"
56#include "daemon.h" 55#include "daemon.h"
57#include "rio.h" 56#include "rio.h"
58#include "riospace.h" 57#include "riospace.h"
59#include "top.h"
60#include "cmdpkt.h" 58#include "cmdpkt.h"
61#include "map.h" 59#include "map.h"
62#include "riotypes.h"
63#include "rup.h" 60#include "rup.h"
64#include "port.h" 61#include "port.h"
65#include "riodrvr.h" 62#include "riodrvr.h"
@@ -72,12 +69,10 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
72#include "unixrup.h" 69#include "unixrup.h"
73#include "board.h" 70#include "board.h"
74#include "host.h" 71#include "host.h"
75#include "error.h"
76#include "phb.h" 72#include "phb.h"
77#include "link.h" 73#include "link.h"
78#include "cmdblk.h" 74#include "cmdblk.h"
79#include "route.h" 75#include "route.h"
80#include "control.h"
81#include "cirrus.h" 76#include "cirrus.h"
82#include "rioioctl.h" 77#include "rioioctl.h"
83 78
@@ -131,30 +126,6 @@ static int
131 126
132#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff)) 127#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
133 128
134int copyin(int arg, caddr_t dp, int siz)
135{
136 int rv;
137
138 rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes from user %p to %p.\n", siz, (void *) arg, dp);
139 rv = copy_from_user(dp, (void *) arg, siz);
140 if (rv)
141 return COPYFAIL;
142 else
143 return rv;
144}
145
146static int copyout(caddr_t dp, int arg, int siz)
147{
148 int rv;
149
150 rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes to user %p from %p.\n", siz, (void *) arg, dp);
151 rv = copy_to_user((void *) arg, dp, siz);
152 if (rv)
153 return COPYFAIL;
154 else
155 return rv;
156}
157
158int riocontrol(p, dev, cmd, arg, su) 129int riocontrol(p, dev, cmd, arg, su)
159struct rio_info *p; 130struct rio_info *p;
160dev_t dev; 131dev_t dev;
@@ -168,7 +139,7 @@ int su;
168 ushort loop; 139 ushort loop;
169 int Entry; 140 int Entry;
170 struct Port *PortP; 141 struct Port *PortP;
171 PKT *PacketP; 142 struct PKT *PacketP;
172 int retval = 0; 143 int retval = 0;
173 unsigned long flags; 144 unsigned long flags;
174 145
@@ -178,7 +149,7 @@ int su;
178 Host = 0; 149 Host = 0;
179 PortP = NULL; 150 PortP = NULL;
180 151
181 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd, (int) arg); 152 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, arg);
182 153
183 switch (cmd) { 154 switch (cmd) {
184 /* 155 /*
@@ -189,90 +160,34 @@ int su;
189 ** otherwise just the specified host card will be changed. 160 ** otherwise just the specified host card will be changed.
190 */ 161 */
191 case RIO_SET_TIMER: 162 case RIO_SET_TIMER:
192 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %dms\n", (uint) arg); 163 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", (unsigned long)arg);
193 { 164 {
194 int host, value; 165 int host, value;
195 host = (uint) arg >> 16; 166 host = ((unsigned long) arg >> 16) & 0x0000FFFF;
196 value = (uint) arg & 0x0000ffff; 167 value = (unsigned long) arg & 0x0000ffff;
197 if (host == -1) { 168 if (host == -1) {
198 for (host = 0; host < p->RIONumHosts; host++) { 169 for (host = 0; host < p->RIONumHosts; host++) {
199 if (p->RIOHosts[host].Flags == RC_RUNNING) { 170 if (p->RIOHosts[host].Flags == RC_RUNNING) {
200 WWORD(p->RIOHosts[host].ParmMapP->timer, value); 171 writew(value, &p->RIOHosts[host].ParmMapP->timer);
201 } 172 }
202 } 173 }
203 } else if (host >= p->RIONumHosts) { 174 } else if (host >= p->RIONumHosts) {
204 return -EINVAL; 175 return -EINVAL;
205 } else { 176 } else {
206 if (p->RIOHosts[host].Flags == RC_RUNNING) { 177 if (p->RIOHosts[host].Flags == RC_RUNNING) {
207 WWORD(p->RIOHosts[host].ParmMapP->timer, value); 178 writew(value, &p->RIOHosts[host].ParmMapP->timer);
208 } 179 }
209 } 180 }
210 } 181 }
211 return 0; 182 return 0;
212 183
213 case RIO_IDENTIFY_DRIVER:
214 /*
215 ** 15.10.1998 ARG - ESIL 0760 part fix
216 ** Added driver ident string output.
217 **
218 #ifndef __THIS_RELEASE__
219 #warning Driver Version string not defined !
220 #endif
221 cprintf("%s %s %s %s\n",
222 RIO_DRV_STR,
223 __THIS_RELEASE__,
224 __DATE__, __TIME__ );
225
226 return 0;
227
228 case RIO_DISPLAY_HOST_CFG:
229 **
230 ** 15.10.1998 ARG - ESIL 0760 part fix
231 ** Added driver host card ident string output.
232 **
233 ** Note that the only types currently supported
234 ** are ISA and PCI. Also this driver does not
235 ** (yet) distinguish between the Old PCI card
236 ** and the Jet PCI card. In fact I think this
237 ** driver only supports JET PCI !
238 **
239
240 for (Host = 0; Host < p->RIONumHosts; Host++)
241 {
242 HostP = &(p->RIOHosts[Host]);
243
244 switch ( HostP->Type )
245 {
246 case RIO_AT :
247 strcpy( host_type, RIO_AT_HOST_STR );
248 break;
249
250 case RIO_PCI :
251 strcpy( host_type, RIO_PCI_HOST_STR );
252 break;
253
254 default :
255 strcpy( host_type, "Unknown" );
256 break;
257 }
258
259 cprintf(
260 "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
261 Host, host_type,
262 (uint)HostP->PaddrP,
263 (int)HostP->Ivec - 32 );
264 }
265 return 0;
266 **
267 */
268
269 case RIO_FOAD_RTA: 184 case RIO_FOAD_RTA:
270 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n"); 185 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
271 return RIOCommandRta(p, (uint) arg, RIOFoadRta); 186 return RIOCommandRta(p, (unsigned long)arg, RIOFoadRta);
272 187
273 case RIO_ZOMBIE_RTA: 188 case RIO_ZOMBIE_RTA:
274 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n"); 189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
275 return RIOCommandRta(p, (uint) arg, RIOZombieRta); 190 return RIOCommandRta(p, (unsigned long)arg, RIOZombieRta);
276 191
277 case RIO_IDENTIFY_RTA: 192 case RIO_IDENTIFY_RTA:
278 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n"); 193 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
@@ -287,7 +202,7 @@ int su;
287 struct CmdBlk *CmdBlkP; 202 struct CmdBlk *CmdBlkP;
288 203
289 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n"); 204 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
290 if (copyin((int) arg, (caddr_t) & SpecialRupCmd, sizeof(SpecialRupCmd)) == COPYFAIL) { 205 if (copy_from_user(&SpecialRupCmd, arg, sizeof(SpecialRupCmd))) {
291 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n"); 206 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
292 p->RIOError.Error = COPYIN_FAILED; 207 p->RIOError.Error = COPYIN_FAILED;
293 return -EFAULT; 208 return -EFAULT;
@@ -302,7 +217,7 @@ int su;
302 SpecialRupCmd.Host = 0; 217 SpecialRupCmd.Host = 0;
303 rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum); 218 rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum);
304 if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) { 219 if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) {
305 cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n"); 220 printk(KERN_WARNING "rio: FAILED TO QUEUE SPECIAL RUP COMMAND\n");
306 } 221 }
307 return 0; 222 return 0;
308 } 223 }
@@ -324,7 +239,7 @@ int su;
324 if ((retval = RIOApel(p)) != 0) 239 if ((retval = RIOApel(p)) != 0)
325 return retval; 240 return retval;
326 241
327 if (copyout((caddr_t) p->RIOConnectTable, (int) arg, TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) { 242 if (copy_to_user(arg, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
328 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n"); 243 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
329 p->RIOError.Error = COPYOUT_FAILED; 244 p->RIOError.Error = COPYOUT_FAILED;
330 return -EFAULT; 245 return -EFAULT;
@@ -369,7 +284,7 @@ int su;
369 p->RIOError.Error = NOT_SUPER_USER; 284 p->RIOError.Error = NOT_SUPER_USER;
370 return -EPERM; 285 return -EPERM;
371 } 286 }
372 if (copyin((int) arg, (caddr_t) & p->RIOConnectTable[0], TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) { 287 if (copy_from_user(&p->RIOConnectTable[0], arg, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
373 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n"); 288 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
374 p->RIOError.Error = COPYIN_FAILED; 289 p->RIOError.Error = COPYIN_FAILED;
375 return -EFAULT; 290 return -EFAULT;
@@ -415,7 +330,7 @@ int su;
415 p->RIOError.Error = NOT_SUPER_USER; 330 p->RIOError.Error = NOT_SUPER_USER;
416 return -EPERM; 331 return -EPERM;
417 } 332 }
418 if (copyout((caddr_t) p->RIOBindTab, (int) arg, (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) { 333 if (copy_to_user(arg, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
419 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n"); 334 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
420 p->RIOError.Error = COPYOUT_FAILED; 335 p->RIOError.Error = COPYOUT_FAILED;
421 return -EFAULT; 336 return -EFAULT;
@@ -434,7 +349,7 @@ int su;
434 p->RIOError.Error = NOT_SUPER_USER; 349 p->RIOError.Error = NOT_SUPER_USER;
435 return -EPERM; 350 return -EPERM;
436 } 351 }
437 if (copyin((int) arg, (caddr_t) & p->RIOBindTab[0], (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) { 352 if (copy_from_user(&p->RIOBindTab[0], arg, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
438 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n"); 353 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
439 p->RIOError.Error = COPYIN_FAILED; 354 p->RIOError.Error = COPYIN_FAILED;
440 return -EFAULT; 355 return -EFAULT;
@@ -458,12 +373,12 @@ int su;
458 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) { 373 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
459 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L)) 374 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
460 EmptySlot = Entry; 375 EmptySlot = Entry;
461 else if (p->RIOBindTab[Entry] == (int) arg) { 376 else if (p->RIOBindTab[Entry] == (long)arg) {
462 /* 377 /*
463 ** Already exists - delete 378 ** Already exists - delete
464 */ 379 */
465 p->RIOBindTab[Entry] = 0L; 380 p->RIOBindTab[Entry] = 0L;
466 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %x from p->RIOBindTab\n", (int) arg); 381 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", (unsigned long)arg);
467 return 0; 382 return 0;
468 } 383 }
469 } 384 }
@@ -471,10 +386,10 @@ int su;
471 ** Dosen't exist - add 386 ** Dosen't exist - add
472 */ 387 */
473 if (EmptySlot != -1) { 388 if (EmptySlot != -1) {
474 p->RIOBindTab[EmptySlot] = (int) arg; 389 p->RIOBindTab[EmptySlot] = (unsigned long)arg;
475 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %x to p->RIOBindTab\n", (int) arg); 390 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", (unsigned long) arg);
476 } else { 391 } else {
477 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %x not added\n", (int) arg); 392 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", (unsigned long) arg);
478 return -ENOMEM; 393 return -ENOMEM;
479 } 394 }
480 return 0; 395 return 0;
@@ -482,7 +397,7 @@ int su;
482 397
483 case RIO_RESUME: 398 case RIO_RESUME:
484 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n"); 399 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n");
485 port = (uint) arg; 400 port = (unsigned long) arg;
486 if ((port < 0) || (port > 511)) { 401 if ((port < 0) || (port > 511)) {
487 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port); 402 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
488 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 403 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -518,8 +433,7 @@ int su;
518 p->RIOError.Error = NOT_SUPER_USER; 433 p->RIOError.Error = NOT_SUPER_USER;
519 return -EPERM; 434 return -EPERM;
520 } 435 }
521 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 436 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
522 == COPYFAIL) {
523 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 437 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
524 p->RIOError.Error = COPYIN_FAILED; 438 p->RIOError.Error = COPYIN_FAILED;
525 return -EFAULT; 439 return -EFAULT;
@@ -533,8 +447,7 @@ int su;
533 p->RIOError.Error = NOT_SUPER_USER; 447 p->RIOError.Error = NOT_SUPER_USER;
534 return -EPERM; 448 return -EPERM;
535 } 449 }
536 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 450 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
537 == COPYFAIL) {
538 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 451 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
539 p->RIOError.Error = COPYIN_FAILED; 452 p->RIOError.Error = COPYIN_FAILED;
540 return -EFAULT; 453 return -EFAULT;
@@ -548,8 +461,7 @@ int su;
548 p->RIOError.Error = NOT_SUPER_USER; 461 p->RIOError.Error = NOT_SUPER_USER;
549 return -EPERM; 462 return -EPERM;
550 } 463 }
551 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 464 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
552 == COPYFAIL) {
553 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n"); 465 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n");
554 p->RIOError.Error = COPYIN_FAILED; 466 p->RIOError.Error = COPYIN_FAILED;
555 return -EFAULT; 467 return -EFAULT;
@@ -557,30 +469,14 @@ int su;
557 return RIODeleteRta(p, &MapEnt); 469 return RIODeleteRta(p, &MapEnt);
558 470
559 case RIO_QUICK_CHECK: 471 case RIO_QUICK_CHECK:
560 /* 472 if (copy_to_user(arg, &p->RIORtaDisCons, sizeof(unsigned int))) {
561 ** 09.12.1998 ARG - ESIL 0776 part fix
562 ** A customer was using this to get the RTAs
563 ** connect/disconnect status.
564 ** RIOConCon() had been botched use RIOHalted
565 ** to keep track of RTA connections and
566 ** disconnections. That has been changed and
567 ** RIORtaDisCons in the rio_info struct now
568 ** does the job. So we need to return the value
569 ** of RIORtaCons instead of RIOHalted.
570 **
571 if (copyout((caddr_t)&p->RIOHalted,(int)arg,
572 sizeof(uint))==COPYFAIL) {
573 **
574 */
575
576 if (copyout((caddr_t) & p->RIORtaDisCons, (int) arg, sizeof(uint)) == COPYFAIL) {
577 p->RIOError.Error = COPYOUT_FAILED; 473 p->RIOError.Error = COPYOUT_FAILED;
578 return -EFAULT; 474 return -EFAULT;
579 } 475 }
580 return 0; 476 return 0;
581 477
582 case RIO_LAST_ERROR: 478 case RIO_LAST_ERROR:
583 if (copyout((caddr_t) & p->RIOError, (int) arg, sizeof(struct Error)) == COPYFAIL) 479 if (copy_to_user(arg, &p->RIOError, sizeof(struct Error)))
584 return -EFAULT; 480 return -EFAULT;
585 return 0; 481 return 0;
586 482
@@ -589,7 +485,7 @@ int su;
589 return -EINVAL; 485 return -EINVAL;
590 486
591 case RIO_GET_MODTYPE: 487 case RIO_GET_MODTYPE:
592 if (copyin((int) arg, (caddr_t) & port, sizeof(uint)) == COPYFAIL) { 488 if (copy_from_user(&port, arg, sizeof(unsigned int))) {
593 p->RIOError.Error = COPYIN_FAILED; 489 p->RIOError.Error = COPYIN_FAILED;
594 return -EFAULT; 490 return -EFAULT;
595 } 491 }
@@ -609,36 +505,11 @@ int su;
609 ** Return module type of port 505 ** Return module type of port
610 */ 506 */
611 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes; 507 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
612 if (copyout((caddr_t) & port, (int) arg, sizeof(uint)) == COPYFAIL) { 508 if (copy_to_user(arg, &port, sizeof(unsigned int))) {
613 p->RIOError.Error = COPYOUT_FAILED; 509 p->RIOError.Error = COPYOUT_FAILED;
614 return -EFAULT; 510 return -EFAULT;
615 } 511 }
616 return (0); 512 return (0);
617 /*
618 ** 02.03.1999 ARG - ESIL 0820 fix
619 ** We are no longer using "Boot Mode", so these ioctls
620 ** are not required :
621 **
622 case RIO_GET_BOOT_MODE :
623 rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
624 **
625 ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
626 **
627 if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
628 sizeof(p->RIOBootMode)) == COPYFAIL) {
629 p->RIOError.Error = COPYOUT_FAILED;
630 return -EFAULT;
631 }
632 return(0);
633
634 case RIO_SET_BOOT_MODE :
635 p->RIOBootMode = (uint) arg;
636 rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
637 return(0);
638 **
639 ** End ESIL 0820 fix
640 */
641
642 case RIO_BLOCK_OPENS: 513 case RIO_BLOCK_OPENS:
643 rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n"); 514 rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n");
644 for (Entry = 0; Entry < RIO_PORTS; Entry++) { 515 for (Entry = 0; Entry < RIO_PORTS; Entry++) {
@@ -650,8 +521,7 @@ int su;
650 521
651 case RIO_SETUP_PORTS: 522 case RIO_SETUP_PORTS:
652 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n"); 523 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n");
653 if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup)) 524 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
654 == COPYFAIL) {
655 p->RIOError.Error = COPYIN_FAILED; 525 p->RIOError.Error = COPYIN_FAILED;
656 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT"); 526 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT");
657 return -EFAULT; 527 return -EFAULT;
@@ -667,7 +537,7 @@ int su;
667 return -EINVAL; 537 return -EINVAL;
668 } 538 }
669 if (!p->RIOPortp) { 539 if (!p->RIOPortp) {
670 cprintf("No p->RIOPortp array!\n"); 540 printk(KERN_ERR "rio: No p->RIOPortp array!\n");
671 rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n"); 541 rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
672 return -EIO; 542 return -EIO;
673 } 543 }
@@ -681,8 +551,7 @@ int su;
681 551
682 case RIO_GET_PORT_SETUP: 552 case RIO_GET_PORT_SETUP:
683 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n"); 553 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n");
684 if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup)) 554 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
685 == COPYFAIL) {
686 p->RIOError.Error = COPYIN_FAILED; 555 p->RIOError.Error = COPYIN_FAILED;
687 return -EFAULT; 556 return -EFAULT;
688 } 557 }
@@ -698,13 +567,12 @@ int su;
698 PortSetup.Store = p->RIOPortp[port]->Store; 567 PortSetup.Store = p->RIOPortp[port]->Store;
699 PortSetup.Lock = p->RIOPortp[port]->Lock; 568 PortSetup.Lock = p->RIOPortp[port]->Lock;
700 PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps; 569 PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps;
701 bcopy(p->RIOPortp[port]->Xprint.XpOn, PortSetup.XpOn, MAX_XP_CTRL_LEN); 570 memcpy(PortSetup.XpOn, p->RIOPortp[port]->Xprint.XpOn, MAX_XP_CTRL_LEN);
702 bcopy(p->RIOPortp[port]->Xprint.XpOff, PortSetup.XpOff, MAX_XP_CTRL_LEN); 571 memcpy(PortSetup.XpOff, p->RIOPortp[port]->Xprint.XpOff, MAX_XP_CTRL_LEN);
703 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0'; 572 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
704 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0'; 573 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
705 574
706 if (copyout((caddr_t) & PortSetup, (int) arg, sizeof(PortSetup)) 575 if (copy_to_user(arg, &PortSetup, sizeof(PortSetup))) {
707 == COPYFAIL) {
708 p->RIOError.Error = COPYOUT_FAILED; 576 p->RIOError.Error = COPYOUT_FAILED;
709 return -EFAULT; 577 return -EFAULT;
710 } 578 }
@@ -712,7 +580,7 @@ int su;
712 580
713 case RIO_GET_PORT_PARAMS: 581 case RIO_GET_PORT_PARAMS:
714 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n"); 582 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n");
715 if (copyin((int) arg, (caddr_t) & PortParams, sizeof(struct PortParams)) == COPYFAIL) { 583 if (copy_from_user(&PortParams, arg, sizeof(struct PortParams))) {
716 p->RIOError.Error = COPYIN_FAILED; 584 p->RIOError.Error = COPYIN_FAILED;
717 return -EFAULT; 585 return -EFAULT;
718 } 586 }
@@ -725,7 +593,7 @@ int su;
725 PortParams.State = PortP->State; 593 PortParams.State = PortP->State;
726 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port); 594 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
727 595
728 if (copyout((caddr_t) & PortParams, (int) arg, sizeof(struct PortParams)) == COPYFAIL) { 596 if (copy_to_user(arg, &PortParams, sizeof(struct PortParams))) {
729 p->RIOError.Error = COPYOUT_FAILED; 597 p->RIOError.Error = COPYOUT_FAILED;
730 return -EFAULT; 598 return -EFAULT;
731 } 599 }
@@ -733,8 +601,7 @@ int su;
733 601
734 case RIO_GET_PORT_TTY: 602 case RIO_GET_PORT_TTY:
735 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n"); 603 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n");
736 if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) 604 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
737 == COPYFAIL) {
738 p->RIOError.Error = COPYIN_FAILED; 605 p->RIOError.Error = COPYIN_FAILED;
739 return -EFAULT; 606 return -EFAULT;
740 } 607 }
@@ -745,14 +612,14 @@ int su;
745 612
746 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port); 613 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
747 PortP = (p->RIOPortp[PortTty.port]); 614 PortP = (p->RIOPortp[PortTty.port]);
748 if (copyout((caddr_t) & PortTty, (int) arg, sizeof(struct PortTty)) == COPYFAIL) { 615 if (copy_to_user(arg, &PortTty, sizeof(struct PortTty))) {
749 p->RIOError.Error = COPYOUT_FAILED; 616 p->RIOError.Error = COPYOUT_FAILED;
750 return -EFAULT; 617 return -EFAULT;
751 } 618 }
752 return retval; 619 return retval;
753 620
754 case RIO_SET_PORT_TTY: 621 case RIO_SET_PORT_TTY:
755 if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) == COPYFAIL) { 622 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
756 p->RIOError.Error = COPYIN_FAILED; 623 p->RIOError.Error = COPYIN_FAILED;
757 return -EFAULT; 624 return -EFAULT;
758 } 625 }
@@ -767,8 +634,7 @@ int su;
767 634
768 case RIO_SET_PORT_PARAMS: 635 case RIO_SET_PORT_PARAMS:
769 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n"); 636 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n");
770 if (copyin((int) arg, (caddr_t) & PortParams, sizeof(PortParams)) 637 if (copy_from_user(&PortParams, arg, sizeof(PortParams))) {
771 == COPYFAIL) {
772 p->RIOError.Error = COPYIN_FAILED; 638 p->RIOError.Error = COPYIN_FAILED;
773 return -EFAULT; 639 return -EFAULT;
774 } 640 }
@@ -784,7 +650,7 @@ int su;
784 650
785 case RIO_GET_PORT_STATS: 651 case RIO_GET_PORT_STATS:
786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n"); 652 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
787 if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) { 653 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
788 p->RIOError.Error = COPYIN_FAILED; 654 p->RIOError.Error = COPYIN_FAILED;
789 return -EFAULT; 655 return -EFAULT;
790 } 656 }
@@ -799,14 +665,14 @@ int su;
799 portStats.opens = PortP->opens; 665 portStats.opens = PortP->opens;
800 portStats.closes = PortP->closes; 666 portStats.closes = PortP->closes;
801 portStats.ioctls = PortP->ioctls; 667 portStats.ioctls = PortP->ioctls;
802 if (copyout((caddr_t) & portStats, (int) arg, sizeof(struct portStats)) == COPYFAIL) { 668 if (copy_to_user(arg, &portStats, sizeof(struct portStats))) {
803 p->RIOError.Error = COPYOUT_FAILED; 669 p->RIOError.Error = COPYOUT_FAILED;
804 return -EFAULT; 670 return -EFAULT;
805 } 671 }
806 return retval; 672 return retval;
807 673
808 case RIO_RESET_PORT_STATS: 674 case RIO_RESET_PORT_STATS:
809 port = (uint) arg; 675 port = (unsigned long) arg;
810 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n"); 676 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
811 if (port >= RIO_PORTS) { 677 if (port >= RIO_PORTS) {
812 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 678 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -824,7 +690,7 @@ int su;
824 690
825 case RIO_GATHER_PORT_STATS: 691 case RIO_GATHER_PORT_STATS:
826 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n"); 692 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
827 if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) { 693 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
828 p->RIOError.Error = COPYIN_FAILED; 694 p->RIOError.Error = COPYIN_FAILED;
829 return -EFAULT; 695 return -EFAULT;
830 } 696 }
@@ -840,7 +706,7 @@ int su;
840 706
841 case RIO_READ_CONFIG: 707 case RIO_READ_CONFIG:
842 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n"); 708 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
843 if (copyout((caddr_t) & p->RIOConf, (int) arg, sizeof(struct Conf)) == COPYFAIL) { 709 if (copy_to_user(arg, &p->RIOConf, sizeof(struct Conf))) {
844 p->RIOError.Error = COPYOUT_FAILED; 710 p->RIOError.Error = COPYOUT_FAILED;
845 return -EFAULT; 711 return -EFAULT;
846 } 712 }
@@ -852,8 +718,7 @@ int su;
852 p->RIOError.Error = NOT_SUPER_USER; 718 p->RIOError.Error = NOT_SUPER_USER;
853 return -EPERM; 719 return -EPERM;
854 } 720 }
855 if (copyin((int) arg, (caddr_t) & p->RIOConf, sizeof(struct Conf)) 721 if (copy_from_user(&p->RIOConf, arg, sizeof(struct Conf))) {
856 == COPYFAIL) {
857 p->RIOError.Error = COPYIN_FAILED; 722 p->RIOError.Error = COPYIN_FAILED;
858 return -EFAULT; 723 return -EFAULT;
859 } 724 }
@@ -862,7 +727,7 @@ int su;
862 */ 727 */
863 for (Host = 0; Host < p->RIONumHosts; Host++) 728 for (Host = 0; Host < p->RIONumHosts; Host++)
864 if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING) 729 if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING)
865 WWORD(p->RIOHosts[Host].ParmMapP->timer, p->RIOConf.Timer); 730 writew(p->RIOConf.Timer, &p->RIOHosts[Host].ParmMapP->timer);
866 return retval; 731 return retval;
867 732
868 case RIO_START_POLLER: 733 case RIO_START_POLLER:
@@ -881,8 +746,7 @@ int su;
881 case RIO_SETDEBUG: 746 case RIO_SETDEBUG:
882 case RIO_GETDEBUG: 747 case RIO_GETDEBUG:
883 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n"); 748 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
884 if (copyin((int) arg, (caddr_t) & DebugCtrl, sizeof(DebugCtrl)) 749 if (copy_from_user(&DebugCtrl, arg, sizeof(DebugCtrl))) {
885 == COPYFAIL) {
886 p->RIOError.Error = COPYIN_FAILED; 750 p->RIOError.Error = COPYIN_FAILED;
887 return -EFAULT; 751 return -EFAULT;
888 } 752 }
@@ -899,7 +763,7 @@ int su;
899 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait); 763 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait);
900 DebugCtrl.Debug = p->rio_debug; 764 DebugCtrl.Debug = p->rio_debug;
901 DebugCtrl.Wait = p->RIODebugWait; 765 DebugCtrl.Wait = p->RIODebugWait;
902 if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) { 766 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
903 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); 767 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
904 p->RIOError.Error = COPYOUT_FAILED; 768 p->RIOError.Error = COPYOUT_FAILED;
905 return -EFAULT; 769 return -EFAULT;
@@ -921,7 +785,7 @@ int su;
921 } else { 785 } else {
922 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); 786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
923 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug; 787 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
924 if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) { 788 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
925 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n"); 789 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
926 p->RIOError.Error = COPYOUT_FAILED; 790 p->RIOError.Error = COPYOUT_FAILED;
927 return -EFAULT; 791 return -EFAULT;
@@ -936,43 +800,20 @@ int su;
936 ** textual null terminated string. 800 ** textual null terminated string.
937 */ 801 */
938 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n"); 802 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n");
939 if (copyout((caddr_t) RIOVersid(), (int) arg, sizeof(struct rioVersion)) == COPYFAIL) { 803 if (copy_to_user(arg, RIOVersid(), sizeof(struct rioVersion))) {
940 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host); 804 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
941 p->RIOError.Error = COPYOUT_FAILED; 805 p->RIOError.Error = COPYOUT_FAILED;
942 return -EFAULT; 806 return -EFAULT;
943 } 807 }
944 return retval; 808 return retval;
945 809
946 /*
947 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
948 ** !! commented out previous 'RIO_VERSID' functionality !!
949 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
950 **
951 case RIO_VERSID:
952 **
953 ** Enquire about the release and version.
954 ** We return MAX_VERSION_LEN bytes, being a textual null
955 ** terminated string.
956 **
957 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
958 if (copyout((caddr_t)RIOVersid(),
959 (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
960 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
961 p->RIOError.Error = COPYOUT_FAILED;
962 return -EFAULT;
963 }
964 return retval;
965 **
966 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
967 */
968
969 case RIO_NUM_HOSTS: 810 case RIO_NUM_HOSTS:
970 /* 811 /*
971 ** Enquire as to the number of hosts located 812 ** Enquire as to the number of hosts located
972 ** at init time. 813 ** at init time.
973 */ 814 */
974 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n"); 815 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
975 if (copyout((caddr_t) & p->RIONumHosts, (int) arg, sizeof(p->RIONumHosts)) == COPYFAIL) { 816 if (copy_to_user(arg, &p->RIONumHosts, sizeof(p->RIONumHosts))) {
976 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n"); 817 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
977 p->RIOError.Error = COPYOUT_FAILED; 818 p->RIOError.Error = COPYOUT_FAILED;
978 return -EFAULT; 819 return -EFAULT;
@@ -983,7 +824,7 @@ int su;
983 /* 824 /*
984 ** Kill host. This may not be in the final version... 825 ** Kill host. This may not be in the final version...
985 */ 826 */
986 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int) arg); 827 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", (unsigned long) arg);
987 if (!su) { 828 if (!su) {
988 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n"); 829 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
989 p->RIOError.Error = NOT_SUPER_USER; 830 p->RIOError.Error = NOT_SUPER_USER;
@@ -994,7 +835,7 @@ int su;
994 835
995 for (Host = 0; Host < p->RIONumHosts; Host++) { 836 for (Host = 0; Host < p->RIONumHosts; Host++) {
996 (void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot); 837 (void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot);
997 bzero((caddr_t) & p->RIOHosts[Host].Flags, ((int) &p->RIOHosts[Host].____end_marker____) - ((int) &p->RIOHosts[Host].Flags)); 838 memset(&p->RIOHosts[Host].Flags, 0, ((char *) &p->RIOHosts[Host].____end_marker____) - ((char *) &p->RIOHosts[Host].Flags));
998 p->RIOHosts[Host].Flags = RC_WAITING; 839 p->RIOHosts[Host].Flags = RC_WAITING;
999 } 840 }
1000 RIOFoadWakeup(p); 841 RIOFoadWakeup(p);
@@ -1017,7 +858,7 @@ int su;
1017 p->RIOError.Error = NOT_SUPER_USER; 858 p->RIOError.Error = NOT_SUPER_USER;
1018 return -EPERM; 859 return -EPERM;
1019 } 860 }
1020 if (copyin((int) arg, (caddr_t) & DownLoad, sizeof(DownLoad)) == COPYFAIL) { 861 if (copy_from_user(&DownLoad, arg, sizeof(DownLoad))) {
1021 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n"); 862 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
1022 p->RIOError.Error = COPYIN_FAILED; 863 p->RIOError.Error = COPYIN_FAILED;
1023 return -EFAULT; 864 return -EFAULT;
@@ -1045,9 +886,9 @@ int su;
1045 886
1046 case RIO_PARMS: 887 case RIO_PARMS:
1047 { 888 {
1048 uint host; 889 unsigned int host;
1049 890
1050 if (copyin((int) arg, (caddr_t) & host, sizeof(host)) == COPYFAIL) { 891 if (copy_from_user(&host, arg, sizeof(host))) {
1051 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 892 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
1052 p->RIOError.Error = COPYIN_FAILED; 893 p->RIOError.Error = COPYIN_FAILED;
1053 return -EFAULT; 894 return -EFAULT;
@@ -1056,7 +897,7 @@ int su;
1056 ** Fetch the parmmap 897 ** Fetch the parmmap
1057 */ 898 */
1058 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n"); 899 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n");
1059 if (copyout((caddr_t) p->RIOHosts[host].ParmMapP, (int) arg, sizeof(PARM_MAP)) == COPYFAIL) { 900 if (copy_to_user(arg, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) {
1060 p->RIOError.Error = COPYOUT_FAILED; 901 p->RIOError.Error = COPYOUT_FAILED;
1061 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); 902 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
1062 return -EFAULT; 903 return -EFAULT;
@@ -1066,7 +907,7 @@ int su;
1066 907
1067 case RIO_HOST_REQ: 908 case RIO_HOST_REQ:
1068 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n"); 909 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
1069 if (copyin((int) arg, (caddr_t) & HostReq, sizeof(HostReq)) == COPYFAIL) { 910 if (copy_from_user(&HostReq, arg, sizeof(HostReq))) {
1070 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 911 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
1071 p->RIOError.Error = COPYIN_FAILED; 912 p->RIOError.Error = COPYIN_FAILED;
1072 return -EFAULT; 913 return -EFAULT;
@@ -1078,7 +919,7 @@ int su;
1078 } 919 }
1079 rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum); 920 rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
1080 921
1081 if (copyout((caddr_t) & p->RIOHosts[HostReq.HostNum], (int) HostReq.HostP, sizeof(struct Host)) == COPYFAIL) { 922 if (copy_to_user(HostReq.HostP, &p->RIOHosts[HostReq.HostNum], sizeof(struct Host))) {
1082 p->RIOError.Error = COPYOUT_FAILED; 923 p->RIOError.Error = COPYOUT_FAILED;
1083 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n"); 924 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
1084 return -EFAULT; 925 return -EFAULT;
@@ -1087,7 +928,7 @@ int su;
1087 928
1088 case RIO_HOST_DPRAM: 929 case RIO_HOST_DPRAM:
1089 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n"); 930 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n");
1090 if (copyin((int) arg, (caddr_t) & HostDpRam, sizeof(HostDpRam)) == COPYFAIL) { 931 if (copy_from_user(&HostDpRam, arg, sizeof(HostDpRam))) {
1091 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n"); 932 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
1092 p->RIOError.Error = COPYIN_FAILED; 933 p->RIOError.Error = COPYIN_FAILED;
1093 return -EFAULT; 934 return -EFAULT;
@@ -1104,13 +945,13 @@ int su;
1104 /* It's hardware like this that really gets on my tits. */ 945 /* It's hardware like this that really gets on my tits. */
1105 static unsigned char copy[sizeof(struct DpRam)]; 946 static unsigned char copy[sizeof(struct DpRam)];
1106 for (off = 0; off < sizeof(struct DpRam); off++) 947 for (off = 0; off < sizeof(struct DpRam); off++)
1107 copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off]; 948 copy[off] = readb(&p->RIOHosts[HostDpRam.HostNum].Caddr[off]);
1108 if (copyout((caddr_t) copy, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) { 949 if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) {
1109 p->RIOError.Error = COPYOUT_FAILED; 950 p->RIOError.Error = COPYOUT_FAILED;
1110 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 951 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
1111 return -EFAULT; 952 return -EFAULT;
1112 } 953 }
1113 } else if (copyout((caddr_t) p->RIOHosts[HostDpRam.HostNum].Caddr, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) { 954 } else if (copy_to_user(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) {
1114 p->RIOError.Error = COPYOUT_FAILED; 955 p->RIOError.Error = COPYOUT_FAILED;
1115 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 956 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
1116 return -EFAULT; 957 return -EFAULT;
@@ -1119,13 +960,13 @@ int su;
1119 960
1120 case RIO_SET_BUSY: 961 case RIO_SET_BUSY:
1121 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n"); 962 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
1122 if ((int) arg < 0 || (int) arg > 511) { 963 if ((unsigned long) arg > 511) {
1123 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n", (int) arg); 964 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", (unsigned long) arg);
1124 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 965 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
1125 return -EINVAL; 966 return -EINVAL;
1126 } 967 }
1127 rio_spin_lock_irqsave(&PortP->portSem, flags); 968 rio_spin_lock_irqsave(&PortP->portSem, flags);
1128 p->RIOPortp[(int) arg]->State |= RIO_BUSY; 969 p->RIOPortp[(unsigned long) arg]->State |= RIO_BUSY;
1129 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 970 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1130 return retval; 971 return retval;
1131 972
@@ -1135,7 +976,7 @@ int su;
1135 ** (probably for debug reasons) 976 ** (probably for debug reasons)
1136 */ 977 */
1137 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n"); 978 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
1138 if (copyin((int) arg, (caddr_t) & PortReq, sizeof(PortReq)) == COPYFAIL) { 979 if (copy_from_user(&PortReq, arg, sizeof(PortReq))) {
1139 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n"); 980 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
1140 p->RIOError.Error = COPYIN_FAILED; 981 p->RIOError.Error = COPYIN_FAILED;
1141 return -EFAULT; 982 return -EFAULT;
@@ -1147,7 +988,7 @@ int su;
1147 return -ENXIO; 988 return -ENXIO;
1148 } 989 }
1149 rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort); 990 rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
1150 if (copyout((caddr_t) p->RIOPortp[PortReq.SysPort], (int) PortReq.PortP, sizeof(struct Port)) == COPYFAIL) { 991 if (copy_to_user(PortReq.PortP, p->RIOPortp[PortReq.SysPort], sizeof(struct Port))) {
1151 p->RIOError.Error = COPYOUT_FAILED; 992 p->RIOError.Error = COPYOUT_FAILED;
1152 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n"); 993 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
1153 return -EFAULT; 994 return -EFAULT;
@@ -1160,7 +1001,7 @@ int su;
1160 ** (probably for debug reasons) 1001 ** (probably for debug reasons)
1161 */ 1002 */
1162 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n"); 1003 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
1163 if (copyin((int) arg, (caddr_t) & RupReq, sizeof(RupReq)) == COPYFAIL) { 1004 if (copy_from_user(&RupReq, arg, sizeof(RupReq))) {
1164 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n"); 1005 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
1165 p->RIOError.Error = COPYIN_FAILED; 1006 p->RIOError.Error = COPYIN_FAILED;
1166 return -EFAULT; 1007 return -EFAULT;
@@ -1184,7 +1025,7 @@ int su;
1184 } 1025 }
1185 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum); 1026 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum);
1186 1027
1187 if (copyout((caddr_t) HostP->UnixRups[RupReq.RupNum].RupP, (int) RupReq.RupP, sizeof(struct RUP)) == COPYFAIL) { 1028 if (copy_to_user(HostP->UnixRups[RupReq.RupNum].RupP, RupReq.RupP, sizeof(struct RUP))) {
1188 p->RIOError.Error = COPYOUT_FAILED; 1029 p->RIOError.Error = COPYOUT_FAILED;
1189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); 1030 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
1190 return -EFAULT; 1031 return -EFAULT;
@@ -1197,7 +1038,7 @@ int su;
1197 ** (probably for debug reasons) 1038 ** (probably for debug reasons)
1198 */ 1039 */
1199 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n"); 1040 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
1200 if (copyin((int) arg, (caddr_t) & LpbReq, sizeof(LpbReq)) == COPYFAIL) { 1041 if (copy_from_user(&LpbReq, arg, sizeof(LpbReq))) {
1201 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n"); 1042 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
1202 p->RIOError.Error = COPYIN_FAILED; 1043 p->RIOError.Error = COPYIN_FAILED;
1203 return -EFAULT; 1044 return -EFAULT;
@@ -1221,7 +1062,7 @@ int su;
1221 } 1062 }
1222 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host); 1063 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host);
1223 1064
1224 if (copyout((caddr_t) & HostP->LinkStrP[LpbReq.Link], (int) LpbReq.LpbP, sizeof(struct LPB)) == COPYFAIL) { 1065 if (copy_to_user(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) {
1225 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n"); 1066 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
1226 p->RIOError.Error = COPYOUT_FAILED; 1067 p->RIOError.Error = COPYOUT_FAILED;
1227 return -EFAULT; 1068 return -EFAULT;
@@ -1252,12 +1093,13 @@ int su;
1252 p->RIOError.Error = SIGNALS_ALREADY_SET; 1093 p->RIOError.Error = SIGNALS_ALREADY_SET;
1253 return -EBUSY; 1094 return -EBUSY;
1254 } 1095 }
1255 p->RIOSignalProcess = getpid(); 1096 /* FIXME: PID tracking */
1097 p->RIOSignalProcess = current->pid;
1256 p->RIOPrintDisabled = DONT_PRINT; 1098 p->RIOPrintDisabled = DONT_PRINT;
1257 return retval; 1099 return retval;
1258 1100
1259 case RIO_SIGNALS_OFF: 1101 case RIO_SIGNALS_OFF:
1260 if (p->RIOSignalProcess != getpid()) { 1102 if (p->RIOSignalProcess != current->pid) {
1261 p->RIOError.Error = NOT_RECEIVING_PROCESS; 1103 p->RIOError.Error = NOT_RECEIVING_PROCESS;
1262 return -EPERM; 1104 return -EPERM;
1263 } 1105 }
@@ -1294,7 +1136,7 @@ int su;
1294 case RIO_MAP_B110_TO_110: 1136 case RIO_MAP_B110_TO_110:
1295 case RIO_MAP_B110_TO_115200: 1137 case RIO_MAP_B110_TO_115200:
1296 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n"); 1138 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n");
1297 port = (uint) arg; 1139 port = (unsigned long) arg;
1298 if (port < 0 || port > 511) { 1140 if (port < 0 || port > 511) {
1299 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port); 1141 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
1300 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 1142 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -1324,7 +1166,7 @@ int su;
1324 1166
1325 case RIO_SEND_PACKET: 1167 case RIO_SEND_PACKET:
1326 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n"); 1168 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
1327 if (copyin((int) arg, (caddr_t) & SendPack, sizeof(SendPack)) == COPYFAIL) { 1169 if (copy_from_user(&SendPack, arg, sizeof(SendPack))) {
1328 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n"); 1170 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
1329 p->RIOError.Error = COPYIN_FAILED; 1171 p->RIOError.Error = COPYIN_FAILED;
1330 return -EFAULT; 1172 return -EFAULT;
@@ -1344,9 +1186,9 @@ int su;
1344 } 1186 }
1345 1187
1346 for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++) 1188 for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++)
1347 WBYTE(PacketP->data[loop], SendPack.Data[loop]); 1189 writeb(SendPack.Data[loop], &PacketP->data[loop]);
1348 1190
1349 WBYTE(PacketP->len, SendPack.Len); 1191 writeb(SendPack.Len, &PacketP->len);
1350 1192
1351 add_transmit(PortP); 1193 add_transmit(PortP);
1352 /* 1194 /*
@@ -1368,7 +1210,7 @@ int su;
1368 return su ? 0 : -EPERM; 1210 return su ? 0 : -EPERM;
1369 1211
1370 case RIO_WHAT_MESG: 1212 case RIO_WHAT_MESG:
1371 if (copyout((caddr_t) & p->RIONoMessage, (int) arg, sizeof(p->RIONoMessage)) == COPYFAIL) { 1213 if (copy_to_user(arg, &p->RIONoMessage, sizeof(p->RIONoMessage))) {
1372 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n"); 1214 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
1373 p->RIOError.Error = COPYOUT_FAILED; 1215 p->RIOError.Error = COPYOUT_FAILED;
1374 return -EFAULT; 1216 return -EFAULT;
@@ -1376,7 +1218,7 @@ int su;
1376 return 0; 1218 return 0;
1377 1219
1378 case RIO_MEM_DUMP: 1220 case RIO_MEM_DUMP:
1379 if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) { 1221 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
1380 p->RIOError.Error = COPYIN_FAILED; 1222 p->RIOError.Error = COPYIN_FAILED;
1381 return -EFAULT; 1223 return -EFAULT;
1382 } 1224 }
@@ -1406,7 +1248,7 @@ int su;
1406 PortP->State |= RIO_BUSY; 1248 PortP->State |= RIO_BUSY;
1407 1249
1408 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1250 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1409 if (copyout((caddr_t) p->RIOMemDump, (int) arg, MEMDUMP_SIZE) == COPYFAIL) { 1251 if (copy_to_user(arg, p->RIOMemDump, MEMDUMP_SIZE)) {
1410 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n"); 1252 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
1411 p->RIOError.Error = COPYOUT_FAILED; 1253 p->RIOError.Error = COPYOUT_FAILED;
1412 return -EFAULT; 1254 return -EFAULT;
@@ -1414,30 +1256,30 @@ int su;
1414 return 0; 1256 return 0;
1415 1257
1416 case RIO_TICK: 1258 case RIO_TICK:
1417 if ((int) arg < 0 || (int) arg >= p->RIONumHosts) 1259 if ((unsigned long) arg >= p->RIONumHosts)
1418 return -EINVAL; 1260 return -EINVAL;
1419 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int) arg); 1261 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", (unsigned long) arg);
1420 WBYTE(p->RIOHosts[(int) arg].SetInt, 0xff); 1262 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].SetInt);
1421 return 0; 1263 return 0;
1422 1264
1423 case RIO_TOCK: 1265 case RIO_TOCK:
1424 if ((int) arg < 0 || (int) arg >= p->RIONumHosts) 1266 if ((unsigned long) arg >= p->RIONumHosts)
1425 return -EINVAL; 1267 return -EINVAL;
1426 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int) arg); 1268 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", (unsigned long) arg);
1427 WBYTE((p->RIOHosts[(int) arg].ResetInt), 0xff); 1269 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].ResetInt);
1428 return 0; 1270 return 0;
1429 1271
1430 case RIO_READ_CHECK: 1272 case RIO_READ_CHECK:
1431 /* Check reads for pkts with data[0] the same */ 1273 /* Check reads for pkts with data[0] the same */
1432 p->RIOReadCheck = !p->RIOReadCheck; 1274 p->RIOReadCheck = !p->RIOReadCheck;
1433 if (copyout((caddr_t) & p->RIOReadCheck, (int) arg, sizeof(uint)) == COPYFAIL) { 1275 if (copy_to_user(arg, &p->RIOReadCheck, sizeof(unsigned int))) {
1434 p->RIOError.Error = COPYOUT_FAILED; 1276 p->RIOError.Error = COPYOUT_FAILED;
1435 return -EFAULT; 1277 return -EFAULT;
1436 } 1278 }
1437 return 0; 1279 return 0;
1438 1280
1439 case RIO_READ_REGISTER: 1281 case RIO_READ_REGISTER:
1440 if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) { 1282 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
1441 p->RIOError.Error = COPYIN_FAILED; 1283 p->RIOError.Error = COPYIN_FAILED;
1442 return -EFAULT; 1284 return -EFAULT;
1443 } 1285 }
@@ -1472,7 +1314,7 @@ int su;
1472 PortP->State |= RIO_BUSY; 1314 PortP->State |= RIO_BUSY;
1473 1315
1474 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1316 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1475 if (copyout((caddr_t) & p->CdRegister, (int) arg, sizeof(uint)) == COPYFAIL) { 1317 if (copy_to_user(arg, &p->CdRegister, sizeof(unsigned int))) {
1476 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n"); 1318 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
1477 p->RIOError.Error = COPYOUT_FAILED; 1319 p->RIOError.Error = COPYOUT_FAILED;
1478 return -EFAULT; 1320 return -EFAULT;
@@ -1485,21 +1327,22 @@ int su;
1485 */ 1327 */
1486 case RIO_MAKE_DEV: 1328 case RIO_MAKE_DEV:
1487 { 1329 {
1488 uint port = (uint) arg & RIO_MODEM_MASK; 1330 unsigned int port = (unsigned long) arg & RIO_MODEM_MASK;
1331 unsigned int ret;
1489 1332
1490 switch ((uint) arg & RIO_DEV_MASK) { 1333 switch ((unsigned long) arg & RIO_DEV_MASK) {
1491 case RIO_DEV_DIRECT: 1334 case RIO_DEV_DIRECT:
1492 arg = (caddr_t) drv_makedev(MAJOR(dev), port); 1335 ret = drv_makedev(MAJOR(dev), port);
1493 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, (int) arg); 1336 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret);
1494 return (int) arg; 1337 return ret;
1495 case RIO_DEV_MODEM: 1338 case RIO_DEV_MODEM:
1496 arg = (caddr_t) drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT)); 1339 ret = drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT));
1497 rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, (int) arg); 1340 rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, ret);
1498 return (int) arg; 1341 return ret;
1499 case RIO_DEV_XPRINT: 1342 case RIO_DEV_XPRINT:
1500 arg = (caddr_t) drv_makedev(MAJOR(dev), port); 1343 ret = drv_makedev(MAJOR(dev), port);
1501 rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, (int) arg); 1344 rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, ret);
1502 return (int) arg; 1345 return ret;
1503 } 1346 }
1504 rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n"); 1347 rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n");
1505 return -EINVAL; 1348 return -EINVAL;
@@ -1513,18 +1356,19 @@ int su;
1513 { 1356 {
1514 dev_t dv; 1357 dev_t dv;
1515 int mino; 1358 int mino;
1359 unsigned long ret;
1516 1360
1517 dv = (dev_t) ((int) arg); 1361 dv = (dev_t) ((unsigned long) arg);
1518 mino = RIO_UNMODEM(dv); 1362 mino = RIO_UNMODEM(dv);
1519 1363
1520 if (RIO_ISMODEM(dv)) { 1364 if (RIO_ISMODEM(dv)) {
1521 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino); 1365 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino);
1522 arg = (caddr_t) (mino | RIO_DEV_MODEM); 1366 ret = mino | RIO_DEV_MODEM;
1523 } else { 1367 } else {
1524 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino); 1368 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino);
1525 arg = (caddr_t) (mino | RIO_DEV_DIRECT); 1369 ret = mino | RIO_DEV_DIRECT;
1526 } 1370 }
1527 return (int) arg; 1371 return ret;
1528 } 1372 }
1529 } 1373 }
1530 rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd); 1374 rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd);
@@ -1537,10 +1381,7 @@ int su;
1537/* 1381/*
1538** Pre-emptive commands go on RUPs and are only one byte long. 1382** Pre-emptive commands go on RUPs and are only one byte long.
1539*/ 1383*/
1540int RIOPreemptiveCmd(p, PortP, Cmd) 1384int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
1541struct rio_info *p;
1542struct Port *PortP;
1543uchar Cmd;
1544{ 1385{
1545 struct CmdBlk *CmdBlkP; 1386 struct CmdBlk *CmdBlkP;
1546 struct PktCmd_M *PktCmdP; 1387 struct PktCmd_M *PktCmdP;
@@ -1558,7 +1399,7 @@ uchar Cmd;
1558 return RIO_FAIL; 1399 return RIO_FAIL;
1559 } 1400 }
1560 1401
1561 rio_dprintk(RIO_DEBUG_CTRL, "Command blk 0x%x - InUse now %d\n", (int) CmdBlkP, PortP->InUse); 1402 rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", CmdBlkP, PortP->InUse);
1562 1403
1563 PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0]; 1404 PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0];
1564 1405
@@ -1572,7 +1413,7 @@ uchar Cmd;
1572 CmdBlkP->Packet.dest_port = COMMAND_RUP; 1413 CmdBlkP->Packet.dest_port = COMMAND_RUP;
1573 CmdBlkP->Packet.len = PKT_CMD_BIT | 2; 1414 CmdBlkP->Packet.len = PKT_CMD_BIT | 2;
1574 CmdBlkP->PostFuncP = RIOUnUse; 1415 CmdBlkP->PostFuncP = RIOUnUse;
1575 CmdBlkP->PostArg = (int) PortP; 1416 CmdBlkP->PostArg = (unsigned long) PortP;
1576 PktCmdP->Command = Cmd; 1417 PktCmdP->Command = Cmd;
1577 port = PortP->HostPort % (ushort) PORTS_PER_RTA; 1418 port = PortP->HostPort % (ushort) PORTS_PER_RTA;
1578 /* 1419 /*
@@ -1584,38 +1425,38 @@ uchar Cmd;
1584 1425
1585 switch (Cmd) { 1426 switch (Cmd) {
1586 case MEMDUMP: 1427 case MEMDUMP:
1587 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n", (int) CmdBlkP, (int) SubCmd.Addr); 1428 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p (addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
1588 PktCmdP->SubCommand = MEMDUMP; 1429 PktCmdP->SubCommand = MEMDUMP;
1589 PktCmdP->SubAddr = SubCmd.Addr; 1430 PktCmdP->SubAddr = SubCmd.Addr;
1590 break; 1431 break;
1591 case FCLOSE: 1432 case FCLOSE:
1592 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk 0x%x\n", (int) CmdBlkP); 1433 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", CmdBlkP);
1593 break; 1434 break;
1594 case READ_REGISTER: 1435 case READ_REGISTER:
1595 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk 0x%x\n", (int) SubCmd.Addr, (int) CmdBlkP); 1436 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
1596 PktCmdP->SubCommand = READ_REGISTER; 1437 PktCmdP->SubCommand = READ_REGISTER;
1597 PktCmdP->SubAddr = SubCmd.Addr; 1438 PktCmdP->SubAddr = SubCmd.Addr;
1598 break; 1439 break;
1599 case RESUME: 1440 case RESUME:
1600 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk 0x%x\n", (int) CmdBlkP); 1441 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", CmdBlkP);
1601 break; 1442 break;
1602 case RFLUSH: 1443 case RFLUSH:
1603 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk 0x%x\n", (int) CmdBlkP); 1444 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", CmdBlkP);
1604 CmdBlkP->PostFuncP = RIORFlushEnable; 1445 CmdBlkP->PostFuncP = RIORFlushEnable;
1605 break; 1446 break;
1606 case SUSPEND: 1447 case SUSPEND:
1607 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk 0x%x\n", (int) CmdBlkP); 1448 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", CmdBlkP);
1608 break; 1449 break;
1609 1450
1610 case MGET: 1451 case MGET:
1611 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk 0x%x\n", (int) CmdBlkP); 1452 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", CmdBlkP);
1612 break; 1453 break;
1613 1454
1614 case MSET: 1455 case MSET:
1615 case MBIC: 1456 case MBIC:
1616 case MBIS: 1457 case MBIS:
1617 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines; 1458 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
1618 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int) CmdBlkP); 1459 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk %p\n", CmdBlkP);
1619 break; 1460 break;
1620 1461
1621 case WFLUSH: 1462 case WFLUSH:
@@ -1629,7 +1470,7 @@ uchar Cmd;
1629 RIOFreeCmdBlk(CmdBlkP); 1470 RIOFreeCmdBlk(CmdBlkP);
1630 return (RIO_FAIL); 1471 return (RIO_FAIL);
1631 } else { 1472 } else {
1632 rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk 0x%x\n", (int) CmdBlkP); 1473 rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk %p\n", CmdBlkP);
1633 CmdBlkP->PostFuncP = RIOWFlushMark; 1474 CmdBlkP->PostFuncP = RIOWFlushMark;
1634 } 1475 }
1635 break; 1476 break;
diff --git a/drivers/char/rio/riodrvr.h b/drivers/char/rio/riodrvr.h
index 663ee0914ed7..3cffe275f216 100644
--- a/drivers/char/rio/riodrvr.h
+++ b/drivers/char/rio/riodrvr.h
@@ -72,42 +72,42 @@ struct rio_info {
72*/ 72*/
73 int RIOHalted; /* halted ? */ 73 int RIOHalted; /* halted ? */
74 int RIORtaDisCons; /* RTA connections/disconnections */ 74 int RIORtaDisCons; /* RTA connections/disconnections */
75 uint RIOReadCheck; /* Rio read check */ 75 unsigned int RIOReadCheck; /* Rio read check */
76 uint RIONoMessage; /* To display message or not */ 76 unsigned int RIONoMessage; /* To display message or not */
77 uint RIONumBootPkts; /* how many packets for an RTA */ 77 unsigned int RIONumBootPkts; /* how many packets for an RTA */
78 uint RIOBootCount; /* size of RTA code */ 78 unsigned int RIOBootCount; /* size of RTA code */
79 uint RIOBooting; /* count of outstanding boots */ 79 unsigned int RIOBooting; /* count of outstanding boots */
80 uint RIOSystemUp; /* Booted ?? */ 80 unsigned int RIOSystemUp; /* Booted ?? */
81 uint RIOCounting; /* for counting interrupts */ 81 unsigned int RIOCounting; /* for counting interrupts */
82 uint RIOIntCount; /* # of intr since last check */ 82 unsigned int RIOIntCount; /* # of intr since last check */
83 uint RIOTxCount; /* number of xmit intrs */ 83 unsigned int RIOTxCount; /* number of xmit intrs */
84 uint RIORxCount; /* number of rx intrs */ 84 unsigned int RIORxCount; /* number of rx intrs */
85 uint RIORupCount; /* number of rup intrs */ 85 unsigned int RIORupCount; /* number of rup intrs */
86 int RIXTimer; 86 int RIXTimer;
87 int RIOBufferSize; /* Buffersize */ 87 int RIOBufferSize; /* Buffersize */
88 int RIOBufferMask; /* Buffersize */ 88 int RIOBufferMask; /* Buffersize */
89 89
90 int RIOFirstMajor; /* First host card's major no */ 90 int RIOFirstMajor; /* First host card's major no */
91 91
92 uint RIOLastPortsMapped; /* highest port number known */ 92 unsigned int RIOLastPortsMapped; /* highest port number known */
93 uint RIOFirstPortsMapped; /* lowest port number known */ 93 unsigned int RIOFirstPortsMapped; /* lowest port number known */
94 94
95 uint RIOLastPortsBooted; /* highest port number running */ 95 unsigned int RIOLastPortsBooted; /* highest port number running */
96 uint RIOFirstPortsBooted; /* lowest port number running */ 96 unsigned int RIOFirstPortsBooted; /* lowest port number running */
97 97
98 uint RIOLastPortsOpened; /* highest port number running */ 98 unsigned int RIOLastPortsOpened; /* highest port number running */
99 uint RIOFirstPortsOpened; /* lowest port number running */ 99 unsigned int RIOFirstPortsOpened; /* lowest port number running */
100 100
101 /* Flag to say that the topology information has been changed. */ 101 /* Flag to say that the topology information has been changed. */
102 uint RIOQuickCheck; 102 unsigned int RIOQuickCheck;
103 uint CdRegister; /* ??? */ 103 unsigned int CdRegister; /* ??? */
104 int RIOSignalProcess; /* Signalling process */ 104 int RIOSignalProcess; /* Signalling process */
105 int rio_debug; /* To debug ... */ 105 int rio_debug; /* To debug ... */
106 int RIODebugWait; /* For what ??? */ 106 int RIODebugWait; /* For what ??? */
107 int tpri; /* Thread prio */ 107 int tpri; /* Thread prio */
108 int tid; /* Thread id */ 108 int tid; /* Thread id */
109 uint _RIO_Polled; /* Counter for polling */ 109 unsigned int _RIO_Polled; /* Counter for polling */
110 uint _RIO_Interrupted; /* Counter for interrupt */ 110 unsigned int _RIO_Interrupted; /* Counter for interrupt */
111 int intr_tid; /* iointset return value */ 111 int intr_tid; /* iointset return value */
112 int TxEnSem; /* TxEnable Semaphore */ 112 int TxEnSem; /* TxEnable Semaphore */
113 113
@@ -121,9 +121,9 @@ struct rio_info {
121 struct Map RIOSavedTable[TOTAL_MAP_ENTRIES]; 121 struct Map RIOSavedTable[TOTAL_MAP_ENTRIES];
122 122
123 /* RTA to host binding table for master/slave operation */ 123 /* RTA to host binding table for master/slave operation */
124 ulong RIOBindTab[MAX_RTA_BINDINGS]; 124 unsigned long RIOBindTab[MAX_RTA_BINDINGS];
125 /* RTA memory dump variable */ 125 /* RTA memory dump variable */
126 uchar RIOMemDump[MEMDUMP_SIZE]; 126 unsigned char RIOMemDump[MEMDUMP_SIZE];
127 struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES]; 127 struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES];
128 128
129}; 129};
@@ -138,7 +138,5 @@ struct rio_info {
138 138
139 139
140#define RIO_RESET_INT 0x7d80 140#define RIO_RESET_INT 0x7d80
141#define WRBYTE(x,y) *(volatile unsigned char *)((x)) = \
142 (unsigned char)(y)
143 141
144#endif /* __riodrvr.h */ 142#endif /* __riodrvr.h */
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 0d44ef464e6b..24d2992154cc 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";
51 51
52 52
53#include "linux_compat.h" 53#include "linux_compat.h"
54#include "typdef.h"
55#include "pkt.h" 54#include "pkt.h"
56#include "daemon.h" 55#include "daemon.h"
57#include "rio.h" 56#include "rio.h"
58#include "riospace.h" 57#include "riospace.h"
59#include "top.h"
60#include "cmdpkt.h" 58#include "cmdpkt.h"
61#include "map.h" 59#include "map.h"
62#include "riotypes.h"
63#include "rup.h" 60#include "rup.h"
64#include "port.h" 61#include "port.h"
65#include "riodrvr.h" 62#include "riodrvr.h"
@@ -72,22 +69,17 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
72#include "unixrup.h" 69#include "unixrup.h"
73#include "board.h" 70#include "board.h"
74#include "host.h" 71#include "host.h"
75#include "error.h"
76#include "phb.h" 72#include "phb.h"
77#include "link.h" 73#include "link.h"
78#include "cmdblk.h" 74#include "cmdblk.h"
79#include "route.h" 75#include "route.h"
80#include "control.h"
81#include "cirrus.h" 76#include "cirrus.h"
82#include "rioioctl.h" 77#include "rioioctl.h"
83#include "rio_linux.h" 78#include "rio_linux.h"
84 79
85#undef bcopy
86#define bcopy rio_pcicopy
87
88int RIOPCIinit(struct rio_info *p, int Mode); 80int RIOPCIinit(struct rio_info *p, int Mode);
89 81
90static int RIOScrub(int, BYTE *, int); 82static int RIOScrub(int, u8 *, int);
91 83
92 84
93/** 85/**
@@ -99,12 +91,8 @@ static int RIOScrub(int, BYTE *, int);
99** bits < 0 indicates 8 bit operation requested, 91** bits < 0 indicates 8 bit operation requested,
100** bits > 0 indicates 16 bit operation. 92** bits > 0 indicates 16 bit operation.
101*/ 93*/
102int 94
103RIOAssignAT(p, Base, virtAddr, mode) 95int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode)
104struct rio_info * p;
105int Base;
106caddr_t virtAddr;
107int mode;
108{ 96{
109 int bits; 97 int bits;
110 struct DpRam *cardp = (struct DpRam *)virtAddr; 98 struct DpRam *cardp = (struct DpRam *)virtAddr;
@@ -124,29 +112,25 @@ int mode;
124 /* 112 /*
125 ** Revision 01 AT host cards don't support WORD operations, 113 ** Revision 01 AT host cards don't support WORD operations,
126 */ 114 */
127 if ( RBYTE(cardp->DpRevision) == 01 ) 115 if (readb(&cardp->DpRevision) == 01)
128 bits = BYTE_OPERATION; 116 bits = BYTE_OPERATION;
129 117
130 p->RIOHosts[p->RIONumHosts].Type = RIO_AT; 118 p->RIOHosts[p->RIONumHosts].Type = RIO_AT;
131 p->RIOHosts[p->RIONumHosts].Copy = bcopy; 119 p->RIOHosts[p->RIONumHosts].Copy = rio_copy_to_card;
132 /* set this later */ 120 /* set this later */
133 p->RIOHosts[p->RIONumHosts].Slot = -1; 121 p->RIOHosts[p->RIONumHosts].Slot = -1;
134 p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits; 122 p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits;
135 WBYTE(p->RIOHosts[p->RIONumHosts].Control, 123 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE ,
136 BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 124 &p->RIOHosts[p->RIONumHosts].Control);
137 p->RIOHosts[p->RIONumHosts].Mode | 125 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
138 INTERRUPT_DISABLE ); 126 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE,
139 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff); 127 &p->RIOHosts[p->RIONumHosts].Control);
140 WBYTE(p->RIOHosts[p->RIONumHosts].Control, 128 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
141 BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
142 p->RIOHosts[p->RIONumHosts].Mode |
143 INTERRUPT_DISABLE );
144 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);
145 p->RIOHosts[p->RIONumHosts].UniqueNum = 129 p->RIOHosts[p->RIONumHosts].UniqueNum =
146 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)| 130 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|
147 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)| 131 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|
148 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)| 132 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|
149 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24); 133 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);
150 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum); 134 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum);
151 135
152 p->RIONumHosts++; 136 p->RIONumHosts++;
@@ -154,7 +138,7 @@ int mode;
154 return(1); 138 return(1);
155} 139}
156 140
157static uchar val[] = { 141static u8 val[] = {
158#ifdef VERY_LONG_TEST 142#ifdef VERY_LONG_TEST
159 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 143 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
160 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36, 144 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36,
@@ -167,12 +151,7 @@ static uchar val[] = {
167** RAM test a board. 151** RAM test a board.
168** Nothing too complicated, just enough to check it out. 152** Nothing too complicated, just enough to check it out.
169*/ 153*/
170int 154int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slot)
171RIOBoardTest(paddr, caddr, type, slot)
172paddr_t paddr;
173caddr_t caddr;
174uchar type;
175int slot;
176{ 155{
177 struct DpRam *DpRam = (struct DpRam *)caddr; 156 struct DpRam *DpRam = (struct DpRam *)caddr;
178 char *ram[4]; 157 char *ram[4];
@@ -180,8 +159,8 @@ int slot;
180 int op, bank; 159 int op, bank;
181 int nbanks; 160 int nbanks;
182 161
183 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=0x%x, slot=%d\n", 162 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=%p, slot=%d\n",
184 type,(int)DpRam, slot); 163 type, DpRam, slot);
185 164
186 RIOHostReset(type, DpRam, slot); 165 RIOHostReset(type, DpRam, slot);
187 166
@@ -209,12 +188,11 @@ int slot;
209 188
210 189
211 if (nbanks == 3) { 190 if (nbanks == 3) {
212 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n", 191 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: %p(0x%x), %p(0x%x), %p(0x%x)\n",
213 (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2]); 192 ram[0], size[0], ram[1], size[1], ram[2], size[2]);
214 } else { 193 } else {
215 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n", 194 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: %p(0x%x), %p(0x%x), %p(0x%x), %p(0x%x)\n",
216 (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2], (int)ram[3], 195 ram[0], size[0], ram[1], size[1], ram[2], size[2], ram[3], size[3]);
217 size[3]);
218 } 196 }
219 197
220 /* 198 /*
@@ -224,7 +202,7 @@ int slot;
224 */ 202 */
225 for (op=0; op<TEST_END; op++) { 203 for (op=0; op<TEST_END; op++) {
226 for (bank=0; bank<nbanks; bank++) { 204 for (bank=0; bank<nbanks; bank++) {
227 if (RIOScrub(op, (BYTE *)ram[bank], size[bank]) == RIO_FAIL) { 205 if (RIOScrub(op, (u8 *)ram[bank], size[bank]) == RIO_FAIL) {
228 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n", 206 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n",
229 bank, op); 207 bank, op);
230 return RIO_FAIL; 208 return RIO_FAIL;
@@ -233,7 +211,7 @@ int slot;
233 } 211 }
234 212
235 rio_dprintk (RIO_DEBUG_INIT, "Test completed\n"); 213 rio_dprintk (RIO_DEBUG_INIT, "Test completed\n");
236 return RIO_SUCCESS; 214 return 0;
237} 215}
238 216
239 217
@@ -248,13 +226,10 @@ int slot;
248** Call with op not zero, and the RAM will be read and compated with val[op-1] 226** Call with op not zero, and the RAM will be read and compated with val[op-1]
249** to check that the data from the previous phase was retained. 227** to check that the data from the previous phase was retained.
250*/ 228*/
251static int 229
252RIOScrub(op, ram, size) 230static int RIOScrub(int op, u8 *ram, int size)
253int op;
254BYTE * ram;
255int size;
256{ 231{
257 int off; 232 int off;
258 unsigned char oldbyte; 233 unsigned char oldbyte;
259 unsigned char newbyte; 234 unsigned char newbyte;
260 unsigned char invbyte; 235 unsigned char invbyte;
@@ -279,15 +254,15 @@ int size;
279 */ 254 */
280 if (op) { 255 if (op) {
281 for (off=0; off<size; off++) { 256 for (off=0; off<size; off++) {
282 if (RBYTE(ram[off]) != oldbyte) { 257 if (readb(ram + off) != oldbyte) {
283 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])); 258 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));
284 return RIO_FAIL; 259 return RIO_FAIL;
285 } 260 }
286 } 261 }
287 for (off=0; off<size; off+=2) { 262 for (off=0; off<size; off+=2) {
288 if (*(ushort *)&ram[off] != oldword) { 263 if (readw(ram + off) != oldword) {
289 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]); 264 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));
290 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])); 265 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));
291 return RIO_FAIL; 266 return RIO_FAIL;
292 } 267 }
293 } 268 }
@@ -301,13 +276,13 @@ int size;
301 ** the BYTE read/write test. 276 ** the BYTE read/write test.
302 */ 277 */
303 for (off=0; off<size; off++) { 278 for (off=0; off<size; off++) {
304 if (op && (RBYTE(ram[off]) != oldbyte)) { 279 if (op && (readb(ram + off) != oldbyte)) {
305 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])); 280 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));
306 return RIO_FAIL; 281 return RIO_FAIL;
307 } 282 }
308 WBYTE(ram[off],invbyte); 283 writeb(invbyte, ram + off);
309 if (RBYTE(ram[off]) != invbyte) { 284 if (readb(ram + off) != invbyte) {
310 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])); 285 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));
311 return RIO_FAIL; 286 return RIO_FAIL;
312 } 287 }
313 } 288 }
@@ -320,16 +295,16 @@ int size;
320 ** This is the WORD operation test. 295 ** This is the WORD operation test.
321 */ 296 */
322 for (off=0; off<size; off+=2) { 297 for (off=0; off<size; off+=2) {
323 if (*(ushort *)&ram[off] != invword) { 298 if (readw(ram + off) != invword) {
324 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]); 299 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));
325 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])); 300 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));
326 return RIO_FAIL; 301 return RIO_FAIL;
327 } 302 }
328 303
329 *(ushort *)&ram[off] = newword; 304 writew(newword, ram + off);
330 if ( *(ushort *)&ram[off] != newword ) { 305 if ( readw(ram + off) != newword ) {
331 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]); 306 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));
332 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])); 307 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));
333 return RIO_FAIL; 308 return RIO_FAIL;
334 } 309 }
335 } 310 }
@@ -340,16 +315,16 @@ int size;
340 ** required test data. 315 ** required test data.
341 */ 316 */
342 for (off=0; off<size; off++) { 317 for (off=0; off<size; off++) {
343 if (RBYTE(ram[off]) != newbyte) { 318 if (readb(ram + off) != newbyte) {
344 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])); 319 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));
345 return RIO_FAIL; 320 return RIO_FAIL;
346 } 321 }
347 } 322 }
348 323
349 for (off=0; off<size; off+=2) { 324 for (off=0; off<size; off+=2) {
350 if ( *(ushort *)&ram[off] != newword ) { 325 if (readw(ram + off) != newword ) {
351 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]); 326 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));
352 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])); 327 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));
353 return RIO_FAIL; 328 return RIO_FAIL;
354 } 329 }
355 } 330 }
@@ -360,41 +335,37 @@ int size;
360 swapword = invbyte | (newbyte << 8); 335 swapword = invbyte | (newbyte << 8);
361 336
362 for (off=0; off<size; off+=2) { 337 for (off=0; off<size; off+=2) {
363 WBYTE(ram[off],invbyte); 338 writeb(invbyte, &ram[off]);
364 WBYTE(ram[off+1],newbyte); 339 writeb(newbyte, &ram[off+1]);
365 } 340 }
366 341
367 for ( off=0; off<size; off+=2 ) { 342 for ( off=0; off<size; off+=2 ) {
368 if (*(ushort *)&ram[off] != swapword) { 343 if (readw(ram + off) != swapword) {
369 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])); 344 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));
370 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])); 345 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));
371 return RIO_FAIL; 346 return RIO_FAIL;
372 } 347 }
373 *((ushort *)&ram[off]) = ~swapword; 348 writew(~swapword, ram + off);
374 } 349 }
375 350
376 for (off=0; off<size; off+=2) { 351 for (off=0; off<size; off+=2) {
377 if (RBYTE(ram[off]) != newbyte) { 352 if (readb(ram + off) != newbyte) {
378 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])); 353 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));
379 return RIO_FAIL; 354 return RIO_FAIL;
380 } 355 }
381 if (RBYTE(ram[off+1]) != invbyte) { 356 if (readb(ram + off + 1) != invbyte) {
382 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])); 357 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));
383 return RIO_FAIL; 358 return RIO_FAIL;
384 } 359 }
385 *((ushort *)&ram[off]) = newword; 360 writew(newword, ram + off);
386 } 361 }
387 return RIO_SUCCESS; 362 return 0;
388} 363}
389 364
390 365
391int 366int RIODefaultName(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
392RIODefaultName(p, HostP, UnitId)
393struct rio_info * p;
394struct Host * HostP;
395uint UnitId;
396{ 367{
397 bcopy("UNKNOWN RTA X-XX",HostP->Mapping[UnitId].Name,17); 368 memcpy(HostP->Mapping[UnitId].Name, "UNKNOWN RTA X-XX", 17);
398 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts); 369 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts);
399 if ((UnitId+1) > 9) { 370 if ((UnitId+1) > 9) {
400 HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10); 371 HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10);
@@ -412,8 +383,7 @@ uint UnitId;
412 383
413static struct rioVersion stVersion; 384static struct rioVersion stVersion;
414 385
415struct rioVersion * 386struct rioVersion *RIOVersid(void)
416RIOVersid(void)
417{ 387{
418 strlcpy(stVersion.version, "RIO driver for linux V1.0", 388 strlcpy(stVersion.version, "RIO driver for linux V1.0",
419 sizeof(stVersion.version)); 389 sizeof(stVersion.version));
@@ -423,40 +393,31 @@ RIOVersid(void)
423 return &stVersion; 393 return &stVersion;
424} 394}
425 395
426void 396void RIOHostReset(unsigned int Type, struct DpRam *DpRamP, unsigned int Slot)
427RIOHostReset(Type, DpRamP, Slot)
428uint Type;
429volatile struct DpRam *DpRamP;
430uint Slot;
431{ 397{
432 /* 398 /*
433 ** Reset the Tpu 399 ** Reset the Tpu
434 */ 400 */
435 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type); 401 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type);
436 switch ( Type ) { 402 switch ( Type ) {
437 case RIO_AT: 403 case RIO_AT:
438 rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n"); 404 rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n");
439 WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 405 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE | BYTE_OPERATION |
440 INTERRUPT_DISABLE | BYTE_OPERATION | 406 SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
441 SLOW_LINKS | SLOW_AT_BUS); 407 writeb(0xFF, &DpRamP->DpResetTpu);
442 WBYTE(DpRamP->DpResetTpu, 0xFF); 408 udelay(3);
443 udelay(3);
444
445 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n"); 409 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n");
446 WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 410 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE |
447 INTERRUPT_DISABLE | BYTE_OPERATION | 411 BYTE_OPERATION | SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
448 SLOW_LINKS | SLOW_AT_BUS); 412 writeb(0xFF, &DpRamP->DpResetTpu);
449 WBYTE(DpRamP->DpResetTpu, 0xFF); 413 udelay(3);
450 udelay(3); 414 break;
451 break;
452 case RIO_PCI: 415 case RIO_PCI:
453 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n"); 416 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n");
454 DpRamP->DpControl = RIO_PCI_BOOT_FROM_RAM; 417 writeb(RIO_PCI_BOOT_FROM_RAM, &DpRamP->DpControl);
455 DpRamP->DpResetInt = 0xFF; 418 writeb(0xFF, &DpRamP->DpResetInt);
456 DpRamP->DpResetTpu = 0xFF; 419 writeb(0xFF, &DpRamP->DpResetTpu);
457 udelay(100); 420 udelay(100);
458 /* for (i=0; i<6000; i++); */
459 /* suspend( 3 ); */
460 break; 421 break;
461 default: 422 default:
462 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n"); 423 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n");
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 34d8787557a1..97f0fa550652 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";
54 54
55#include "linux_compat.h" 55#include "linux_compat.h"
56#include "rio_linux.h" 56#include "rio_linux.h"
57#include "typdef.h"
58#include "pkt.h" 57#include "pkt.h"
59#include "daemon.h" 58#include "daemon.h"
60#include "rio.h" 59#include "rio.h"
61#include "riospace.h" 60#include "riospace.h"
62#include "top.h"
63#include "cmdpkt.h" 61#include "cmdpkt.h"
64#include "map.h" 62#include "map.h"
65#include "riotypes.h"
66#include "rup.h" 63#include "rup.h"
67#include "port.h" 64#include "port.h"
68#include "riodrvr.h" 65#include "riodrvr.h"
@@ -75,12 +72,10 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
75#include "unixrup.h" 72#include "unixrup.h"
76#include "board.h" 73#include "board.h"
77#include "host.h" 74#include "host.h"
78#include "error.h"
79#include "phb.h" 75#include "phb.h"
80#include "link.h" 76#include "link.h"
81#include "cmdblk.h" 77#include "cmdblk.h"
82#include "route.h" 78#include "route.h"
83#include "control.h"
84#include "cirrus.h" 79#include "cirrus.h"
85#include "rioioctl.h" 80#include "rioioctl.h"
86 81
@@ -101,8 +96,7 @@ static char *firstchars(char *p, int nch)
101 96
102#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) 97#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
103/* Enable and start the transmission of packets */ 98/* Enable and start the transmission of packets */
104void RIOTxEnable(en) 99void RIOTxEnable(char *en)
105char *en;
106{ 100{
107 struct Port *PortP; 101 struct Port *PortP;
108 struct rio_info *p; 102 struct rio_info *p;
@@ -186,10 +180,8 @@ char *en;
186static int RupIntr; 180static int RupIntr;
187static int RxIntr; 181static int RxIntr;
188static int TxIntr; 182static int TxIntr;
189void RIOServiceHost(p, HostP, From) 183
190struct rio_info *p; 184void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
191struct Host *HostP;
192int From;
193{ 185{
194 rio_spin_lock(&HostP->HostLock); 186 rio_spin_lock(&HostP->HostLock);
195 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { 187 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
@@ -201,22 +193,22 @@ int From;
201 } 193 }
202 rio_spin_unlock(&HostP->HostLock); 194 rio_spin_unlock(&HostP->HostLock);
203 195
204 if (RWORD(HostP->ParmMapP->rup_intr)) { 196 if (readw(&HostP->ParmMapP->rup_intr)) {
205 WWORD(HostP->ParmMapP->rup_intr, 0); 197 writew(0, &HostP->ParmMapP->rup_intr);
206 p->RIORupCount++; 198 p->RIORupCount++;
207 RupIntr++; 199 RupIntr++;
208 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP - p->RIOHosts); 200 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts);
209 RIOPollHostCommands(p, HostP); 201 RIOPollHostCommands(p, HostP);
210 } 202 }
211 203
212 if (RWORD(HostP->ParmMapP->rx_intr)) { 204 if (readw(&HostP->ParmMapP->rx_intr)) {
213 int port; 205 int port;
214 206
215 WWORD(HostP->ParmMapP->rx_intr, 0); 207 writew(0, &HostP->ParmMapP->rx_intr);
216 p->RIORxCount++; 208 p->RIORxCount++;
217 RxIntr++; 209 RxIntr++;
218 210
219 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP - p->RIOHosts); 211 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts);
220 /* 212 /*
221 ** Loop through every port. If the port is mapped into 213 ** Loop through every port. If the port is mapped into
222 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is 214 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
@@ -277,26 +269,26 @@ int From;
277 ** it's handshake bit is set, then we must clear the handshake, 269 ** it's handshake bit is set, then we must clear the handshake,
278 ** so that that downstream RTA is re-enabled. 270 ** so that that downstream RTA is re-enabled.
279 */ 271 */
280 if (!can_remove_receive(&PacketP, PortP) && (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { 272 if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
281 /* 273 /*
282 ** MAGIC! ( Basically, handshake the RX buffer, so that 274 ** MAGIC! ( Basically, handshake the RX buffer, so that
283 ** the RTAs upstream can be re-enabled. ) 275 ** the RTAs upstream can be re-enabled. )
284 */ 276 */
285 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); 277 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
286 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 278 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
287 } 279 }
288 rio_spin_unlock(&PortP->portSem); 280 rio_spin_unlock(&PortP->portSem);
289 } 281 }
290 } 282 }
291 283
292 if (RWORD(HostP->ParmMapP->tx_intr)) { 284 if (readw(&HostP->ParmMapP->tx_intr)) {
293 int port; 285 int port;
294 286
295 WWORD(HostP->ParmMapP->tx_intr, 0); 287 writew(0, &HostP->ParmMapP->tx_intr);
296 288
297 p->RIOTxCount++; 289 p->RIOTxCount++;
298 TxIntr++; 290 TxIntr++;
299 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP - p->RIOHosts); 291 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts);
300 292
301 /* 293 /*
302 ** Loop through every port. 294 ** Loop through every port.
@@ -399,7 +391,6 @@ int From;
399 /* For now don't handle RTA reboots. -- REW. 391 /* For now don't handle RTA reboots. -- REW.
400 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ 392 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
401 if (PortP->MagicFlags) { 393 if (PortP->MagicFlags) {
402#if 1
403 if (PortP->MagicFlags & MAGIC_REBOOT) { 394 if (PortP->MagicFlags & MAGIC_REBOOT) {
404 /* 395 /*
405 ** well, the RTA has been rebooted, and there is room 396 ** well, the RTA has been rebooted, and there is room
@@ -416,13 +407,12 @@ int From;
416 PortP->InUse = NOT_INUSE; 407 PortP->InUse = NOT_INUSE;
417 408
418 rio_spin_unlock(&PortP->portSem); 409 rio_spin_unlock(&PortP->portSem);
419 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? TRUE : FALSE, DONT_SLEEP) == RIO_FAIL) { 410 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) {
420 continue; /* with next port */ 411 continue; /* with next port */
421 } 412 }
422 rio_spin_lock(&PortP->portSem); 413 rio_spin_lock(&PortP->portSem);
423 PortP->MagicFlags &= ~MAGIC_REBOOT; 414 PortP->MagicFlags &= ~MAGIC_REBOOT;
424 } 415 }
425#endif
426 416
427 /* 417 /*
428 ** As mentioned above, this is a tacky hack to cope 418 ** As mentioned above, this is a tacky hack to cope
@@ -445,9 +435,9 @@ int From;
445 */ 435 */
446 PktCmdP = (struct PktCmd *) &PacketP->data[0]; 436 PktCmdP = (struct PktCmd *) &PacketP->data[0];
447 437
448 WBYTE(PktCmdP->Command, WFLUSH); 438 writeb(WFLUSH, &PktCmdP->Command);
449 439
450 p = PortP->HostPort % (ushort) PORTS_PER_RTA; 440 p = PortP->HostPort % (u16) PORTS_PER_RTA;
451 441
452 /* 442 /*
453 ** If second block of ports for 16 port RTA, add 8 443 ** If second block of ports for 16 port RTA, add 8
@@ -456,27 +446,27 @@ int From;
456 if (PortP->SecondBlock) 446 if (PortP->SecondBlock)
457 p += PORTS_PER_RTA; 447 p += PORTS_PER_RTA;
458 448
459 WBYTE(PktCmdP->PhbNum, p); 449 writeb(p, &PktCmdP->PhbNum);
460 450
461 /* 451 /*
462 ** to make debuggery easier 452 ** to make debuggery easier
463 */ 453 */
464 WBYTE(PacketP->data[2], 'W'); 454 writeb('W', &PacketP->data[2]);
465 WBYTE(PacketP->data[3], 'F'); 455 writeb('F', &PacketP->data[3]);
466 WBYTE(PacketP->data[4], 'L'); 456 writeb('L', &PacketP->data[4]);
467 WBYTE(PacketP->data[5], 'U'); 457 writeb('U', &PacketP->data[5]);
468 WBYTE(PacketP->data[6], 'S'); 458 writeb('S', &PacketP->data[6]);
469 WBYTE(PacketP->data[7], 'H'); 459 writeb('H', &PacketP->data[7]);
470 WBYTE(PacketP->data[8], ' '); 460 writeb(' ', &PacketP->data[8]);
471 WBYTE(PacketP->data[9], '0' + PortP->WflushFlag); 461 writeb('0' + PortP->WflushFlag, &PacketP->data[9]);
472 WBYTE(PacketP->data[10], ' '); 462 writeb(' ', &PacketP->data[10]);
473 WBYTE(PacketP->data[11], ' '); 463 writeb(' ', &PacketP->data[11]);
474 WBYTE(PacketP->data[12], '\0'); 464 writeb('\0', &PacketP->data[12]);
475 465
476 /* 466 /*
477 ** its two bytes long! 467 ** its two bytes long!
478 */ 468 */
479 WBYTE(PacketP->len, PKT_CMD_BIT | 2); 469 writeb(PKT_CMD_BIT | 2, &PacketP->len);
480 470
481 /* 471 /*
482 ** queue it! 472 ** queue it!
@@ -529,19 +519,15 @@ int From;
529} 519}
530 520
531/* 521/*
532** Routine for handling received data for clist drivers. 522** Routine for handling received data for tty drivers
533** NB: Called with the tty locked. The spl from the lockb( ) is passed.
534** we return the ttySpl level that we re-locked at.
535*/ 523*/
536static void RIOReceive(p, PortP) 524static void RIOReceive(struct rio_info *p, struct Port *PortP)
537struct rio_info *p;
538struct Port *PortP;
539{ 525{
540 struct tty_struct *TtyP; 526 struct tty_struct *TtyP;
541 register ushort transCount; 527 unsigned short transCount;
542 struct PKT *PacketP; 528 struct PKT *PacketP;
543 register uint DataCnt; 529 register unsigned int DataCnt;
544 uchar *ptr; 530 unsigned char *ptr;
545 unsigned char *buf; 531 unsigned char *buf;
546 int copied = 0; 532 int copied = 0;
547 533
@@ -594,9 +580,6 @@ struct Port *PortP;
594 transCount = 1; 580 transCount = 1;
595 while (can_remove_receive(&PacketP, PortP) 581 while (can_remove_receive(&PacketP, PortP)
596 && transCount) { 582 && transCount) {
597#ifdef STATS
598 PortP->Stat.RxIntCnt++;
599#endif /* STATS */
600 RxIntCnt++; 583 RxIntCnt++;
601 584
602 /* 585 /*
@@ -642,28 +625,15 @@ struct Port *PortP;
642 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the 625 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
643 ** driver). 626 ** driver).
644 */ 627 */
645#undef ___DEBUG_IT___ 628 ptr = (unsigned char *) PacketP->data + PortP->RxDataStart;
646#ifdef ___DEBUG_IT___
647 kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ", intCount, RxIntCnt, PortP->PortNum, TtyP->rxqueue.count, transCount, TtyP->flags);
648#endif
649 ptr = (uchar *) PacketP->data + PortP->RxDataStart;
650 629
651 tty_prepare_flip_string(TtyP, &buf, transCount); 630 tty_prepare_flip_string(TtyP, &buf, transCount);
652 rio_memcpy_fromio(buf, ptr, transCount); 631 rio_memcpy_fromio(buf, ptr, transCount);
653#ifdef STATS
654 /*
655 ** keep a count for statistical purposes
656 */
657 PortP->Stat.RxCharCnt += transCount;
658#endif
659 PortP->RxDataStart += transCount; 632 PortP->RxDataStart += transCount;
660 PacketP->len -= transCount; 633 PacketP->len -= transCount;
661 copied += transCount; 634 copied += transCount;
662 635
663 636
664#ifdef ___DEBUG_IT___
665 kkprintf("T:%d L:%d\n", DataCnt, PacketP->len);
666#endif
667 637
668 if (PacketP->len == 0) { 638 if (PacketP->len == 0) {
669 /* 639 /*
@@ -674,12 +644,6 @@ struct Port *PortP;
674 remove_receive(PortP); 644 remove_receive(PortP);
675 put_free_end(PortP->HostP, PacketP); 645 put_free_end(PortP->HostP, PacketP);
676 PortP->RxDataStart = 0; 646 PortP->RxDataStart = 0;
677#ifdef STATS
678 /*
679 ** more lies ( oops, I mean statistics )
680 */
681 PortP->Stat.RxPktCnt++;
682#endif /* STATS */
683 } 647 }
684 } 648 }
685 } 649 }
@@ -691,215 +655,3 @@ struct Port *PortP;
691 return; 655 return;
692} 656}
693 657
694#ifdef FUTURE_RELEASE
695/*
696** The proc routine called by the line discipline to do the work for it.
697** The proc routine works hand in hand with the interrupt routine.
698*/
699int riotproc(p, tp, cmd, port)
700struct rio_info *p;
701register struct ttystatics *tp;
702int cmd;
703int port;
704{
705 register struct Port *PortP;
706 int SysPort;
707 struct PKT *PacketP;
708
709 SysPort = port; /* Believe me, it works. */
710
711 if (SysPort < 0 || SysPort >= RIO_PORTS) {
712 rio_dprintk(RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n", SysPort);
713 return 0;
714 }
715 PortP = p->RIOPortp[SysPort];
716
717 if ((uint) PortP->PhbP < (uint) PortP->Caddr || (uint) PortP->PhbP >= (uint) PortP->Caddr + SIXTY_FOUR_K) {
718 rio_dprintk(RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n", SysPort);
719 rio_dprintk(RIO_DEBUG_INTR, " PortP = 0x%x\n", PortP);
720 rio_dprintk(RIO_DEBUG_INTR, " PortP->PhbP = 0x%x\n", PortP->PhbP);
721 rio_dprintk(RIO_DEBUG_INTR, " PortP->Caddr = 0x%x\n", PortP->PhbP);
722 rio_dprintk(RIO_DEBUG_INTR, " PortP->HostPort = 0x%x\n", PortP->HostPort);
723 return 0;
724 }
725
726 switch (cmd) {
727 case T_WFLUSH:
728 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH\n");
729 /*
730 ** Because of the spooky way the RIO works, we don't need
731 ** to issue a flush command on any of the SET*F commands,
732 ** as that causes trouble with getty and login, which issue
733 ** these commands to incur a READ flush, and rely on the fact
734 ** that the line discipline does a wait for drain for them.
735 ** As the rio doesn't wait for drain, the write flush would
736 ** destroy the Password: prompt. This isn't very friendly, so
737 ** here we only issue a WFLUSH command if we are in the interrupt
738 ** routine, or we aren't executing a SET*F command.
739 */
740 if (PortP->HostP->InIntr || !PortP->FlushCmdBodge) {
741 /*
742 ** form a wflush packet - 1 byte long, no data
743 */
744 if (PortP->State & RIO_DELETED) {
745 rio_dprintk(RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
746 } else {
747 if (RIOPreemptiveCmd(p, PortP, WFLUSH) == RIO_FAIL) {
748 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
749 } else
750 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command\n");
751 }
752 /*
753 ** WFLUSH operation - flush the data!
754 */
755 PortP->TxBufferIn = PortP->TxBufferOut = 0;
756 } else {
757 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
758 }
759 /*
760 ** sort out the line discipline
761 */
762 if (PortP->CookMode == COOK_WELL)
763 goto start;
764 break;
765
766 case T_RESUME:
767 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME\n");
768 /*
769 ** send pre-emptive resume packet
770 */
771 if (PortP->State & RIO_DELETED) {
772 rio_dprintk(RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
773 } else {
774 if (RIOPreemptiveCmd(p, PortP, RESUME) == RIO_FAIL) {
775 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME Command failed\n");
776 }
777 }
778 /*
779 ** and re-start the sender software!
780 */
781 if (PortP->CookMode == COOK_WELL)
782 goto start;
783 break;
784
785 case T_TIME:
786 rio_dprintk(RIO_DEBUG_INTR, "T_TIME\n");
787 /*
788 ** T_TIME is called when xDLY is set in oflags and
789 ** the line discipline timeout has expired. It's
790 ** function in life is to clear the TIMEOUT flag
791 ** and to re-start output to the port.
792 */
793 /*
794 ** Fall through and re-start output
795 */
796 case T_OUTPUT:
797 start:
798 if (PortP->MagicFlags & MAGIC_FLUSH) {
799 PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
800 return 0;
801 }
802 RIOTxEnable((char *) PortP);
803 PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
804 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n"); */
805 break;
806
807 case T_SUSPEND:
808 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND\n");
809 /*
810 ** send a suspend pre-emptive packet.
811 */
812 if (PortP->State & RIO_DELETED) {
813 rio_dprintk(RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
814 } else {
815 if (RIOPreemptiveCmd(p, PortP, SUSPEND) == RIO_FAIL) {
816 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
817 }
818 }
819 /*
820 ** done!
821 */
822 break;
823
824 case T_BLOCK:
825 rio_dprintk(RIO_DEBUG_INTR, "T_BLOCK\n");
826 break;
827
828 case T_RFLUSH:
829 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH\n");
830 if (PortP->State & RIO_DELETED) {
831 rio_dprintk(RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
832 PortP->RxDataStart = 0;
833 } else {
834 if (RIOPreemptiveCmd(p, PortP, RFLUSH) == RIO_FAIL) {
835 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
836 return 0;
837 }
838 PortP->RxDataStart = 0;
839 while (can_remove_receive(&PacketP, PortP)) {
840 remove_receive(PortP);
841 ShowPacket(DBG_PROC, PacketP);
842 put_free_end(PortP->HostP, PacketP);
843 }
844 if (PortP->PhbP->handshake == PHB_HANDSHAKE_SET) {
845 /*
846 ** MAGIC!
847 */
848 rio_dprintk(RIO_DEBUG_INTR, "Set receive handshake bit\n");
849 PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
850 }
851 }
852 break;
853 /* FALLTHROUGH */
854 case T_UNBLOCK:
855 rio_dprintk(RIO_DEBUG_INTR, "T_UNBLOCK\n");
856 /*
857 ** If there is any data to receive set a timeout to service it.
858 */
859 RIOReceive(p, PortP);
860 break;
861
862 case T_BREAK:
863 rio_dprintk(RIO_DEBUG_INTR, "T_BREAK\n");
864 /*
865 ** Send a break command. For Sys V
866 ** this is a timed break, so we
867 ** send a SBREAK[time] packet
868 */
869 /*
870 ** Build a BREAK command
871 */
872 if (PortP->State & RIO_DELETED) {
873 rio_dprintk(RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
874 } else {
875 if (RIOShortCommand(PortP, SBREAK, 2, p->RIOConf.BreakInterval) == RIO_FAIL) {
876 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
877 }
878 }
879
880 /*
881 ** done!
882 */
883 break;
884
885 case T_INPUT:
886 rio_dprintk(RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
887 break;
888 case T_PARM:
889 rio_dprintk(RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
890 break;
891
892 case T_SWTCH:
893 rio_dprintk(RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
894 break;
895
896 default:
897 rio_dprintk(RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n", cmd);
898 }
899 /*
900 ** T_OUTPUT returns without passing through this point!
901 */
902 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n"); */
903 return (0);
904}
905#endif
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index c622f46d6d77..d2e8092cdb29 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";
52 52
53#include "linux_compat.h" 53#include "linux_compat.h"
54#include "rio_linux.h" 54#include "rio_linux.h"
55#include "typdef.h"
56#include "pkt.h" 55#include "pkt.h"
57#include "daemon.h" 56#include "daemon.h"
58#include "rio.h" 57#include "rio.h"
59#include "riospace.h" 58#include "riospace.h"
60#include "top.h"
61#include "cmdpkt.h" 59#include "cmdpkt.h"
62#include "map.h" 60#include "map.h"
63#include "riotypes.h"
64#include "rup.h" 61#include "rup.h"
65#include "port.h" 62#include "port.h"
66#include "riodrvr.h" 63#include "riodrvr.h"
@@ -73,17 +70,13 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
73#include "unixrup.h" 70#include "unixrup.h"
74#include "board.h" 71#include "board.h"
75#include "host.h" 72#include "host.h"
76#include "error.h"
77#include "phb.h" 73#include "phb.h"
78#include "link.h" 74#include "link.h"
79#include "cmdblk.h" 75#include "cmdblk.h"
80#include "route.h" 76#include "route.h"
81#include "control.h"
82#include "cirrus.h" 77#include "cirrus.h"
83#include "rioioctl.h" 78#include "rioioctl.h"
84#include "param.h" 79#include "param.h"
85#include "list.h"
86#include "sam.h"
87 80
88 81
89 82
@@ -157,20 +150,16 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
157** NB. for MPX 150** NB. for MPX
158** tty lock must NOT have been previously acquired. 151** tty lock must NOT have been previously acquired.
159*/ 152*/
160int RIOParam(PortP, cmd, Modem, SleepFlag) 153int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
161struct Port *PortP;
162int cmd;
163int Modem;
164int SleepFlag;
165{ 154{
166 register struct tty_struct *TtyP; 155 struct tty_struct *TtyP;
167 int retval; 156 int retval;
168 register struct phb_param *phb_param_ptr; 157 struct phb_param *phb_param_ptr;
169 PKT *PacketP; 158 struct PKT *PacketP;
170 int res; 159 int res;
171 uchar Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; 160 u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
172 uchar TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; 161 u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
173 uchar LNext = 0, TxBaud = 0, RxBaud = 0; 162 u8 LNext = 0, TxBaud = 0, RxBaud = 0;
174 int retries = 0xff; 163 int retries = 0xff;
175 unsigned long flags; 164 unsigned long flags;
176 165
@@ -226,16 +215,13 @@ int SleepFlag;
226 if (retval == RIO_FAIL) { 215 if (retval == RIO_FAIL) {
227 rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); 216 rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
228 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 217 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
229 pseterr(EINTR);
230 func_exit(); 218 func_exit();
231 219 return -EINTR;
232 return RIO_FAIL;
233 } 220 }
234 if (PortP->State & RIO_DELETED) { 221 if (PortP->State & RIO_DELETED) {
235 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 222 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
236 func_exit(); 223 func_exit();
237 224 return 0;
238 return RIO_SUCCESS;
239 } 225 }
240 } 226 }
241 227
@@ -247,7 +233,7 @@ int SleepFlag;
247 } 233 }
248 234
249 rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); 235 rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
250 rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP); 236 rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP);
251 237
252 phb_param_ptr = (struct phb_param *) PacketP->data; 238 phb_param_ptr = (struct phb_param *) PacketP->data;
253 239
@@ -474,9 +460,6 @@ int SleepFlag;
474 e(115200); /* e(230400);e(460800); e(921600); */ 460 e(115200); /* e(230400);e(460800); e(921600); */
475 } 461 }
476 462
477 /* XXX MIssing conversion table. XXX */
478 /* (TtyP->termios->c_cflag & V_CBAUD); */
479
480 rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); 463 rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
481 464
482 465
@@ -552,23 +535,23 @@ int SleepFlag;
552 /* 535 /*
553 ** Actually write the info into the packet to be sent 536 ** Actually write the info into the packet to be sent
554 */ 537 */
555 WBYTE(phb_param_ptr->Cmd, cmd); 538 writeb(cmd, &phb_param_ptr->Cmd);
556 WBYTE(phb_param_ptr->Cor1, Cor1); 539 writeb(Cor1, &phb_param_ptr->Cor1);
557 WBYTE(phb_param_ptr->Cor2, Cor2); 540 writeb(Cor2, &phb_param_ptr->Cor2);
558 WBYTE(phb_param_ptr->Cor4, Cor4); 541 writeb(Cor4, &phb_param_ptr->Cor4);
559 WBYTE(phb_param_ptr->Cor5, Cor5); 542 writeb(Cor5, &phb_param_ptr->Cor5);
560 WBYTE(phb_param_ptr->TxXon, TxXon); 543 writeb(TxXon, &phb_param_ptr->TxXon);
561 WBYTE(phb_param_ptr->RxXon, RxXon); 544 writeb(RxXon, &phb_param_ptr->RxXon);
562 WBYTE(phb_param_ptr->TxXoff, TxXoff); 545 writeb(TxXoff, &phb_param_ptr->TxXoff);
563 WBYTE(phb_param_ptr->RxXoff, RxXoff); 546 writeb(RxXoff, &phb_param_ptr->RxXoff);
564 WBYTE(phb_param_ptr->LNext, LNext); 547 writeb(LNext, &phb_param_ptr->LNext);
565 WBYTE(phb_param_ptr->TxBaud, TxBaud); 548 writeb(TxBaud, &phb_param_ptr->TxBaud);
566 WBYTE(phb_param_ptr->RxBaud, RxBaud); 549 writeb(RxBaud, &phb_param_ptr->RxBaud);
567 550
568 /* 551 /*
569 ** Set the length/command field 552 ** Set the length/command field
570 */ 553 */
571 WBYTE(PacketP->len, 12 | PKT_CMD_BIT); 554 writeb(12 | PKT_CMD_BIT, &PacketP->len);
572 555
573 /* 556 /*
574 ** The packet is formed - now, whack it off 557 ** The packet is formed - now, whack it off
@@ -589,7 +572,7 @@ int SleepFlag;
589 */ 572 */
590 func_exit(); 573 func_exit();
591 574
592 return RIO_SUCCESS; 575 return 0;
593} 576}
594 577
595 578
@@ -597,15 +580,13 @@ int SleepFlag;
597** We can add another packet to a transmit queue if the packet pointer pointed 580** We can add another packet to a transmit queue if the packet pointer pointed
598** to by the TxAdd pointer has PKT_IN_USE clear in its address. 581** to by the TxAdd pointer has PKT_IN_USE clear in its address.
599*/ 582*/
600int can_add_transmit(PktP, PortP) 583int can_add_transmit(struct PKT **PktP, struct Port *PortP)
601PKT **PktP;
602struct Port *PortP;
603{ 584{
604 register PKT *tp; 585 struct PKT *tp;
605 586
606 *PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->TxAdd)); 587 *PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));
607 588
608 return !((uint) tp & PKT_IN_USE); 589 return !((unsigned long) tp & PKT_IN_USE);
609} 590}
610 591
611/* 592/*
@@ -613,27 +594,24 @@ struct Port *PortP;
613** and then move the TxAdd pointer along one position to point to the next 594** and then move the TxAdd pointer along one position to point to the next
614** packet pointer. You must wrap the pointer from the end back to the start. 595** packet pointer. You must wrap the pointer from the end back to the start.
615*/ 596*/
616void add_transmit(PortP) 597void add_transmit(struct Port *PortP)
617struct Port *PortP;
618{ 598{
619 if (RWORD(*PortP->TxAdd) & PKT_IN_USE) { 599 if (readw(PortP->TxAdd) & PKT_IN_USE) {
620 rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!"); 600 rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
621 } 601 }
622 WWORD(*(ushort *) PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE); 602 writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);
623 PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1; 603 PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
624 WWORD(PortP->PhbP->tx_add, RIO_OFF(PortP->Caddr, PortP->TxAdd)); 604 writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);
625} 605}
626 606
627/**************************************** 607/****************************************
628 * Put a packet onto the end of the 608 * Put a packet onto the end of the
629 * free list 609 * free list
630 ****************************************/ 610 ****************************************/
631void put_free_end(HostP, PktP) 611void put_free_end(struct Host *HostP, struct PKT *PktP)
632struct Host *HostP;
633PKT *PktP;
634{ 612{
635 FREE_LIST *tmp_pointer; 613 struct rio_free_list *tmp_pointer;
636 ushort old_end, new_end; 614 unsigned short old_end, new_end;
637 unsigned long flags; 615 unsigned long flags;
638 616
639 rio_spin_lock_irqsave(&HostP->HostLock, flags); 617 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -643,21 +621,21 @@ PKT *PktP;
643 * 621 *
644 ************************************************/ 622 ************************************************/
645 623
646 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%x)\n", (int) PktP); 624 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);
647 625
648 if ((old_end = RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) { 626 if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
649 new_end = RIO_OFF(HostP->Caddr, PktP); 627 new_end = RIO_OFF(HostP->Caddr, PktP);
650 tmp_pointer = (FREE_LIST *) RIO_PTR(HostP->Caddr, old_end); 628 tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end);
651 WWORD(tmp_pointer->next, new_end); 629 writew(new_end, &tmp_pointer->next);
652 WWORD(((FREE_LIST *) PktP)->prev, old_end); 630 writew(old_end, &((struct rio_free_list *) PktP)->prev);
653 WWORD(((FREE_LIST *) PktP)->next, TPNULL); 631 writew(TPNULL, &((struct rio_free_list *) PktP)->next);
654 WWORD(HostP->ParmMapP->free_list_end, new_end); 632 writew(new_end, &HostP->ParmMapP->free_list_end);
655 } else { /* First packet on the free list this should never happen! */ 633 } else { /* First packet on the free list this should never happen! */
656 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); 634 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
657 WWORD(HostP->ParmMapP->free_list_end, RIO_OFF(HostP->Caddr, PktP)); 635 writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
658 tmp_pointer = (FREE_LIST *) PktP; 636 tmp_pointer = (struct rio_free_list *) PktP;
659 WWORD(tmp_pointer->prev, TPNULL); 637 writew(TPNULL, &tmp_pointer->prev);
660 WWORD(tmp_pointer->next, TPNULL); 638 writew(TPNULL, &tmp_pointer->next);
661 } 639 }
662 rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock); 640 rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
663 rio_spin_unlock_irqrestore(&HostP->HostLock, flags); 641 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
@@ -669,12 +647,10 @@ PKT *PktP;
669** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, 647** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
670** then can_remove_receive() returns 0. 648** then can_remove_receive() returns 0.
671*/ 649*/
672int can_remove_receive(PktP, PortP) 650int can_remove_receive(struct PKT **PktP, struct Port *PortP)
673PKT **PktP;
674struct Port *PortP;
675{ 651{
676 if (RWORD(*PortP->RxRemove) & PKT_IN_USE) { 652 if (readw(PortP->RxRemove) & PKT_IN_USE) {
677 *PktP = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->RxRemove) & ~PKT_IN_USE); 653 *PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);
678 return 1; 654 return 1;
679 } 655 }
680 return 0; 656 return 0;
@@ -685,10 +661,9 @@ struct Port *PortP;
685** and then bump the pointers. Once the pointers get to the end, they must 661** and then bump the pointers. Once the pointers get to the end, they must
686** be wrapped back to the start. 662** be wrapped back to the start.
687*/ 663*/
688void remove_receive(PortP) 664void remove_receive(struct Port *PortP)
689struct Port *PortP;
690{ 665{
691 WWORD(*PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE); 666 writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove);
692 PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1; 667 PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;
693 WWORD(PortP->PhbP->rx_remove, RIO_OFF(PortP->Caddr, PortP->RxRemove)); 668 writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove);
694} 669}
diff --git a/drivers/char/rio/riopcicopy.c b/drivers/char/rio/riopcicopy.c
deleted file mode 100644
index 535afaa51ca5..000000000000
--- a/drivers/char/rio/riopcicopy.c
+++ /dev/null
@@ -1,8 +0,0 @@
1
2/* Yeah. We have copyright on this one. Sure. */
3
4void rio_pcicopy(char *from, char *to, int amount)
5{
6 while (amount--)
7 *to++ = *from++;
8}
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index f98888f52659..357085337942 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";
50 50
51#include "linux_compat.h" 51#include "linux_compat.h"
52#include "rio_linux.h" 52#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 53#include "pkt.h"
55#include "daemon.h" 54#include "daemon.h"
56#include "rio.h" 55#include "rio.h"
57#include "riospace.h" 56#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 57#include "cmdpkt.h"
60#include "map.h" 58#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 59#include "rup.h"
63#include "port.h" 60#include "port.h"
64#include "riodrvr.h" 61#include "riodrvr.h"
@@ -71,29 +68,25 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
71#include "unixrup.h" 68#include "unixrup.h"
72#include "board.h" 69#include "board.h"
73#include "host.h" 70#include "host.h"
74#include "error.h"
75#include "phb.h" 71#include "phb.h"
76#include "link.h" 72#include "link.h"
77#include "cmdblk.h" 73#include "cmdblk.h"
78#include "route.h" 74#include "route.h"
79#include "control.h"
80#include "cirrus.h" 75#include "cirrus.h"
81#include "rioioctl.h" 76#include "rioioctl.h"
82#include "param.h" 77#include "param.h"
83#include "list.h"
84#include "sam.h"
85 78
86static int RIOCheckIsolated(struct rio_info *, struct Host *, uint); 79static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int);
87static int RIOIsolate(struct rio_info *, struct Host *, uint); 80static int RIOIsolate(struct rio_info *, struct Host *, unsigned int);
88static int RIOCheck(struct Host *, uint); 81static int RIOCheck(struct Host *, unsigned int);
89static void RIOConCon(struct rio_info *, struct Host *, uint, uint, uint, uint, int); 82static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int);
90 83
91 84
92/* 85/*
93** Incoming on the ROUTE_RUP 86** Incoming on the ROUTE_RUP
94** I wrote this while I was tired. Forgive me. 87** I wrote this while I was tired. Forgive me.
95*/ 88*/
96int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 89int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP)
97{ 90{
98 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 91 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
99 struct PktCmd_M *PktReplyP; 92 struct PktCmd_M *PktReplyP;
@@ -104,10 +97,10 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
104 int ThisLink, ThisLinkMin, ThisLinkMax; 97 int ThisLink, ThisLinkMin, ThisLinkMax;
105 int port; 98 int port;
106 int Mod, Mod1, Mod2; 99 int Mod, Mod1, Mod2;
107 ushort RtaType; 100 unsigned short RtaType;
108 uint RtaUniq; 101 unsigned int RtaUniq;
109 uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ 102 unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
110 uint OldUnit, NewUnit, OldLink, NewLink; 103 unsigned int OldUnit, NewUnit, OldLink, NewLink;
111 char *MyType, *MyName; 104 char *MyType, *MyName;
112 int Lies; 105 int Lies;
113 unsigned long flags; 106 unsigned long flags;
@@ -115,7 +108,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
115 /* 108 /*
116 ** Is this unit telling us it's current link topology? 109 ** Is this unit telling us it's current link topology?
117 */ 110 */
118 if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) { 111 if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) {
119 MapP = HostP->Mapping; 112 MapP = HostP->Mapping;
120 113
121 /* 114 /*
@@ -125,7 +118,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
125 ** from an RTA then we need to fill in the Mapping structure's 118 ** from an RTA then we need to fill in the Mapping structure's
126 ** Topology array for the unit. 119 ** Topology array for the unit.
127 */ 120 */
128 if (Rup >= (ushort) MAX_RUP) { 121 if (Rup >= (unsigned short) MAX_RUP) {
129 ThisUnit = HOST_ID; 122 ThisUnit = HOST_ID;
130 TopP = HostP->Topology; 123 TopP = HostP->Topology;
131 MyType = "Host"; 124 MyType = "Host";
@@ -151,11 +144,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
151 ** it won't lie about network interconnect, total disconnects 144 ** it won't lie about network interconnect, total disconnects
152 ** and no-IDs. (or at least, it doesn't *matter* if it does) 145 ** and no-IDs. (or at least, it doesn't *matter* if it does)
153 */ 146 */
154 if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP) 147 if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
155 continue; 148 continue;
156 149
157 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) { 150 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
158 if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) { 151 if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) {
159 Lies++; 152 Lies++;
160 } 153 }
161 } 154 }
@@ -164,11 +157,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
164 if (Lies) { 157 if (Lies) {
165 rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies); 158 rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
166 rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n", 159 rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
167 RBYTE(PktCmdP->RouteTopology[0].Unit), 160 readb(&PktCmdP->RouteTopology[0].Unit),
168 'A' + RBYTE(PktCmdP->RouteTopology[0].Link), 161 'A' + readb(&PktCmdP->RouteTopology[0].Link),
169 RBYTE(PktCmdP->RouteTopology[1].Unit), 162 readb(&PktCmdP->RouteTopology[1].Unit),
170 '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)); 163 '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));
171 return TRUE; 164 return 1;
172 } 165 }
173 166
174 /* 167 /*
@@ -184,8 +177,8 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
184 /* 177 /*
185 ** this is what it is now connected to 178 ** this is what it is now connected to
186 */ 179 */
187 NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit); 180 NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit);
188 NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link); 181 NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link);
189 182
190 if (OldUnit != NewUnit || OldLink != NewLink) { 183 if (OldUnit != NewUnit || OldLink != NewLink) {
191 /* 184 /*
@@ -219,7 +212,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
219 212
220 if (NewUnit == ROUTE_INTERCONNECT) { 213 if (NewUnit == ROUTE_INTERCONNECT) {
221 if (!p->RIONoMessage) 214 if (!p->RIONoMessage)
222 cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); 215 printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
223 } 216 }
224 217
225 /* 218 /*
@@ -258,18 +251,18 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
258 RIOCheckIsolated(p, HostP, OldUnit); 251 RIOCheckIsolated(p, HostP, OldUnit);
259 } 252 }
260 } 253 }
261 return TRUE; 254 return 1;
262 } 255 }
263 256
264 /* 257 /*
265 ** The only other command we recognise is a route_request command 258 ** The only other command we recognise is a route_request command
266 */ 259 */
267 if (RBYTE(PktCmdP->Command) != ROUTE_REQUEST) { 260 if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
268 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", RBYTE(PktCmdP->Command), Rup, (int) HostP); 261 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
269 return TRUE; 262 return 1;
270 } 263 }
271 264
272 RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24); 265 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
273 266
274 /* 267 /*
275 ** Determine if 8 or 16 port RTA 268 ** Determine if 8 or 16 port RTA
@@ -278,7 +271,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
278 271
279 rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq); 272 rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
280 273
281 Mod = RBYTE(PktCmdP->ModuleTypes); 274 Mod = readb(&PktCmdP->ModuleTypes);
282 Mod1 = LONYBLE(Mod); 275 Mod1 = LONYBLE(Mod);
283 if (RtaType == TYPE_RTA16) { 276 if (RtaType == TYPE_RTA16) {
284 /* 277 /*
@@ -292,10 +285,6 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
292 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); 285 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);
293 } 286 }
294 287
295 if (RtaUniq == 0xffffffff) {
296 ShowPacket(DBG_SPECIAL, PacketP);
297 }
298
299 /* 288 /*
300 ** try to unhook a command block from the command free list. 289 ** try to unhook a command block from the command free list.
301 */ 290 */
@@ -320,7 +309,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
320 PktReplyP->Command = ROUTE_FOAD; 309 PktReplyP->Command = ROUTE_FOAD;
321 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 310 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
322 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 311 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
323 return TRUE; 312 return 1;
324 } 313 }
325 314
326 /* 315 /*
@@ -348,13 +337,13 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
348 if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) { 337 if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
349 if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) { 338 if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
350 if (!p->RIONoMessage) 339 if (!p->RIONoMessage)
351 cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); 340 printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
352 HostP->Mapping[ThisUnit].Flags |= MSG_DONE; 341 HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
353 } 342 }
354 PktReplyP->Command = ROUTE_FOAD; 343 PktReplyP->Command = ROUTE_FOAD;
355 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 344 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
356 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 345 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
357 return TRUE; 346 return 1;
358 } 347 }
359 348
360 /* 349 /*
@@ -447,7 +436,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
447 /* 436 /*
448 ** Job done, get on with the interrupts! 437 ** Job done, get on with the interrupts!
449 */ 438 */
450 return TRUE; 439 return 1;
451 } 440 }
452 } 441 }
453 /* 442 /*
@@ -475,7 +464,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
475 464
476 if (!UnknownMesgDone) { 465 if (!UnknownMesgDone) {
477 if (!p->RIONoMessage) 466 if (!p->RIONoMessage)
478 cprintf("One or more unknown RTAs are being updated.\n"); 467 printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n");
479 UnknownMesgDone = 1; 468 UnknownMesgDone = 1;
480 } 469 }
481 470
@@ -491,28 +480,25 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
491 if (RtaType == TYPE_RTA16) { 480 if (RtaType == TYPE_RTA16) {
492 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) { 481 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
493 RIODefaultName(p, HostP, ThisUnit); 482 RIODefaultName(p, HostP, ThisUnit);
494 FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP); 483 rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
495 } 484 }
496 } else { 485 } else {
497 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) { 486 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
498 RIODefaultName(p, HostP, ThisUnit); 487 RIODefaultName(p, HostP, ThisUnit);
499 FillSlot(ThisUnit, 0, RtaUniq, HostP); 488 rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
500 } 489 }
501 } 490 }
502 PktReplyP->Command = ROUTE_USED; 491 PktReplyP->Command = ROUTE_USED;
503 HostP->Copy("RT_USED", PktReplyP->CommandText, 7); 492 HostP->Copy("RT_USED", PktReplyP->CommandText, 7);
504 } 493 }
505 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 494 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
506 return TRUE; 495 return 1;
507} 496}
508 497
509 498
510void RIOFixPhbs(p, HostP, unit) 499void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
511struct rio_info *p;
512struct Host *HostP;
513uint unit;
514{ 500{
515 ushort link, port; 501 unsigned short link, port;
516 struct Port *PortP; 502 struct Port *PortP;
517 unsigned long flags; 503 unsigned long flags;
518 int PortN = HostP->Mapping[unit].SysPort; 504 int PortN = HostP->Mapping[unit].SysPort;
@@ -520,19 +506,19 @@ uint unit;
520 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN); 506 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
521 507
522 if (PortN != -1) { 508 if (PortN != -1) {
523 ushort dest_unit = HostP->Mapping[unit].ID2; 509 unsigned short dest_unit = HostP->Mapping[unit].ID2;
524 510
525 /* 511 /*
526 ** Get the link number used for the 1st 8 phbs on this unit. 512 ** Get the link number used for the 1st 8 phbs on this unit.
527 */ 513 */
528 PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort]; 514 PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
529 515
530 link = RWORD(PortP->PhbP->link); 516 link = readw(&PortP->PhbP->link);
531 517
532 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { 518 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
533 ushort dest_port = port + 8; 519 unsigned short dest_port = port + 8;
534 WORD *TxPktP; 520 u16 *TxPktP;
535 PKT *Pkt; 521 struct PKT *Pkt;
536 522
537 PortP = p->RIOPortp[PortN]; 523 PortP = p->RIOPortp[PortN];
538 524
@@ -569,18 +555,18 @@ uint unit;
569 ** card. This needs to be translated into a 32 bit pointer 555 ** card. This needs to be translated into a 32 bit pointer
570 ** so it can be accessed from the driver. 556 ** so it can be accessed from the driver.
571 */ 557 */
572 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP)); 558 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP));
573 559
574 /* 560 /*
575 ** If the packet is used, reset it. 561 ** If the packet is used, reset it.
576 */ 562 */
577 Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE); 563 Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE);
578 WBYTE(Pkt->dest_unit, dest_unit); 564 writeb(dest_unit, &Pkt->dest_unit);
579 WBYTE(Pkt->dest_port, dest_port); 565 writeb(dest_port, &Pkt->dest_port);
580 } 566 }
581 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); 567 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);
582 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); 568 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
583 WWORD(PortP->PhbP->link, link); 569 writew(link, &PortP->PhbP->link);
584 570
585 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 571 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
586 } 572 }
@@ -590,9 +576,9 @@ uint unit;
590 */ 576 */
591 if (link > 3) 577 if (link > 3)
592 return; 578 return;
593 if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) { 579 if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) {
594 rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7); 580 rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
595 WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7); 581 writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port);
596 } 582 }
597 } 583 }
598} 584}
@@ -603,10 +589,7 @@ uint unit;
603** the world about it. This is done to ensure that the configurator 589** the world about it. This is done to ensure that the configurator
604** only gets up-to-date information about what is going on. 590** only gets up-to-date information about what is going on.
605*/ 591*/
606static int RIOCheckIsolated(p, HostP, UnitId) 592static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
607struct rio_info *p;
608struct Host *HostP;
609uint UnitId;
610{ 593{
611 unsigned long flags; 594 unsigned long flags;
612 rio_spin_lock_irqsave(&HostP->HostLock, flags); 595 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -628,12 +611,9 @@ uint UnitId;
628** all the units attached to it. This will mean that the entire 611** all the units attached to it. This will mean that the entire
629** subnet will re-introduce itself. 612** subnet will re-introduce itself.
630*/ 613*/
631static int RIOIsolate(p, HostP, UnitId) 614static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
632struct rio_info *p;
633struct Host *HostP;
634uint UnitId;
635{ 615{
636 uint link, unit; 616 unsigned int link, unit;
637 617
638 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */ 618 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */
639 619
@@ -658,9 +638,7 @@ uint UnitId;
658 return 1; 638 return 1;
659} 639}
660 640
661static int RIOCheck(HostP, UnitId) 641static int RIOCheck(struct Host *HostP, unsigned int UnitId)
662struct Host *HostP;
663uint UnitId;
664{ 642{
665 unsigned char link; 643 unsigned char link;
666 644
@@ -714,8 +692,7 @@ uint UnitId;
714** Returns the type of unit (host, 16/8 port RTA) 692** Returns the type of unit (host, 16/8 port RTA)
715*/ 693*/
716 694
717uint GetUnitType(Uniq) 695unsigned int GetUnitType(unsigned int Uniq)
718uint Uniq;
719{ 696{
720 switch ((Uniq >> 28) & 0xf) { 697 switch ((Uniq >> 28) & 0xf) {
721 case RIO_AT: 698 case RIO_AT:
@@ -736,8 +713,7 @@ uint Uniq;
736 } 713 }
737} 714}
738 715
739int RIOSetChange(p) 716int RIOSetChange(struct rio_info *p)
740struct rio_info *p;
741{ 717{
742 if (p->RIOQuickCheck != NOT_CHANGED) 718 if (p->RIOQuickCheck != NOT_CHANGED)
743 return (0); 719 return (0);
@@ -751,14 +727,13 @@ struct rio_info *p;
751 return (0); 727 return (0);
752} 728}
753 729
754static void RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change) 730static void RIOConCon(struct rio_info *p,
755struct rio_info *p; 731 struct Host *HostP,
756struct Host *HostP; 732 unsigned int FromId,
757uint FromId; 733 unsigned int FromLink,
758uint FromLink; 734 unsigned int ToId,
759uint ToId; 735 unsigned int ToLink,
760uint ToLink; 736 int Change)
761int Change;
762{ 737{
763 char *FromName; 738 char *FromName;
764 char *FromType; 739 char *FromType;
@@ -818,7 +793,7 @@ int Change;
818 ToType = ToId ? "RTA" : "HOST"; 793 ToType = ToId ? "RTA" : "HOST";
819 794
820 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"); 795 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");
821 cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected"); 796 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");
822} 797}
823 798
824/* 799/*
@@ -838,7 +813,7 @@ static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
838 */ 813 */
839 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { 814 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
840 if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) { 815 if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) {
841 bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map)); 816 memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
842 } 817 }
843 } 818 }
844 return 0; 819 return 0;
@@ -898,7 +873,7 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
898 int nOther = (HostP->Mapping[unit].ID2) - 1; 873 int nOther = (HostP->Mapping[unit].ID2) - 1;
899 874
900 rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther); 875 rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
901 bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map)); 876 memset(&HostP->Mapping[nOther], 0, sizeof(struct Map));
902 } 877 }
903 RIORemoveFromSavedTable(p, &HostP->Mapping[unit]); 878 RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
904 879
@@ -912,7 +887,8 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
912** This function scans the given host table for either one 887** This function scans the given host table for either one
913** or two free unit ID's. 888** or two free unit ID's.
914*/ 889*/
915int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2) 890
891int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2)
916{ 892{
917 int unit, tempID; 893 int unit, tempID;
918 894
@@ -997,7 +973,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
997 /* 973 /*
998 ** Clear out this slot now that we intend to use it. 974 ** Clear out this slot now that we intend to use it.
999 */ 975 */
1000 bzero(&HostP->Mapping[unit], sizeof(struct Map)); 976 memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
1001 977
1002 /* 978 /*
1003 ** If the second ID is not needed then we can return 979 ** 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
1015 /* 991 /*
1016 ** Clear out this slot now that we intend to use it. 992 ** Clear out this slot now that we intend to use it.
1017 */ 993 */
1018 bzero(&HostP->Mapping[unit], sizeof(struct Map)); 994 memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
1019 995
1020 /* At this point under the right(wrong?) conditions 996 /* At this point under the right(wrong?) conditions
1021 ** we may have a first unit ID being higher than the 997 ** 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 a86b216ab653..d3abe0d37d64 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";
53 53
54#include "linux_compat.h" 54#include "linux_compat.h"
55#include "rio_linux.h" 55#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h" 56#include "pkt.h"
58#include "daemon.h" 57#include "daemon.h"
59#include "rio.h" 58#include "rio.h"
60#include "riospace.h" 59#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h" 60#include "cmdpkt.h"
63#include "map.h" 61#include "map.h"
64#include "riotypes.h"
65#include "rup.h" 62#include "rup.h"
66#include "port.h" 63#include "port.h"
67#include "riodrvr.h" 64#include "riodrvr.h"
@@ -74,25 +71,20 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
74#include "unixrup.h" 71#include "unixrup.h"
75#include "board.h" 72#include "board.h"
76#include "host.h" 73#include "host.h"
77#include "error.h"
78#include "phb.h" 74#include "phb.h"
79#include "link.h" 75#include "link.h"
80#include "cmdblk.h" 76#include "cmdblk.h"
81#include "route.h" 77#include "route.h"
82#include "control.h"
83#include "cirrus.h" 78#include "cirrus.h"
84#include "rioioctl.h" 79#include "rioioctl.h"
85#include "param.h" 80#include "param.h"
86#include "list.h"
87#include "sam.h"
88#include "protsts.h" 81#include "protsts.h"
89 82
90/* 83/*
91** A configuration table has been loaded. It is now up to us 84** A configuration table has been loaded. It is now up to us
92** to sort it out and use the information contained therein. 85** to sort it out and use the information contained therein.
93*/ 86*/
94int RIONewTable(p) 87int RIONewTable(struct rio_info *p)
95struct rio_info *p;
96{ 88{
97 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; 89 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
98 struct Map *MapP; 90 struct Map *MapP;
@@ -137,7 +129,7 @@ struct rio_info *p;
137 cptr = MapP->Name; /* (2) */ 129 cptr = MapP->Name; /* (2) */
138 cptr[MAX_NAME_LEN - 1] = '\0'; 130 cptr[MAX_NAME_LEN - 1] = '\0';
139 if (cptr[0] == '\0') { 131 if (cptr[0] == '\0') {
140 bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8); 132 memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8);
141 MapP->Name[5] = '0' + Entry / 10; 133 MapP->Name[5] = '0' + Entry / 10;
142 MapP->Name[6] = '0' + Entry % 10; 134 MapP->Name[6] = '0' + Entry % 10;
143 } 135 }
@@ -298,9 +290,9 @@ struct rio_info *p;
298 */ 290 */
299 for (Host = 0; Host < RIO_HOSTS; Host++) { 291 for (Host = 0; Host < RIO_HOSTS; Host++) {
300 for (Entry = 0; Entry < MAX_RUP; Entry++) { 292 for (Entry = 0; Entry < MAX_RUP; Entry++) {
301 bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map)); 293 memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map));
302 } 294 }
303 bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name)); 295 memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name));
304 } 296 }
305 297
306 /* 298 /*
@@ -326,7 +318,7 @@ struct rio_info *p;
326 */ 318 */
327 if (MapP->ID == 0) { 319 if (MapP->ID == 0) {
328 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name); 320 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
329 bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN); 321 memcpy(HostP->Name, MapP->Name, MAX_NAME_LEN);
330 continue; 322 continue;
331 } 323 }
332 324
@@ -370,7 +362,7 @@ struct rio_info *p;
370 } 362 }
371 } 363 }
372 if (!p->RIOHosts[Host].Name[0]) { 364 if (!p->RIOHosts[Host].Name[0]) {
373 bcopy("HOST 1", p->RIOHosts[Host].Name, 7); 365 memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
374 p->RIOHosts[Host].Name[5] += Host; 366 p->RIOHosts[Host].Name[5] += Host;
375 } 367 }
376 /* 368 /*
@@ -398,7 +390,7 @@ struct rio_info *p;
398 */ 390 */
399 if (Host1 != Host) { 391 if (Host1 != Host) {
400 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name); 392 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
401 bcopy("HOST 1", p->RIOHosts[Host].Name, 7); 393 memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
402 p->RIOHosts[Host].Name[5] += Host1; 394 p->RIOHosts[Host].Name[5] += Host1;
403 } 395 }
404 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name); 396 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
@@ -409,9 +401,10 @@ struct rio_info *p;
409/* 401/*
410** User process needs the config table - build it from first 402** User process needs the config table - build it from first
411** principles. 403** principles.
404**
405* FIXME: SMP locking
412*/ 406*/
413int RIOApel(p) 407int RIOApel(struct rio_info *p)
414struct rio_info *p;
415{ 408{
416 int Host; 409 int Host;
417 int link; 410 int link;
@@ -419,17 +412,17 @@ struct rio_info *p;
419 int Next = 0; 412 int Next = 0;
420 struct Map *MapP; 413 struct Map *MapP;
421 struct Host *HostP; 414 struct Host *HostP;
422 long oldspl; 415 unsigned long flags;
423
424 disable(oldspl); /* strange but true! */
425 416
426 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); 417 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
427 418
428 bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES); 419 memset(&p->RIOConnectTable[0], 0, sizeof(struct Map) * TOTAL_MAP_ENTRIES);
429 420
430 for (Host = 0; Host < RIO_HOSTS; Host++) { 421 for (Host = 0; Host < RIO_HOSTS; Host++) {
431 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host); 422 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host);
432 HostP = &p->RIOHosts[Host]; 423 HostP = &p->RIOHosts[Host];
424 rio_spin_lock_irqsave(&HostP->HostLock, flags);
425
433 MapP = &p->RIOConnectTable[Next++]; 426 MapP = &p->RIOConnectTable[Next++];
434 MapP->HostUniqueNum = HostP->UniqueNum; 427 MapP->HostUniqueNum = HostP->UniqueNum;
435 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) 428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
@@ -440,7 +433,7 @@ struct rio_info *p;
440 MapP->SysPort = NO_PORT; 433 MapP->SysPort = NO_PORT;
441 for (link = 0; link < LINKS_PER_UNIT; link++) 434 for (link = 0; link < LINKS_PER_UNIT; link++)
442 MapP->Topology[link] = HostP->Topology[link]; 435 MapP->Topology[link] = HostP->Topology[link];
443 bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN); 436 memcpy(MapP->Name, HostP->Name, MAX_NAME_LEN);
444 for (Rup = 0; Rup < MAX_RUP; Rup++) { 437 for (Rup = 0; Rup < MAX_RUP; Rup++) {
445 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) { 438 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) {
446 p->RIOConnectTable[Next] = HostP->Mapping[Rup]; 439 p->RIOConnectTable[Next] = HostP->Mapping[Rup];
@@ -453,8 +446,8 @@ struct rio_info *p;
453 Next++; 446 Next++;
454 } 447 }
455 } 448 }
449 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
456 } 450 }
457 restore(oldspl);
458 return 0; 451 return 0;
459} 452}
460 453
@@ -463,9 +456,7 @@ struct rio_info *p;
463** if the entry is suitably inactive, then we can gob on it and remove 456** if the entry is suitably inactive, then we can gob on it and remove
464** it from the table. 457** it from the table.
465*/ 458*/
466int RIODeleteRta(p, MapP) 459int RIODeleteRta(struct rio_info *p, struct Map *MapP)
467struct rio_info *p;
468struct Map *MapP;
469{ 460{
470 int host, entry, port, link; 461 int host, entry, port, link;
471 int SysPort; 462 int SysPort;
@@ -541,10 +532,10 @@ struct Map *MapP;
541 ** the phb to port mappings in RIORouteRup. 532 ** the phb to port mappings in RIORouteRup.
542 */ 533 */
543 if (PortP->SecondBlock) { 534 if (PortP->SecondBlock) {
544 ushort dest_unit = HostMapP->ID; 535 u16 dest_unit = HostMapP->ID;
545 ushort dest_port = port - SysPort; 536 u16 dest_port = port - SysPort;
546 WORD *TxPktP; 537 u16 *TxPktP;
547 PKT *Pkt; 538 struct PKT *Pkt;
548 539
549 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { 540 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
550 /* 541 /*
@@ -554,19 +545,19 @@ struct Map *MapP;
554 ** a 32 bit pointer so it can be 545 ** a 32 bit pointer so it can be
555 ** accessed from the driver. 546 ** accessed from the driver.
556 */ 547 */
557 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP)); 548 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP));
558 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); 549 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);
559 WWORD(Pkt->dest_unit, dest_unit); 550 writew(dest_unit, &Pkt->dest_unit);
560 WWORD(Pkt->dest_port, dest_port); 551 writew(dest_port, &Pkt->dest_port);
561 } 552 }
562 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); 553 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);
563 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); 554 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
564 } 555 }
565 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); 556 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
566 } 557 }
567 } 558 }
568 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n"); 559 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
569 bzero((char *) HostMapP, sizeof(struct Map)); 560 memset(HostMapP, 0, sizeof(struct Map));
570 work_done++; 561 work_done++;
571 } 562 }
572 } 563 }
@@ -576,11 +567,11 @@ struct Map *MapP;
576 /* XXXXX lock me up */ 567 /* XXXXX lock me up */
577 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { 568 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
578 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { 569 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
579 bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map)); 570 memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
580 work_done++; 571 work_done++;
581 } 572 }
582 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { 573 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
583 bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map)); 574 memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map));
584 work_done++; 575 work_done++;
585 } 576 }
586 } 577 }
@@ -602,7 +593,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
602 593
603 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); 594 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);
604 595
605 if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) { 596 if ((MapP->ID != (u16) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
606 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n"); 597 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
607 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; 598 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
608 return -EINVAL; 599 return -EINVAL;
@@ -648,7 +639,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
648 ** Now we have a host we need to allocate an ID 639 ** Now we have a host we need to allocate an ID
649 ** if the entry does not already have one. 640 ** if the entry does not already have one.
650 */ 641 */
651 if (MapP->ID == (ushort) - 1) { 642 if (MapP->ID == (u16) - 1) {
652 int nNewID; 643 int nNewID;
653 644
654 rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name); 645 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)
667 p->RIOError.Error = COULDNT_FIND_ENTRY; 658 p->RIOError.Error = COULDNT_FIND_ENTRY;
668 return -EBUSY; 659 return -EBUSY;
669 } 660 }
670 MapP->ID = (ushort) nNewID + 1; 661 MapP->ID = (u16) nNewID + 1;
671 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID); 662 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
672 HostMapP = &p->RIOHosts[host].Mapping[nNewID]; 663 HostMapP = &p->RIOHosts[host].Mapping[nNewID];
673 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum; 664 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
@@ -708,7 +699,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
708 */ 699 */
709 HostMapP->SysPort = MapP->SysPort; 700 HostMapP->SysPort = MapP->SysPort;
710 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) 701 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
711 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); 702 memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
712 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED; 703 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
713#ifdef NEED_TO_FIX 704#ifdef NEED_TO_FIX
714 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]); 705 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]);
@@ -742,16 +733,13 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
742} 733}
743 734
744 735
745int RIOReMapPorts(p, HostP, HostMapP) 736int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
746struct rio_info *p;
747struct Host *HostP;
748struct Map *HostMapP;
749{ 737{
750 register struct Port *PortP; 738 struct Port *PortP;
751 uint SubEnt; 739 unsigned int SubEnt;
752 uint HostPort; 740 unsigned int HostPort;
753 uint SysPort; 741 unsigned int SysPort;
754 ushort RtaType; 742 u16 RtaType;
755 unsigned long flags; 743 unsigned long flags;
756 744
757 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID); 745 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
@@ -794,12 +782,12 @@ struct Map *HostMapP;
794 */ 782 */
795 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { 783 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
796 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; 784 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
797 PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add)); 785 PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
798 PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start)); 786 PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
799 PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end)); 787 PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
800 PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove)); 788 PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
801 PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start)); 789 PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
802 PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end)); 790 PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
803 } else 791 } else
804 PortP->PhbP = NULL; 792 PortP->PhbP = NULL;
805 793
@@ -813,10 +801,10 @@ struct Map *HostMapP;
813 PortP->RupNum = HostMapP->ID - 1; 801 PortP->RupNum = HostMapP->ID - 1;
814 if (HostMapP->Flags & RTA16_SECOND_SLOT) { 802 if (HostMapP->Flags & RTA16_SECOND_SLOT) {
815 PortP->ID2 = HostMapP->ID2 - 1; 803 PortP->ID2 = HostMapP->ID2 - 1;
816 PortP->SecondBlock = TRUE; 804 PortP->SecondBlock = 1;
817 } else { 805 } else {
818 PortP->ID2 = 0; 806 PortP->ID2 = 0;
819 PortP->SecondBlock = FALSE; 807 PortP->SecondBlock = 0;
820 } 808 }
821 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum; 809 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
822 810
@@ -866,9 +854,6 @@ struct Map *HostMapP;
866 PortP->RxDataStart = 0; 854 PortP->RxDataStart = 0;
867 PortP->Cor2Copy = 0; 855 PortP->Cor2Copy = 0;
868 PortP->Name = &HostMapP->Name[0]; 856 PortP->Name = &HostMapP->Name[0];
869#ifdef STATS
870 bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats));
871#endif
872 PortP->statsGather = 0; 857 PortP->statsGather = 0;
873 PortP->txchars = 0; 858 PortP->txchars = 0;
874 PortP->rxchars = 0; 859 PortP->rxchars = 0;
@@ -876,10 +861,10 @@ struct Map *HostMapP;
876 PortP->closes = 0; 861 PortP->closes = 0;
877 PortP->ioctls = 0; 862 PortP->ioctls = 0;
878 if (PortP->TxRingBuffer) 863 if (PortP->TxRingBuffer)
879 bzero(PortP->TxRingBuffer, p->RIOBufferSize); 864 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
880 else if (p->RIOBufferSize) { 865 else if (p->RIOBufferSize) {
881 PortP->TxRingBuffer = sysbrk(p->RIOBufferSize); 866 PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL);
882 bzero(PortP->TxRingBuffer, p->RIOBufferSize); 867 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
883 } 868 }
884 PortP->TxBufferOut = 0; 869 PortP->TxBufferOut = 0;
885 PortP->TxBufferIn = 0; 870 PortP->TxBufferIn = 0;
@@ -890,7 +875,7 @@ struct Map *HostMapP;
890 ** If the same, we have received the same rx pkt from the RTA 875 ** If the same, we have received the same rx pkt from the RTA
891 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. 876 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
892 */ 877 */
893 PortP->LastRxTgl = ~(uchar) PHB_RX_TGL; 878 PortP->LastRxTgl = ~(u8) PHB_RX_TGL;
894 879
895 /* 880 /*
896 ** and mark the port as usable 881 ** and mark the port as usable
@@ -906,9 +891,7 @@ struct Map *HostMapP;
906 return 0; 891 return 0;
907} 892}
908 893
909int RIOChangeName(p, MapP) 894int RIOChangeName(struct rio_info *p, struct Map *MapP)
910struct rio_info *p;
911struct Map *MapP;
912{ 895{
913 int host; 896 int host;
914 struct Map *HostMapP; 897 struct Map *HostMapP;
@@ -941,7 +924,7 @@ struct Map *MapP;
941 return -ENXIO; 924 return -ENXIO;
942 } 925 }
943 if (MapP->ID == 0) { 926 if (MapP->ID == 0) {
944 CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN); 927 memcpy(p->RIOHosts[host].Name, MapP->Name, MAX_NAME_LEN);
945 return 0; 928 return 0;
946 } 929 }
947 930
@@ -951,7 +934,7 @@ struct Map *MapP;
951 p->RIOError.Error = RTA_NUMBER_WRONG; 934 p->RIOError.Error = RTA_NUMBER_WRONG;
952 return -ENXIO; 935 return -ENXIO;
953 } 936 }
954 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); 937 memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
955 return 0; 938 return 0;
956 } 939 }
957 } 940 }
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 6379816ed173..204267613c9c 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";
56 56
57#include "linux_compat.h" 57#include "linux_compat.h"
58#include "rio_linux.h" 58#include "rio_linux.h"
59#include "typdef.h"
60#include "pkt.h" 59#include "pkt.h"
61#include "daemon.h" 60#include "daemon.h"
62#include "rio.h" 61#include "rio.h"
63#include "riospace.h" 62#include "riospace.h"
64#include "top.h"
65#include "cmdpkt.h" 63#include "cmdpkt.h"
66#include "map.h" 64#include "map.h"
67#include "riotypes.h"
68#include "rup.h" 65#include "rup.h"
69#include "port.h" 66#include "port.h"
70#include "riodrvr.h" 67#include "riodrvr.h"
@@ -77,58 +74,18 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
77#include "unixrup.h" 74#include "unixrup.h"
78#include "board.h" 75#include "board.h"
79#include "host.h" 76#include "host.h"
80#include "error.h"
81#include "phb.h" 77#include "phb.h"
82#include "link.h" 78#include "link.h"
83#include "cmdblk.h" 79#include "cmdblk.h"
84#include "route.h" 80#include "route.h"
85#include "control.h"
86#include "cirrus.h" 81#include "cirrus.h"
87#include "rioioctl.h" 82#include "rioioctl.h"
88#include "param.h" 83#include "param.h"
89#include "list.h"
90#include "sam.h"
91 84
92static void RIOClearUp(struct Port *PortP); 85static void RIOClearUp(struct Port *PortP);
93int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
94
95
96extern int conv_vb[]; /* now defined in ttymgr.c */
97extern int conv_bv[]; /* now defined in ttymgr.c */
98 86
99/* 87/* Below belongs in func.h */
100** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support 88int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
101**
102** ep.def.h is necessary for Modular Kernel Support
103** DO NOT place any kernel 'extern's after this line
104** or this source file will not build riotty.k.o
105*/
106#ifdef uLYNX
107#include <ep.def.h>
108#endif
109
110#ifdef NEED_THIS2
111static struct old_sgttyb default_sg = {
112 B19200, B19200, /* input and output speed */
113 'H' - '@', /* erase char */
114 -1, /* 2nd erase char */
115 'U' - '@', /* kill char */
116 ECHO | CRMOD, /* mode */
117 'C' - '@', /* interrupt character */
118 '\\' - '@', /* quit char */
119 'Q' - '@', /* start char */
120 'S' - '@', /* stop char */
121 'D' - '@', /* EOF */
122 -1, /* brk */
123 (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */
124 'Z' - '@', /* process stop */
125 'Y' - '@', /* delayed stop */
126 'R' - '@', /* reprint line */
127 'O' - '@', /* flush output */
128 'W' - '@', /* word erase */
129 'V' - '@' /* literal next char */
130};
131#endif
132 89
133 90
134extern struct rio_info *p; 91extern struct rio_info *p;
@@ -136,8 +93,7 @@ extern struct rio_info *p;
136 93
137int riotopen(struct tty_struct *tty, struct file *filp) 94int riotopen(struct tty_struct *tty, struct file *filp)
138{ 95{
139 register uint SysPort; 96 unsigned int SysPort;
140 int Modem;
141 int repeat_this = 250; 97 int repeat_this = 250;
142 struct Port *PortP; /* pointer to the port structure */ 98 struct Port *PortP; /* pointer to the port structure */
143 unsigned long flags; 99 unsigned long flags;
@@ -151,16 +107,14 @@ int riotopen(struct tty_struct *tty, struct file *filp)
151 tty->driver_data = NULL; 107 tty->driver_data = NULL;
152 108
153 SysPort = rio_minor(tty); 109 SysPort = rio_minor(tty);
154 Modem = rio_ismodem(tty);
155 110
156 if (p->RIOFailed) { 111 if (p->RIOFailed) {
157 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); 112 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
158 pseterr(ENXIO);
159 func_exit(); 113 func_exit();
160 return -ENXIO; 114 return -ENXIO;
161 } 115 }
162 116
163 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped); 117 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped);
164 118
165 /* 119 /*
166 ** Validate that we have received a legitimate request. 120 ** Validate that we have received a legitimate request.
@@ -170,7 +124,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
170 */ 124 */
171 if (SysPort >= RIO_PORTS) { /* out of range ? */ 125 if (SysPort >= RIO_PORTS) { /* out of range ? */
172 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); 126 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
173 pseterr(ENXIO);
174 func_exit(); 127 func_exit();
175 return -ENXIO; 128 return -ENXIO;
176 } 129 }
@@ -187,7 +140,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
187 */ 140 */
188 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); 141 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
189 func_exit(); 142 func_exit();
190 pseterr(ENXIO);
191 return -ENXIO; 143 return -ENXIO;
192 } 144 }
193 145
@@ -209,7 +161,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
209 */ 161 */
210 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { 162 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
211 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); 163 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
212 pseterr(ENXIO);
213 func_exit(); 164 func_exit();
214 return -ENXIO; 165 return -ENXIO;
215 } 166 }
@@ -309,15 +260,12 @@ int riotopen(struct tty_struct *tty, struct file *filp)
309 /* PortP->gs.xmit_cnt = 0; */ 260 /* PortP->gs.xmit_cnt = 0; */
310 261
311 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 262 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
312#ifdef NEED_THIS
313 ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg);
314#endif
315 263
316 /* Someone explain to me why this delay/config is 264 /* Someone explain to me why this delay/config is
317 here. If I read the docs correctly the "open" 265 here. If I read the docs correctly the "open"
318 command piggybacks the parameters immediately. 266 command piggybacks the parameters immediately.
319 -- REW */ 267 -- REW */
320 RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */ 268 RIOParam(PortP, OPEN, 1, OK_TO_SLEEP); /* Open the port */
321 rio_spin_lock_irqsave(&PortP->portSem, flags); 269 rio_spin_lock_irqsave(&PortP->portSem, flags);
322 270
323 /* 271 /*
@@ -325,20 +273,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
325 */ 273 */
326 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { 274 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) {
327 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); 275 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState);
328/*
329** 15.10.1998 ARG - ESIL 0759
330** (Part) fix for port being trashed when opened whilst RTA "disconnected"
331** Take out the limited wait - now wait for ever or until user
332** bangs us out.
333**
334 if (repeat_this -- <= 0) {
335 rio_dprint(RIO_DEBUG_TTY, ("Waiting for open to finish timed out.\n"));
336 RIOPreemptiveCmd(p, PortP, FCLOSE );
337 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
338 return -EINTR;
339 }
340**
341*/
342 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 276 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
343 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 277 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
344 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); 278 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)
358 } 292 }
359 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); 293 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
360 } 294 }
361#ifdef MODEM_SUPPORT 295 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
362 if (Modem) { 296 /*
363 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); 297 ** ACTION
298 ** insert test for carrier here. -- ???
299 ** I already see that test here. What's the deal? -- REW
300 */
301 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
302 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
364 /* 303 /*
365 ** ACTION 304 tp->tm.c_state |= CARR_ON;
366 ** insert test for carrier here. -- ??? 305 wakeup((caddr_t) &tp->tm.c_canq);
367 ** I already see that test here. What's the deal? -- REW
368 */ 306 */
369 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { 307 PortP->State |= RIO_CARR_ON;
370 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); 308 wake_up_interruptible(&PortP->gs.open_wait);
309 } else { /* no carrier - wait for DCD */
371 /* 310 /*
372 tp->tm.c_state |= CARR_ON; 311 while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
373 wakeup((caddr_t) &tp->tm.c_canq); 312 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
374 */ 313 */
375 PortP->State |= RIO_CARR_ON; 314 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
376 wake_up_interruptible(&PortP->gs.open_wait); 315 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
377 } else { /* no carrier - wait for DCD */
378
379 /* 316 /*
380 while (!(PortP->gs.tty->termios->c_state & CARR_ON) && 317 PortP->gs.tty->termios->c_state |= WOPEN;
381 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
382 */ 318 */
383 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { 319 PortP->State |= RIO_WOPEN;
384 320 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
385 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); 321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
386 /* 322 /*
387 PortP->gs.tty->termios->c_state |= WOPEN; 323 ** ACTION: verify that this is a good thing
324 ** to do here. -- ???
325 ** I think it's OK. -- REW
388 */ 326 */
389 PortP->State |= RIO_WOPEN; 327 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
328 RIOPreemptiveCmd(p, PortP, FCLOSE);
329 /*
330 tp->tm.c_state &= ~WOPEN;
331 */
332 PortP->State &= ~RIO_WOPEN;
390 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 333 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
391 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) 334 func_exit();
392 { 335 return -EINTR;
393 /*
394 ** ACTION: verify that this is a good thing
395 ** to do here. -- ???
396 ** I think it's OK. -- REW
397 */
398 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
399 RIOPreemptiveCmd(p, PortP, FCLOSE);
400 /*
401 tp->tm.c_state &= ~WOPEN;
402 */
403 PortP->State &= ~RIO_WOPEN;
404 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
405 func_exit();
406 return -EINTR;
407 }
408 } 336 }
409 PortP->State &= ~RIO_WOPEN;
410 } 337 }
411 if (p->RIOHalted) 338 PortP->State &= ~RIO_WOPEN;
412 goto bombout;
413 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
414 PortP->State |= RIO_MOPEN;
415 } else
416#endif
417 {
418 /*
419 ** ACTION
420 ** Direct line open - force carrier (will probably mean
421 ** that sleeping Modem line fubar)
422 */
423 PortP->State |= RIO_LOPEN;
424 } 339 }
340 if (p->RIOHalted)
341 goto bombout;
342 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
343 PortP->State |= RIO_MOPEN;
425 344
426 if (p->RIOHalted) { 345 if (p->RIOHalted)
427 goto bombout; 346 goto bombout;
428 }
429 347
430 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); 348 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
431 349
432#ifdef STATS
433 PortP->Stat.OpenCnt++;
434#endif
435 /* 350 /*
436 ** Count opens for port statistics reporting 351 ** Count opens for port statistics reporting
437 */ 352 */
@@ -460,23 +375,21 @@ int riotclose(void *ptr)
460 unsigned long end_time; 375 unsigned long end_time;
461 struct tty_struct *tty; 376 struct tty_struct *tty;
462 unsigned long flags; 377 unsigned long flags;
463 int Modem;
464 int rv = 0; 378 int rv = 0;
465 379
466 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum); 380 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
467 381
468 /* PortP = p->RIOPortp[SysPort]; */ 382 /* PortP = p->RIOPortp[SysPort]; */
469 rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP); 383 rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP);
470 /* tp = PortP->TtyP; *//* Get tty */ 384 /* tp = PortP->TtyP; *//* Get tty */
471 tty = PortP->gs.tty; 385 tty = PortP->gs.tty;
472 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty); 386 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty);
473 387
474 if (PortP->gs.closing_wait) 388 if (PortP->gs.closing_wait)
475 end_time = jiffies + PortP->gs.closing_wait; 389 end_time = jiffies + PortP->gs.closing_wait;
476 else 390 else
477 end_time = jiffies + MAX_SCHEDULE_TIMEOUT; 391 end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
478 392
479 Modem = rio_ismodem(tty);
480 rio_spin_lock_irqsave(&PortP->portSem, flags); 393 rio_spin_lock_irqsave(&PortP->portSem, flags);
481 394
482 /* 395 /*
@@ -500,7 +413,7 @@ int riotclose(void *ptr)
500 /* 413 /*
501 ** clear the open bits for this device 414 ** clear the open bits for this device
502 */ 415 */
503 PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN); 416 PortP->State &= ~RIO_MOPEN;
504 PortP->State &= ~RIO_CARR_ON; 417 PortP->State &= ~RIO_CARR_ON;
505 PortP->ModemState &= ~MSVR1_CD; 418 PortP->ModemState &= ~MSVR1_CD;
506 /* 419 /*
@@ -536,7 +449,6 @@ int riotclose(void *ptr)
536 449
537 if (!deleted) 450 if (!deleted)
538 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) { 451 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
539 cprintf("Need to flush the ttyport\n");
540 if (repeat_this-- <= 0) { 452 if (repeat_this-- <= 0) {
541 rv = -EINTR; 453 rv = -EINTR;
542 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 454 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
@@ -615,16 +527,13 @@ int riotclose(void *ptr)
615*/ 527*/
616 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); 528 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
617 529
618#ifdef STATS
619 PortP->Stat.CloseCnt++;
620#endif
621 /* 530 /*
622 ** Count opens for port statistics reporting 531 ** Count opens for port statistics reporting
623 */ 532 */
624 if (PortP->statsGather) 533 if (PortP->statsGather)
625 PortP->closes++; 534 PortP->closes++;
626 535
627 close_end: 536close_end:
628 /* XXX: Why would a "DELETED" flag be reset here? I'd have 537 /* XXX: Why would a "DELETED" flag be reset here? I'd have
629 thought that a "deleted" flag means that the port was 538 thought that a "deleted" flag means that the port was
630 permanently gone, but here we can make it reappear by it 539 permanently gone, but here we can make it reappear by it
@@ -640,8 +549,7 @@ int riotclose(void *ptr)
640 549
641 550
642 551
643static void RIOClearUp(PortP) 552static void RIOClearUp(struct Port *PortP)
644struct Port *PortP;
645{ 553{
646 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n"); 554 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n");
647 PortP->Config = 0; /* Direct semaphore */ 555 PortP->Config = 0; /* Direct semaphore */
@@ -668,7 +576,7 @@ struct Port *PortP;
668*/ 576*/
669int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) 577int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg)
670{ 578{
671 PKT *PacketP; 579 struct PKT *PacketP;
672 int retries = 20; /* at 10 per second -> 2 seconds */ 580 int retries = 20; /* at 10 per second -> 2 seconds */
673 unsigned long flags; 581 unsigned long flags;
674 582
@@ -722,15 +630,15 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len
722 /* 630 /*
723 ** set the command byte and the argument byte 631 ** set the command byte and the argument byte
724 */ 632 */
725 WBYTE(PacketP->data[0], command); 633 writeb(command, &PacketP->data[0]);
726 634
727 if (len == 2) 635 if (len == 2)
728 WBYTE(PacketP->data[1], arg); 636 writeb(arg, &PacketP->data[1]);
729 637
730 /* 638 /*
731 ** set the length of the packet and set the command bit. 639 ** set the length of the packet and set the command bit.
732 */ 640 */
733 WBYTE(PacketP->len, PKT_CMD_BIT | len); 641 writeb(PKT_CMD_BIT | len, &PacketP->len);
734 642
735 add_transmit(PortP); 643 add_transmit(PortP);
736 /* 644 /*
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
deleted file mode 100644
index 46084d5c7e98..000000000000
--- a/drivers/char/rio/riotypes.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* R I O T Y P E S
4 ******* *******
5 ****************************************************************************
6
7 Author : Jon Brawn
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36
37#ifndef _riotypes_h
38#define _riotypes_h 1
39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_riotypes_h_sccs = "@(#)riotypes.h 1.10"; */
43#endif
44#endif
45
46typedef unsigned short NUMBER_ptr;
47typedef unsigned short WORD_ptr;
48typedef unsigned short BYTE_ptr;
49typedef unsigned short char_ptr;
50typedef unsigned short Channel_ptr;
51typedef unsigned short FREE_LIST_ptr_ptr;
52typedef unsigned short FREE_LIST_ptr;
53typedef unsigned short LPB_ptr;
54typedef unsigned short Process_ptr;
55typedef unsigned short PHB_ptr;
56typedef unsigned short PKT_ptr;
57typedef unsigned short PKT_ptr_ptr;
58typedef unsigned short Q_BUF_ptr;
59typedef unsigned short Q_BUF_ptr_ptr;
60typedef unsigned short ROUTE_STR_ptr;
61typedef unsigned short RUP_ptr;
62typedef unsigned short short_ptr;
63typedef unsigned short u_short_ptr;
64typedef unsigned short ushort_ptr;
65
66#endif /* __riotypes__ */
67
68/*********** end of file ***********/
diff --git a/drivers/char/rio/rom.h b/drivers/char/rio/rom.h
deleted file mode 100644
index 58a7843625ff..000000000000
--- a/drivers/char/rio/rom.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* R O M
4 ******* *******
5 ****************************************************************************
6
7 Author : Ian Nandhra
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36
37#ifndef _rom_h
38#define _rom_h 1
39
40#ifndef lint
41#ifdef SCCS
42static char *_rio_rom_h_sccs = "@(#)rom.h 1.1";
43#endif
44#endif
45
46typedef struct ROM ROM;
47struct ROM {
48 u_short slx;
49 char pcb_letter_rev;
50 char pcb_number_rev;
51 char serial[4];
52 char year;
53 char week;
54};
55
56#endif
57
58#define HOST_ROM (ROM *) 0x7c00
59#define RTA_ROM (ROM *) 0x7801
60#define ROM_LENGTH 0x20
61
62/*********** end of file ***********/
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index f74f67c6f702..4ae90cb207a9 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -37,14 +37,7 @@
37#ifndef _rup_h 37#ifndef _rup_h
38#define _rup_h 1 38#define _rup_h 1
39 39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_rup_h_sccs = "@(#)rup.h 1.5"; */
43#endif
44#endif
45
46#define MAX_RUP ((short) 16) 40#define MAX_RUP ((short) 16)
47
48#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */ 41#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
49 42
50/************************************************* 43/*************************************************
@@ -60,15 +53,15 @@
60#define RUP_NO_OWNER 0xff /* RUP not owned by any process */ 53#define RUP_NO_OWNER 0xff /* RUP not owned by any process */
61 54
62struct RUP { 55struct RUP {
63 PKT_ptr txpkt; /* Outgoing packet */ 56 u16 txpkt; /* Outgoing packet */
64 PKT_ptr rxpkt; /* Incoming packet */ 57 u16 rxpkt; /* Incoming packet */
65 WORD link; /* Which link to send down? */ 58 u16 link; /* Which link to send down? */
66 BYTE rup_dest_unit[2]; /* Destination unit */ 59 u8 rup_dest_unit[2]; /* Destination unit */
67 WORD handshake; /* For handshaking */ 60 u16 handshake; /* For handshaking */
68 WORD timeout; /* Timeout */ 61 u16 timeout; /* Timeout */
69 WORD status; /* Status */ 62 u16 status; /* Status */
70 WORD txcontrol; /* Transmit control */ 63 u16 txcontrol; /* Transmit control */
71 WORD rxcontrol; /* Receive control */ 64 u16 rxcontrol; /* Receive control */
72}; 65};
73 66
74#endif 67#endif
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
deleted file mode 100644
index 6f754e19015d..000000000000
--- a/drivers/char/rio/sam.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* S A M . H
4 ******* *******
5 ****************************************************************************
6
7 Author : Ian Nandhra
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36#ifndef _sam_h
37#define _sam_h 1
38
39#ifdef SCCS_LABELS
40#ifndef lint
41/* static char *_rio_sam_h_sccs = "@(#)sam.h 1.3"; */
42#endif
43#endif
44
45
46#define NUM_FREE_LIST_UNITS 500
47
48#ifndef FALSE
49#define FALSE (short) 0x00
50#endif
51#ifndef TRUE
52#define TRUE (short) !FALSE
53#endif
54
55#define TX TRUE
56#define RX FALSE
57
58
59typedef struct FREE_LIST FREE_LIST;
60struct FREE_LIST {
61 FREE_LIST_ptr next;
62 FREE_LIST_ptr prev;
63};
64
65
66#endif
67/*********** end of file ***********/
diff --git a/drivers/char/rio/space.h b/drivers/char/rio/space.h
deleted file mode 100644
index 1f12690f9d1f..000000000000
--- a/drivers/char/rio/space.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : space.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:19
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)space.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_space_h__
34#define __rio_space_h__
35
36#ifdef SCCS_LABELS
37static char *_space_h_sccs_ = "@(#)space.h 1.2";
38#endif
39
40extern int rio_cntls;
41extern int rio_bases[];
42extern int rio_limits[];
43extern int rio_vects[];
44
45#endif /* __rio_space_h__ */
diff --git a/drivers/char/rio/top.h b/drivers/char/rio/top.h
deleted file mode 100644
index d15a11dc4f73..000000000000
--- a/drivers/char/rio/top.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : top.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:19
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)top.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_top_h__
34#define __rio_top_h__
35
36#ifdef SCCS_LABELS
37static char *_top_h_sccs_ = "@(#)top.h 1.2";
38#endif
39
40/*
41** Topology information
42*/
43struct Top {
44 uchar Unit;
45 uchar Link;
46};
47
48#endif /* __rio_top_h__ */
diff --git a/drivers/char/rio/typdef.h b/drivers/char/rio/typdef.h
deleted file mode 100644
index 185b889e1510..000000000000
--- a/drivers/char/rio/typdef.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : typdef.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:20
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)typdef.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_typdef_h__
34#define __rio_typdef_h__
35
36#ifdef SCCS_LABELS
37static char *_typdef_h_sccs_ = "@(#)typdef.h 1.2";
38#endif
39
40#undef VPIX
41
42/*
43** IT IS REALLY, REALLY, IMPORTANT THAT BYTES ARE UNSIGNED!
44**
45** These types are ONLY to be used for refering to data structures
46** on the RIO Host card!
47*/
48typedef volatile unsigned char BYTE;
49typedef volatile unsigned short WORD;
50typedef volatile unsigned int DWORD;
51typedef volatile unsigned short RIOP;
52typedef volatile short NUMBER;
53
54
55/*
56** 27.01.199 ARG - mods to compile 'newutils' on LyxnOS -
57** These #defines are for the benefit of the 'libfuncs' library
58** only. They are not necessarily correct type mappings and
59** are here only to make the source compile.
60*/
61/* typedef unsigned int uint; */
62typedef unsigned long ulong_t;
63typedef unsigned short ushort_t;
64typedef unsigned char uchar_t;
65typedef unsigned char queue_t;
66typedef unsigned char mblk_t;
67typedef unsigned int paddr_t;
68typedef unsigned char uchar;
69
70#define TPNULL ((ushort)(0x8000))
71
72
73/*
74** RIO structures defined in other include files.
75*/
76typedef struct PKT PKT;
77typedef struct LPB LPB;
78typedef struct RUP RUP;
79typedef struct Port Port;
80typedef struct DpRam DpRam;
81
82#endif /* __rio_typdef_h__ */
diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h
index a126c7cabac6..4306e01dbf01 100644
--- a/drivers/char/rio/unixrup.h
+++ b/drivers/char/rio/unixrup.h
@@ -45,9 +45,9 @@ struct UnixRup {
45 struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */ 45 struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */
46 struct CmdBlk *CmdPendingP; /* The command currently being sent */ 46 struct CmdBlk *CmdPendingP; /* The command currently being sent */
47 struct RUP *RupP; /* the Rup to send it to */ 47 struct RUP *RupP; /* the Rup to send it to */
48 uint Id; /* Id number */ 48 unsigned int Id; /* Id number */
49 uint BaseSysPort; /* SysPort of first tty on this RTA */ 49 unsigned int BaseSysPort; /* SysPort of first tty on this RTA */
50 uint ModTypes; /* Modules on this RTA */ 50 unsigned int ModTypes; /* Modules on this RTA */
51 spinlock_t RupLock; /* Lock structure for MPX */ 51 spinlock_t RupLock; /* Lock structure for MPX */
52 /* struct lockb RupLock; *//* Lock structure for MPX */ 52 /* struct lockb RupLock; *//* Lock structure for MPX */
53}; 53};
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 119e629656b7..657c0d88f48c 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1743,10 +1743,10 @@ static int iobase;
1743static int iobase1; 1743static int iobase1;
1744static int iobase2; 1744static int iobase2;
1745static int iobase3; 1745static int iobase3;
1746MODULE_PARM(iobase, "i"); 1746module_param(iobase, int, 0);
1747MODULE_PARM(iobase1, "i"); 1747module_param(iobase1, int, 0);
1748MODULE_PARM(iobase2, "i"); 1748module_param(iobase2, int, 0);
1749MODULE_PARM(iobase3, "i"); 1749module_param(iobase3, int, 0);
1750 1750
1751MODULE_LICENSE("GPL"); 1751MODULE_LICENSE("GPL");
1752#endif /* MODULE */ 1752#endif /* MODULE */
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index ede688a4e141..d68be61f0a49 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,
7770 } 7770 }
7771 7771
7772 info->params.encoding = new_encoding; 7772 info->params.encoding = new_encoding;
7773 info->params.crc_type = new_crctype;; 7773 info->params.crc_type = new_crctype;
7774 7774
7775 /* if network interface up, reprogram hardware */ 7775 /* if network interface up, reprogram hardware */
7776 if (info->netcount) 7776 if (info->netcount)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index b046390cd256..738ec2f4e563 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,
1365 } 1365 }
1366 1366
1367 info->params.encoding = new_encoding; 1367 info->params.encoding = new_encoding;
1368 info->params.crc_type = new_crctype;; 1368 info->params.crc_type = new_crctype;
1369 1369
1370 /* if network interface up, reprogram hardware */ 1370 /* if network interface up, reprogram hardware */
1371 if (info->netcount) 1371 if (info->netcount)
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 960adb256fbb..858740131115 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,
1650 } 1650 }
1651 1651
1652 info->params.encoding = new_encoding; 1652 info->params.encoding = new_encoding;
1653 info->params.crc_type = new_crctype;; 1653 info->params.crc_type = new_crctype;
1654 1654
1655 /* if network interface up, reprogram hardware */ 1655 /* if network interface up, reprogram hardware */
1656 if (info->netcount) 1656 if (info->netcount)
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index d58f82318853..35082dc12eae 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -42,16 +42,15 @@
42/* Whether we react on sysrq keys or just ignore them */ 42/* Whether we react on sysrq keys or just ignore them */
43int sysrq_enabled = 1; 43int sysrq_enabled = 1;
44 44
45/* Loglevel sysrq handler */
46static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs, 45static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs,
47 struct tty_struct *tty) 46 struct tty_struct *tty)
48{ 47{
49 int i; 48 int i;
50 i = key - '0'; 49 i = key - '0';
51 console_loglevel = 7; 50 console_loglevel = 7;
52 printk("Loglevel set to %d\n", i); 51 printk("Loglevel set to %d\n", i);
53 console_loglevel = i; 52 console_loglevel = i;
54} 53}
55static struct sysrq_key_op sysrq_loglevel_op = { 54static struct sysrq_key_op sysrq_loglevel_op = {
56 .handler = sysrq_handle_loglevel, 55 .handler = sysrq_handle_loglevel,
57 .help_msg = "loglevel0-8", 56 .help_msg = "loglevel0-8",
@@ -59,11 +58,9 @@ static struct sysrq_key_op sysrq_loglevel_op = {
59 .enable_mask = SYSRQ_ENABLE_LOG, 58 .enable_mask = SYSRQ_ENABLE_LOG,
60}; 59};
61 60
62
63/* SAK sysrq handler */
64#ifdef CONFIG_VT 61#ifdef CONFIG_VT
65static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs, 62static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs,
66 struct tty_struct *tty) 63 struct tty_struct *tty)
67{ 64{
68 if (tty) 65 if (tty)
69 do_SAK(tty); 66 do_SAK(tty);
@@ -75,12 +72,13 @@ static struct sysrq_key_op sysrq_SAK_op = {
75 .action_msg = "SAK", 72 .action_msg = "SAK",
76 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 73 .enable_mask = SYSRQ_ENABLE_KEYBOARD,
77}; 74};
75#else
76#define sysrq_SAK_op (*(struct sysrq_key_op *)0)
78#endif 77#endif
79 78
80#ifdef CONFIG_VT 79#ifdef CONFIG_VT
81/* unraw sysrq handler */
82static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs, 80static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs,
83 struct tty_struct *tty) 81 struct tty_struct *tty)
84{ 82{
85 struct kbd_struct *kbd = &kbd_table[fg_console]; 83 struct kbd_struct *kbd = &kbd_table[fg_console];
86 84
@@ -93,10 +91,11 @@ static struct sysrq_key_op sysrq_unraw_op = {
93 .action_msg = "Keyboard mode set to XLATE", 91 .action_msg = "Keyboard mode set to XLATE",
94 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 92 .enable_mask = SYSRQ_ENABLE_KEYBOARD,
95}; 93};
94#else
95#define sysrq_unraw_op (*(struct sysrq_key_op *)0)
96#endif /* CONFIG_VT */ 96#endif /* CONFIG_VT */
97 97
98#ifdef CONFIG_KEXEC 98#ifdef CONFIG_KEXEC
99/* crashdump sysrq handler */
100static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, 99static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs,
101 struct tty_struct *tty) 100 struct tty_struct *tty)
102{ 101{
@@ -108,16 +107,16 @@ static struct sysrq_key_op sysrq_crashdump_op = {
108 .action_msg = "Trigger a crashdump", 107 .action_msg = "Trigger a crashdump",
109 .enable_mask = SYSRQ_ENABLE_DUMP, 108 .enable_mask = SYSRQ_ENABLE_DUMP,
110}; 109};
110#else
111#define sysrq_crashdump_op (*(struct sysrq_key_op *)0)
111#endif 112#endif
112 113
113/* reboot sysrq handler */
114static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, 114static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs,
115 struct tty_struct *tty) 115 struct tty_struct *tty)
116{ 116{
117 local_irq_enable(); 117 local_irq_enable();
118 emergency_restart(); 118 emergency_restart();
119} 119}
120
121static struct sysrq_key_op sysrq_reboot_op = { 120static struct sysrq_key_op sysrq_reboot_op = {
122 .handler = sysrq_handle_reboot, 121 .handler = sysrq_handle_reboot,
123 .help_msg = "reBoot", 122 .help_msg = "reBoot",
@@ -126,11 +125,10 @@ static struct sysrq_key_op sysrq_reboot_op = {
126}; 125};
127 126
128static void sysrq_handle_sync(int key, struct pt_regs *pt_regs, 127static void sysrq_handle_sync(int key, struct pt_regs *pt_regs,
129 struct tty_struct *tty) 128 struct tty_struct *tty)
130{ 129{
131 emergency_sync(); 130 emergency_sync();
132} 131}
133
134static struct sysrq_key_op sysrq_sync_op = { 132static struct sysrq_key_op sysrq_sync_op = {
135 .handler = sysrq_handle_sync, 133 .handler = sysrq_handle_sync,
136 .help_msg = "Sync", 134 .help_msg = "Sync",
@@ -139,11 +137,10 @@ static struct sysrq_key_op sysrq_sync_op = {
139}; 137};
140 138
141static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs, 139static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs,
142 struct tty_struct *tty) 140 struct tty_struct *tty)
143{ 141{
144 emergency_remount(); 142 emergency_remount();
145} 143}
146
147static struct sysrq_key_op sysrq_mountro_op = { 144static struct sysrq_key_op sysrq_mountro_op = {
148 .handler = sysrq_handle_mountro, 145 .handler = sysrq_handle_mountro,
149 .help_msg = "Unmount", 146 .help_msg = "Unmount",
@@ -151,28 +148,23 @@ static struct sysrq_key_op sysrq_mountro_op = {
151 .enable_mask = SYSRQ_ENABLE_REMOUNT, 148 .enable_mask = SYSRQ_ENABLE_REMOUNT,
152}; 149};
153 150
154/* END SYNC SYSRQ HANDLERS BLOCK */
155
156#ifdef CONFIG_DEBUG_MUTEXES 151#ifdef CONFIG_DEBUG_MUTEXES
157 152static void sysrq_handle_showlocks(int key, struct pt_regs *pt_regs,
158static void 153 struct tty_struct *tty)
159sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
160{ 154{
161 mutex_debug_show_all_locks(); 155 mutex_debug_show_all_locks();
162} 156}
163
164static struct sysrq_key_op sysrq_showlocks_op = { 157static struct sysrq_key_op sysrq_showlocks_op = {
165 .handler = sysrq_handle_showlocks, 158 .handler = sysrq_handle_showlocks,
166 .help_msg = "show-all-locks(D)", 159 .help_msg = "show-all-locks(D)",
167 .action_msg = "Show Locks Held", 160 .action_msg = "Show Locks Held",
168}; 161};
169 162#else
163#define sysrq_showlocks_op (*(struct sysrq_key_op *)0)
170#endif 164#endif
171 165
172/* SHOW SYSRQ HANDLERS BLOCK */
173
174static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs, 166static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs,
175 struct tty_struct *tty) 167 struct tty_struct *tty)
176{ 168{
177 if (pt_regs) 169 if (pt_regs)
178 show_regs(pt_regs); 170 show_regs(pt_regs);
@@ -184,9 +176,8 @@ static struct sysrq_key_op sysrq_showregs_op = {
184 .enable_mask = SYSRQ_ENABLE_DUMP, 176 .enable_mask = SYSRQ_ENABLE_DUMP,
185}; 177};
186 178
187
188static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs, 179static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs,
189 struct tty_struct *tty) 180 struct tty_struct *tty)
190{ 181{
191 show_state(); 182 show_state();
192} 183}
@@ -197,9 +188,8 @@ static struct sysrq_key_op sysrq_showstate_op = {
197 .enable_mask = SYSRQ_ENABLE_DUMP, 188 .enable_mask = SYSRQ_ENABLE_DUMP,
198}; 189};
199 190
200
201static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs, 191static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs,
202 struct tty_struct *tty) 192 struct tty_struct *tty)
203{ 193{
204 show_mem(); 194 show_mem();
205} 195}
@@ -210,13 +200,9 @@ static struct sysrq_key_op sysrq_showmem_op = {
210 .enable_mask = SYSRQ_ENABLE_DUMP, 200 .enable_mask = SYSRQ_ENABLE_DUMP,
211}; 201};
212 202
213/* SHOW SYSRQ HANDLERS BLOCK */ 203/*
214 204 * Signal sysrq helper function. Sends a signal to all user processes.
215 205 */
216/* SIGNAL SYSRQ HANDLERS BLOCK */
217
218/* signal sysrq helper function
219 * Sends a signal to all user processes */
220static void send_sig_all(int sig) 206static void send_sig_all(int sig)
221{ 207{
222 struct task_struct *p; 208 struct task_struct *p;
@@ -229,7 +215,7 @@ static void send_sig_all(int sig)
229} 215}
230 216
231static void sysrq_handle_term(int key, struct pt_regs *pt_regs, 217static void sysrq_handle_term(int key, struct pt_regs *pt_regs,
232 struct tty_struct *tty) 218 struct tty_struct *tty)
233{ 219{
234 send_sig_all(SIGTERM); 220 send_sig_all(SIGTERM);
235 console_loglevel = 8; 221 console_loglevel = 8;
@@ -243,7 +229,8 @@ static struct sysrq_key_op sysrq_term_op = {
243 229
244static void moom_callback(void *ignored) 230static void moom_callback(void *ignored)
245{ 231{
246 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], GFP_KERNEL, 0); 232 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
233 GFP_KERNEL, 0);
247} 234}
248 235
249static DECLARE_WORK(moom_work, moom_callback, NULL); 236static DECLARE_WORK(moom_work, moom_callback, NULL);
@@ -260,7 +247,7 @@ static struct sysrq_key_op sysrq_moom_op = {
260}; 247};
261 248
262static void sysrq_handle_kill(int key, struct pt_regs *pt_regs, 249static void sysrq_handle_kill(int key, struct pt_regs *pt_regs,
263 struct tty_struct *tty) 250 struct tty_struct *tty)
264{ 251{
265 send_sig_all(SIGKILL); 252 send_sig_all(SIGKILL);
266 console_loglevel = 8; 253 console_loglevel = 8;
@@ -272,8 +259,6 @@ static struct sysrq_key_op sysrq_kill_op = {
272 .enable_mask = SYSRQ_ENABLE_SIGNAL, 259 .enable_mask = SYSRQ_ENABLE_SIGNAL,
273}; 260};
274 261
275/* END SIGNAL SYSRQ HANDLERS BLOCK */
276
277static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs, 262static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs,
278 struct tty_struct *tty) 263 struct tty_struct *tty)
279{ 264{
@@ -288,110 +273,99 @@ static struct sysrq_key_op sysrq_unrt_op = {
288 273
289/* Key Operations table and lock */ 274/* Key Operations table and lock */
290static DEFINE_SPINLOCK(sysrq_key_table_lock); 275static DEFINE_SPINLOCK(sysrq_key_table_lock);
291#define SYSRQ_KEY_TABLE_LENGTH 36 276
292static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = { 277static struct sysrq_key_op *sysrq_key_table[36] = {
293/* 0 */ &sysrq_loglevel_op, 278 &sysrq_loglevel_op, /* 0 */
294/* 1 */ &sysrq_loglevel_op, 279 &sysrq_loglevel_op, /* 1 */
295/* 2 */ &sysrq_loglevel_op, 280 &sysrq_loglevel_op, /* 2 */
296/* 3 */ &sysrq_loglevel_op, 281 &sysrq_loglevel_op, /* 3 */
297/* 4 */ &sysrq_loglevel_op, 282 &sysrq_loglevel_op, /* 4 */
298/* 5 */ &sysrq_loglevel_op, 283 &sysrq_loglevel_op, /* 5 */
299/* 6 */ &sysrq_loglevel_op, 284 &sysrq_loglevel_op, /* 6 */
300/* 7 */ &sysrq_loglevel_op, 285 &sysrq_loglevel_op, /* 7 */
301/* 8 */ &sysrq_loglevel_op, 286 &sysrq_loglevel_op, /* 8 */
302/* 9 */ &sysrq_loglevel_op, 287 &sysrq_loglevel_op, /* 9 */
303/* a */ NULL, /* Don't use for system provided sysrqs, 288
304 it is handled specially on the sparc 289 /*
305 and will never arrive */ 290 * Don't use for system provided sysrqs, it is handled specially on
306/* b */ &sysrq_reboot_op, 291 * sparc and will never arrive
307#ifdef CONFIG_KEXEC 292 */
308/* c */ &sysrq_crashdump_op, 293 NULL, /* a */
309#else 294 &sysrq_reboot_op, /* b */
310/* c */ NULL, 295 &sysrq_crashdump_op, /* c */
311#endif 296 &sysrq_showlocks_op, /* d */
312#ifdef CONFIG_DEBUG_MUTEXES 297 &sysrq_term_op, /* e */
313/* d */ &sysrq_showlocks_op, 298 &sysrq_moom_op, /* f */
314#else 299 NULL, /* g */
315/* d */ NULL, 300 NULL, /* h */
316#endif 301 &sysrq_kill_op, /* i */
317/* e */ &sysrq_term_op, 302 NULL, /* j */
318/* f */ &sysrq_moom_op, 303 &sysrq_SAK_op, /* k */
319/* g */ NULL, 304 NULL, /* l */
320/* h */ NULL, 305 &sysrq_showmem_op, /* m */
321/* i */ &sysrq_kill_op, 306 &sysrq_unrt_op, /* n */
322/* j */ NULL, 307 /* This will often be registered as 'Off' at init time */
323#ifdef CONFIG_VT 308 NULL, /* o */
324/* k */ &sysrq_SAK_op, 309 &sysrq_showregs_op, /* p */
325#else 310 NULL, /* q */
326/* k */ NULL, 311 &sysrq_unraw_op, /* r */
327#endif 312 &sysrq_sync_op, /* s */
328/* l */ NULL, 313 &sysrq_showstate_op, /* t */
329/* m */ &sysrq_showmem_op, 314 &sysrq_mountro_op, /* u */
330/* n */ &sysrq_unrt_op, 315 /* May be assigned at init time by SMP VOYAGER */
331/* o */ NULL, /* This will often be registered 316 NULL, /* v */
332 as 'Off' at init time */ 317 NULL, /* w */
333/* p */ &sysrq_showregs_op, 318 NULL, /* x */
334/* q */ NULL, 319 NULL, /* y */
335#ifdef CONFIG_VT 320 NULL /* z */
336/* r */ &sysrq_unraw_op,
337#else
338/* r */ NULL,
339#endif
340/* s */ &sysrq_sync_op,
341/* t */ &sysrq_showstate_op,
342/* u */ &sysrq_mountro_op,
343/* v */ NULL, /* May be assigned at init time by SMP VOYAGER */
344/* w */ NULL,
345/* x */ NULL,
346/* y */ NULL,
347/* z */ NULL
348}; 321};
349 322
350/* key2index calculation, -1 on invalid index */ 323/* key2index calculation, -1 on invalid index */
351static int sysrq_key_table_key2index(int key) { 324static int sysrq_key_table_key2index(int key)
325{
352 int retval; 326 int retval;
353 if ((key >= '0') && (key <= '9')) { 327
328 if ((key >= '0') && (key <= '9'))
354 retval = key - '0'; 329 retval = key - '0';
355 } else if ((key >= 'a') && (key <= 'z')) { 330 else if ((key >= 'a') && (key <= 'z'))
356 retval = key + 10 - 'a'; 331 retval = key + 10 - 'a';
357 } else { 332 else
358 retval = -1; 333 retval = -1;
359 }
360 return retval; 334 return retval;
361} 335}
362 336
363/* 337/*
364 * get and put functions for the table, exposed to modules. 338 * get and put functions for the table, exposed to modules.
365 */ 339 */
366 340struct sysrq_key_op *__sysrq_get_key_op(int key)
367struct sysrq_key_op *__sysrq_get_key_op (int key) { 341{
368 struct sysrq_key_op *op_p; 342 struct sysrq_key_op *op_p = NULL;
369 int i; 343 int i;
370 344
371 i = sysrq_key_table_key2index(key); 345 i = sysrq_key_table_key2index(key);
372 op_p = (i == -1) ? NULL : sysrq_key_table[i]; 346 if (i != -1)
347 op_p = sysrq_key_table[i];
373 return op_p; 348 return op_p;
374} 349}
375 350
376static void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p) { 351static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
377 int i; 352{
353 int i = sysrq_key_table_key2index(key);
378 354
379 i = sysrq_key_table_key2index(key);
380 if (i != -1) 355 if (i != -1)
381 sysrq_key_table[i] = op_p; 356 sysrq_key_table[i] = op_p;
382} 357}
383 358
384/* 359/*
385 * This is the non-locking version of handle_sysrq 360 * This is the non-locking version of handle_sysrq. It must/can only be called
386 * It must/can only be called by sysrq key handlers, 361 * by sysrq key handlers, as they are inside of the lock
387 * as they are inside of the lock
388 */ 362 */
389 363void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
390void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, int check_mask) 364 int check_mask)
391{ 365{
392 struct sysrq_key_op *op_p; 366 struct sysrq_key_op *op_p;
393 int orig_log_level; 367 int orig_log_level;
394 int i, j; 368 int i;
395 unsigned long flags; 369 unsigned long flags;
396 370
397 spin_lock_irqsave(&sysrq_key_table_lock, flags); 371 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
401 375
402 op_p = __sysrq_get_key_op(key); 376 op_p = __sysrq_get_key_op(key);
403 if (op_p) { 377 if (op_p) {
404 /* Should we check for enabled operations (/proc/sysrq-trigger should not) 378 /*
405 * and is the invoked operation enabled? */ 379 * Should we check for enabled operations (/proc/sysrq-trigger
380 * should not) and is the invoked operation enabled?
381 */
406 if (!check_mask || sysrq_enabled == 1 || 382 if (!check_mask || sysrq_enabled == 1 ||
407 (sysrq_enabled & op_p->enable_mask)) { 383 (sysrq_enabled & op_p->enable_mask)) {
408 printk ("%s\n", op_p->action_msg); 384 printk("%s\n", op_p->action_msg);
409 console_loglevel = orig_log_level; 385 console_loglevel = orig_log_level;
410 op_p->handler(key, pt_regs, tty); 386 op_p->handler(key, pt_regs, tty);
411 } 387 } else {
412 else
413 printk("This sysrq operation is disabled.\n"); 388 printk("This sysrq operation is disabled.\n");
389 }
414 } else { 390 } else {
415 printk("HELP : "); 391 printk("HELP : ");
416 /* Only print the help msg once per handler */ 392 /* Only print the help msg once per handler */
417 for (i=0; i<SYSRQ_KEY_TABLE_LENGTH; i++) 393 for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) {
418 if (sysrq_key_table[i]) { 394 if (sysrq_key_table[i]) {
419 for (j=0; sysrq_key_table[i] != sysrq_key_table[j]; j++); 395 int j;
420 if (j == i) 396
421 printk ("%s ", sysrq_key_table[i]->help_msg); 397 for (j = 0; sysrq_key_table[i] !=
398 sysrq_key_table[j]; j++)
399 ;
400 if (j != i)
401 continue;
402 printk("%s ", sysrq_key_table[i]->help_msg);
403 }
422 } 404 }
423 printk ("\n"); 405 printk("\n");
424 console_loglevel = orig_log_level; 406 console_loglevel = orig_log_level;
425 } 407 }
426 spin_unlock_irqrestore(&sysrq_key_table_lock, flags); 408 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
430 * This function is called by the keyboard handler when SysRq is pressed 412 * This function is called by the keyboard handler when SysRq is pressed
431 * and any other keycode arrives. 413 * and any other keycode arrives.
432 */ 414 */
433
434void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) 415void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
435{ 416{
436 if (!sysrq_enabled) 417 if (!sysrq_enabled)
437 return; 418 return;
438 __handle_sysrq(key, pt_regs, tty, 1); 419 __handle_sysrq(key, pt_regs, tty, 1);
439} 420}
421EXPORT_SYMBOL(handle_sysrq);
440 422
441static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, 423static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
442 struct sysrq_key_op *remove_op_p) { 424 struct sysrq_key_op *remove_op_p)
425{
443 426
444 int retval; 427 int retval;
445 unsigned long flags; 428 unsigned long flags;
@@ -452,7 +435,6 @@ static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
452 retval = -1; 435 retval = -1;
453 } 436 }
454 spin_unlock_irqrestore(&sysrq_key_table_lock, flags); 437 spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
455
456 return retval; 438 return retval;
457} 439}
458 440
@@ -460,12 +442,10 @@ int register_sysrq_key(int key, struct sysrq_key_op *op_p)
460{ 442{
461 return __sysrq_swap_key_ops(key, op_p, NULL); 443 return __sysrq_swap_key_ops(key, op_p, NULL);
462} 444}
445EXPORT_SYMBOL(register_sysrq_key);
463 446
464int unregister_sysrq_key(int key, struct sysrq_key_op *op_p) 447int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
465{ 448{
466 return __sysrq_swap_key_ops(key, NULL, op_p); 449 return __sysrq_swap_key_ops(key, NULL, op_p);
467} 450}
468
469EXPORT_SYMBOL(handle_sysrq);
470EXPORT_SYMBOL(register_sysrq_key);
471EXPORT_SYMBOL(unregister_sysrq_key); 451EXPORT_SYMBOL(unregister_sysrq_key);
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index 0c6f521abd0e..e2fb234dee40 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -355,14 +355,14 @@ static void tosh_set_fn_port(void)
355/* 355/*
356 * Get the machine identification number of the current model 356 * Get the machine identification number of the current model
357 */ 357 */
358static int tosh_get_machine_id(void) 358static int tosh_get_machine_id(void __iomem *bios)
359{ 359{
360 int id; 360 int id;
361 SMMRegisters regs; 361 SMMRegisters regs;
362 unsigned short bx,cx; 362 unsigned short bx,cx;
363 unsigned long address; 363 unsigned long address;
364 364
365 id = (0x100*(int) isa_readb(0xffffe))+((int) isa_readb(0xffffa)); 365 id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa));
366 366
367 /* do we have a SCTTable machine identication number on our hands */ 367 /* do we have a SCTTable machine identication number on our hands */
368 368
@@ -388,12 +388,12 @@ static int tosh_get_machine_id(void)
388 388
389 /* now twiddle with our pointer a bit */ 389 /* now twiddle with our pointer a bit */
390 390
391 address = 0x000f0000+bx; 391 address = bx;
392 cx = isa_readw(address); 392 cx = readw(bios + address);
393 address = 0x000f0009+bx+cx; 393 address = 9+bx+cx;
394 cx = isa_readw(address); 394 cx = readw(bios + address);
395 address = 0x000f000a+cx; 395 address = 0xa+cx;
396 cx = isa_readw(address); 396 cx = readw(bios + address);
397 397
398 /* now construct our machine identification number */ 398 /* now construct our machine identification number */
399 399
@@ -416,13 +416,18 @@ static int tosh_probe(void)
416 int i,major,minor,day,year,month,flag; 416 int i,major,minor,day,year,month,flag;
417 unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 }; 417 unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 };
418 SMMRegisters regs; 418 SMMRegisters regs;
419 void __iomem *bios = ioremap(0xf0000, 0x10000);
420
421 if (!bios)
422 return -ENOMEM;
419 423
420 /* extra sanity check for the string "TOSHIBA" in the BIOS because 424 /* extra sanity check for the string "TOSHIBA" in the BIOS because
421 some machines that are not Toshiba's pass the next test */ 425 some machines that are not Toshiba's pass the next test */
422 426
423 for (i=0;i<7;i++) { 427 for (i=0;i<7;i++) {
424 if (isa_readb(0xfe010+i)!=signature[i]) { 428 if (readb(bios+0xe010+i)!=signature[i]) {
425 printk("toshiba: not a supported Toshiba laptop\n"); 429 printk("toshiba: not a supported Toshiba laptop\n");
430 iounmap(bios);
426 return -ENODEV; 431 return -ENODEV;
427 } 432 }
428 } 433 }
@@ -438,6 +443,7 @@ static int tosh_probe(void)
438 443
439 if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) { 444 if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) {
440 printk("toshiba: not a supported Toshiba laptop\n"); 445 printk("toshiba: not a supported Toshiba laptop\n");
446 iounmap(bios);
441 return -ENODEV; 447 return -ENODEV;
442 } 448 }
443 449
@@ -447,19 +453,19 @@ static int tosh_probe(void)
447 453
448 /* next get the machine ID of the current laptop */ 454 /* next get the machine ID of the current laptop */
449 455
450 tosh_id = tosh_get_machine_id(); 456 tosh_id = tosh_get_machine_id(bios);
451 457
452 /* get the BIOS version */ 458 /* get the BIOS version */
453 459
454 major = isa_readb(0xfe009)-'0'; 460 major = readb(bios+0xe009)-'0';
455 minor = ((isa_readb(0xfe00b)-'0')*10)+(isa_readb(0xfe00c)-'0'); 461 minor = ((readb(bios+0xe00b)-'0')*10)+(readb(bios+0xe00c)-'0');
456 tosh_bios = (major*0x100)+minor; 462 tosh_bios = (major*0x100)+minor;
457 463
458 /* get the BIOS date */ 464 /* get the BIOS date */
459 465
460 day = ((isa_readb(0xffff5)-'0')*10)+(isa_readb(0xffff6)-'0'); 466 day = ((readb(bios+0xfff5)-'0')*10)+(readb(bios+0xfff6)-'0');
461 month = ((isa_readb(0xffff8)-'0')*10)+(isa_readb(0xffff9)-'0'); 467 month = ((readb(bios+0xfff8)-'0')*10)+(readb(bios+0xfff9)-'0');
462 year = ((isa_readb(0xffffb)-'0')*10)+(isa_readb(0xffffc)-'0'); 468 year = ((readb(bios+0xfffb)-'0')*10)+(readb(bios+0xfffc)-'0');
463 tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6) 469 tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6)
464 | ((day & 0x1f)<<1); 470 | ((day & 0x1f)<<1);
465 471
@@ -476,6 +482,8 @@ static int tosh_probe(void)
476 if ((tosh_id==0xfccb) || (tosh_id==0xfccc)) 482 if ((tosh_id==0xfccb) || (tosh_id==0xfccc))
477 tosh_fan = 1; 483 tosh_fan = 1;
478 484
485 iounmap(bios);
486
479 return 0; 487 return 0;
480} 488}
481 489
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index fd3a4beaa53d..dec0224b4478 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -24,6 +24,7 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/miscdevice.h> 25#include <linux/miscdevice.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/io.h>
27 28
28enum tpm_timeout { 29enum tpm_timeout {
29 TPM_TIMEOUT = 5, /* msecs */ 30 TPM_TIMEOUT = 5, /* msecs */
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 76592ee1fb38..48d795bb8c4b 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -354,7 +354,7 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
354 354
355EXPORT_SYMBOL_GPL(tty_buffer_request_room); 355EXPORT_SYMBOL_GPL(tty_buffer_request_room);
356 356
357int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size) 357int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)
358{ 358{
359 int copied = 0; 359 int copied = 0;
360 do { 360 do {
@@ -378,7 +378,7 @@ int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t
378 378
379EXPORT_SYMBOL_GPL(tty_insert_flip_string); 379EXPORT_SYMBOL_GPL(tty_insert_flip_string);
380 380
381int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size) 381int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size)
382{ 382{
383 int copied = 0; 383 int copied = 0;
384 do { 384 do {
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index c0dfcf273f0a..16e99db2e12d 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -148,6 +148,16 @@ config MPCORE_WATCHDOG
148 To compile this driver as a module, choose M here: the 148 To compile this driver as a module, choose M here: the
149 module will be called mpcore_wdt. 149 module will be called mpcore_wdt.
150 150
151config EP93XX_WATCHDOG
152 tristate "EP93xx Watchdog"
153 depends on WATCHDOG && ARCH_EP93XX
154 help
155 Say Y here if to include support for the watchdog timer
156 embedded in the Cirrus Logic EP93xx family of devices.
157
158 To compile this driver as a module, choose M here: the
159 module will be called ep93xx_wdt.
160
151# X86 (i386 + ia64 + x86_64) Architecture 161# X86 (i386 + ia64 + x86_64) Architecture
152 162
153config ACQUIRE_WDT 163config ACQUIRE_WDT
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 36c0b282b8ba..d6f27fde9905 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
30obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o 30obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
31obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o 31obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
32obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o 32obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
33obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
33 34
34# X86 (i386 + ia64 + x86_64) Architecture 35# X86 (i386 + ia64 + x86_64) Architecture
35obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o 36obj-$(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 000000000000..9021dbb78299
--- /dev/null
+++ b/drivers/char/watchdog/ep93xx_wdt.c
@@ -0,0 +1,257 @@
1/*
2 * Watchdog driver for Cirrus Logic EP93xx family of devices.
3 *
4 * Copyright (c) 2004 Ray Lehtiniemi
5 * Copyright (c) 2006 Tower Technologies
6 * Based on ep93xx driver, bits from alim7101_wdt.c
7 *
8 * Authors: Ray Lehtiniemi <rayl@mail.com>,
9 * Alessandro Zummo <a.zummo@towertech.it>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 *
15 * This watchdog fires after 250msec, which is a too short interval
16 * for us to rely on the user space daemon alone. So we ping the
17 * wdt each ~200msec and eventually stop doing it if the user space
18 * daemon dies.
19 *
20 * TODO:
21 *
22 * - Test last reset from watchdog status
23 * - Add a few missing ioctls
24 */
25
26#include <linux/module.h>
27#include <linux/fs.h>
28#include <linux/miscdevice.h>
29#include <linux/watchdog.h>
30#include <linux/timer.h>
31
32#include <asm/hardware.h>
33#include <asm/uaccess.h>
34
35#define WDT_VERSION "0.3"
36#define PFX "ep93xx_wdt: "
37
38/* default timeout (secs) */
39#define WDT_TIMEOUT 30
40
41static int nowayout = WATCHDOG_NOWAYOUT;
42static int timeout = WDT_TIMEOUT;
43
44static struct timer_list timer;
45static unsigned long next_heartbeat;
46static unsigned long wdt_status;
47static unsigned long boot_status;
48
49#define WDT_IN_USE 0
50#define WDT_OK_TO_CLOSE 1
51
52#define EP93XX_WDT_REG(x) (EP93XX_WATCHDOG_BASE + (x))
53#define EP93XX_WDT_WATCHDOG EP93XX_WDT_REG(0x00)
54#define EP93XX_WDT_WDSTATUS EP93XX_WDT_REG(0x04)
55
56/* reset the wdt every ~200ms */
57#define WDT_INTERVAL (HZ/5)
58
59static void wdt_enable(void)
60{
61 __raw_writew(0xaaaa, EP93XX_WDT_WATCHDOG);
62}
63
64static void wdt_disable(void)
65{
66 __raw_writew(0xaa55, EP93XX_WDT_WATCHDOG);
67}
68
69static inline void wdt_ping(void)
70{
71 __raw_writew(0x5555, EP93XX_WDT_WATCHDOG);
72}
73
74static void wdt_startup(void)
75{
76 next_heartbeat = jiffies + (timeout * HZ);
77
78 wdt_enable();
79 mod_timer(&timer, jiffies + WDT_INTERVAL);
80}
81
82static void wdt_shutdown(void)
83{
84 del_timer_sync(&timer);
85 wdt_disable();
86}
87
88static void wdt_keepalive(void)
89{
90 /* user land ping */
91 next_heartbeat = jiffies + (timeout * HZ);
92}
93
94static int ep93xx_wdt_open(struct inode *inode, struct file *file)
95{
96 if (test_and_set_bit(WDT_IN_USE, &wdt_status))
97 return -EBUSY;
98
99 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
100
101 wdt_startup();
102
103 return nonseekable_open(inode, file);
104}
105
106static ssize_t
107ep93xx_wdt_write(struct file *file, const char __user *data, size_t len,
108 loff_t *ppos)
109{
110 /* Can't seek (pwrite) on this device */
111 if (*ppos != file->f_pos)
112 return -ESPIPE;
113
114 if (len) {
115 if (!nowayout) {
116 size_t i;
117
118 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
119
120 for (i = 0; i != len; i++) {
121 char c;
122
123 if (get_user(c, data + i))
124 return -EFAULT;
125
126 if (c == 'V')
127 set_bit(WDT_OK_TO_CLOSE, &wdt_status);
128 else
129 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
130 }
131 }
132 wdt_keepalive();
133 }
134
135 return len;
136}
137
138static struct watchdog_info ident = {
139 .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE,
140 .identity = "EP93xx Watchdog",
141};
142
143static int
144ep93xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
145 unsigned long arg)
146{
147 int ret = -ENOIOCTLCMD;
148
149 switch (cmd) {
150 case WDIOC_GETSUPPORT:
151 ret = copy_to_user((struct watchdog_info __user *)arg, &ident,
152 sizeof(ident)) ? -EFAULT : 0;
153 break;
154
155 case WDIOC_GETSTATUS:
156 ret = put_user(0, (int __user *)arg);
157 break;
158
159 case WDIOC_GETBOOTSTATUS:
160 ret = put_user(boot_status, (int __user *)arg);
161 break;
162
163 case WDIOC_GETTIMEOUT:
164 /* actually, it is 0.250 seconds.... */
165 ret = put_user(1, (int __user *)arg);
166 break;
167
168 case WDIOC_KEEPALIVE:
169 wdt_keepalive();
170 ret = 0;
171 break;
172 }
173 return ret;
174}
175
176static int ep93xx_wdt_release(struct inode *inode, struct file *file)
177{
178 if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
179 wdt_shutdown();
180 else
181 printk(KERN_CRIT PFX "Device closed unexpectedly - "
182 "timer will not stop\n");
183
184 clear_bit(WDT_IN_USE, &wdt_status);
185 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
186
187 return 0;
188}
189
190static struct file_operations ep93xx_wdt_fops = {
191 .owner = THIS_MODULE,
192 .write = ep93xx_wdt_write,
193 .ioctl = ep93xx_wdt_ioctl,
194 .open = ep93xx_wdt_open,
195 .release = ep93xx_wdt_release,
196};
197
198static struct miscdevice ep93xx_wdt_miscdev = {
199 .minor = WATCHDOG_MINOR,
200 .name = "watchdog",
201 .fops = &ep93xx_wdt_fops,
202};
203
204static void ep93xx_timer_ping(unsigned long data)
205{
206 if (time_before(jiffies, next_heartbeat))
207 wdt_ping();
208
209 /* Re-set the timer interval */
210 mod_timer(&timer, jiffies + WDT_INTERVAL);
211}
212
213static int __init ep93xx_wdt_init(void)
214{
215 int err;
216
217 err = misc_register(&ep93xx_wdt_miscdev);
218
219 boot_status = __raw_readl(EP93XX_WDT_WATCHDOG) & 0x01 ? 1 : 0;
220
221 printk(KERN_INFO PFX "EP93XX watchdog, driver version "
222 WDT_VERSION "%s\n",
223 (__raw_readl(EP93XX_WDT_WATCHDOG) & 0x08)
224 ? " (nCS1 disable detected)" : "");
225
226 if (timeout < 1 || timeout > 3600) {
227 timeout = WDT_TIMEOUT;
228 printk(KERN_INFO PFX
229 "timeout value must be 1<=x<=3600, using %d\n",
230 timeout);
231 }
232
233 setup_timer(&timer, ep93xx_timer_ping, 1);
234 return err;
235}
236
237static void __exit ep93xx_wdt_exit(void)
238{
239 wdt_shutdown();
240 misc_deregister(&ep93xx_wdt_miscdev);
241}
242
243module_init(ep93xx_wdt_init);
244module_exit(ep93xx_wdt_exit);
245
246module_param(nowayout, int, 0);
247MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
248
249module_param(timeout, int, 0);
250MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
251
252MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>,"
253 "Alessandro Zummo <a.zummo@towertech.it>");
254MODULE_DESCRIPTION("EP93xx Watchdog");
255MODULE_LICENSE("GPL");
256MODULE_VERSION(WDT_VERSION);
257MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9582de1c9cad..aed80e6aec6d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -5,7 +5,9 @@
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * 6 *
7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com> 7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>
8 * Added handling for CPU hotplug 8 * Added handling for CPU hotplug
9 * Feb 2006 - Jacob Shin <jacob.shin@amd.com>
10 * Fix handling for CPU hotplug -- affected CPUs
9 * 11 *
10 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
@@ -44,8 +46,8 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
44static void handle_update(void *data); 46static void handle_update(void *data);
45 47
46/** 48/**
47 * Two notifier lists: the "policy" list is involved in the 49 * Two notifier lists: the "policy" list is involved in the
48 * validation process for a new CPU frequency policy; the 50 * validation process for a new CPU frequency policy; the
49 * "transition" list for kernel code that needs to handle 51 * "transition" list for kernel code that needs to handle
50 * changes to devices when the CPU clock speed changes. 52 * changes to devices when the CPU clock speed changes.
51 * The mutex locks both lists. 53 * The mutex locks both lists.
@@ -151,7 +153,7 @@ void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt
151 va_list args; 153 va_list args;
152 unsigned int len; 154 unsigned int len;
153 unsigned long flags; 155 unsigned long flags;
154 156
155 WARN_ON(!prefix); 157 WARN_ON(!prefix);
156 if (type & debug) { 158 if (type & debug) {
157 spin_lock_irqsave(&disable_ratelimit_lock, flags); 159 spin_lock_irqsave(&disable_ratelimit_lock, flags);
@@ -198,7 +200,7 @@ static inline void cpufreq_debug_disable_ratelimit(void) { return; }
198 * 200 *
199 * This function alters the system "loops_per_jiffy" for the clock 201 * This function alters the system "loops_per_jiffy" for the clock
200 * speed change. Note that loops_per_jiffy cannot be updated on SMP 202 * speed change. Note that loops_per_jiffy cannot be updated on SMP
201 * systems as each CPU might be scaled differently. So, use the arch 203 * systems as each CPU might be scaled differently. So, use the arch
202 * per-CPU loops_per_jiffy value wherever possible. 204 * per-CPU loops_per_jiffy value wherever possible.
203 */ 205 */
204#ifndef CONFIG_SMP 206#ifndef CONFIG_SMP
@@ -233,7 +235,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) {
233 * 235 *
234 * This function calls the transition notifiers and the "adjust_jiffies" 236 * This function calls the transition notifiers and the "adjust_jiffies"
235 * function. It is called twice on all CPU frequency changes that have 237 * function. It is called twice on all CPU frequency changes that have
236 * external effects. 238 * external effects.
237 */ 239 */
238void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) 240void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
239{ 241{
@@ -251,7 +253,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
251 switch (state) { 253 switch (state) {
252 254
253 case CPUFREQ_PRECHANGE: 255 case CPUFREQ_PRECHANGE:
254 /* detect if the driver reported a value as "old frequency" 256 /* detect if the driver reported a value as "old frequency"
255 * which is not equal to what the cpufreq core thinks is 257 * which is not equal to what the cpufreq core thinks is
256 * "old frequency". 258 * "old frequency".
257 */ 259 */
@@ -335,11 +337,11 @@ extern struct sysdev_class cpu_sysdev_class;
335 * "unsigned int". 337 * "unsigned int".
336 */ 338 */
337 339
338#define show_one(file_name, object) \ 340#define show_one(file_name, object) \
339static ssize_t show_##file_name \ 341static ssize_t show_##file_name \
340(struct cpufreq_policy * policy, char *buf) \ 342(struct cpufreq_policy * policy, char *buf) \
341{ \ 343{ \
342 return sprintf (buf, "%u\n", policy->object); \ 344 return sprintf (buf, "%u\n", policy->object); \
343} 345}
344 346
345show_one(cpuinfo_min_freq, cpuinfo.min_freq); 347show_one(cpuinfo_min_freq, cpuinfo.min_freq);
@@ -404,8 +406,8 @@ static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf)
404/** 406/**
405 * store_scaling_governor - store policy for the specified CPU 407 * store_scaling_governor - store policy for the specified CPU
406 */ 408 */
407static ssize_t store_scaling_governor (struct cpufreq_policy * policy, 409static ssize_t store_scaling_governor (struct cpufreq_policy * policy,
408 const char *buf, size_t count) 410 const char *buf, size_t count)
409{ 411{
410 unsigned int ret = -EINVAL; 412 unsigned int ret = -EINVAL;
411 char str_governor[16]; 413 char str_governor[16];
@@ -528,7 +530,7 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf)
528 return ret; 530 return ret;
529} 531}
530 532
531static ssize_t store(struct kobject * kobj, struct attribute * attr, 533static ssize_t store(struct kobject * kobj, struct attribute * attr,
532 const char * buf, size_t count) 534 const char * buf, size_t count)
533{ 535{
534 struct cpufreq_policy * policy = to_policy(kobj); 536 struct cpufreq_policy * policy = to_policy(kobj);
@@ -564,7 +566,7 @@ static struct kobj_type ktype_cpufreq = {
564/** 566/**
565 * cpufreq_add_dev - add a CPU device 567 * cpufreq_add_dev - add a CPU device
566 * 568 *
567 * Adds the cpufreq interface for a CPU device. 569 * Adds the cpufreq interface for a CPU device.
568 */ 570 */
569static int cpufreq_add_dev (struct sys_device * sys_dev) 571static int cpufreq_add_dev (struct sys_device * sys_dev)
570{ 572{
@@ -573,8 +575,12 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
573 struct cpufreq_policy new_policy; 575 struct cpufreq_policy new_policy;
574 struct cpufreq_policy *policy; 576 struct cpufreq_policy *policy;
575 struct freq_attr **drv_attr; 577 struct freq_attr **drv_attr;
578 struct sys_device *cpu_sys_dev;
576 unsigned long flags; 579 unsigned long flags;
577 unsigned int j; 580 unsigned int j;
581#ifdef CONFIG_SMP
582 struct cpufreq_policy *managed_policy;
583#endif
578 584
579 if (cpu_is_offline(cpu)) 585 if (cpu_is_offline(cpu))
580 return 0; 586 return 0;
@@ -587,8 +593,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
587 * CPU because it is in the same boat. */ 593 * CPU because it is in the same boat. */
588 policy = cpufreq_cpu_get(cpu); 594 policy = cpufreq_cpu_get(cpu);
589 if (unlikely(policy)) { 595 if (unlikely(policy)) {
590 dprintk("CPU already managed, adding link\n"); 596 cpufreq_cpu_put(policy);
591 sysfs_create_link(&sys_dev->kobj, &policy->kobj, "cpufreq");
592 cpufreq_debug_enable_ratelimit(); 597 cpufreq_debug_enable_ratelimit();
593 return 0; 598 return 0;
594 } 599 }
@@ -623,6 +628,32 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
623 goto err_out; 628 goto err_out;
624 } 629 }
625 630
631#ifdef CONFIG_SMP
632 for_each_cpu_mask(j, policy->cpus) {
633 if (cpu == j)
634 continue;
635
636 /* check for existing affected CPUs. They may not be aware
637 * of it due to CPU Hotplug.
638 */
639 managed_policy = cpufreq_cpu_get(j);
640 if (unlikely(managed_policy)) {
641 spin_lock_irqsave(&cpufreq_driver_lock, flags);
642 managed_policy->cpus = policy->cpus;
643 cpufreq_cpu_data[cpu] = managed_policy;
644 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
645
646 dprintk("CPU already managed, adding link\n");
647 sysfs_create_link(&sys_dev->kobj,
648 &managed_policy->kobj, "cpufreq");
649
650 cpufreq_debug_enable_ratelimit();
651 mutex_unlock(&policy->lock);
652 ret = 0;
653 goto err_out_driver_exit; /* call driver->exit() */
654 }
655 }
656#endif
626 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 657 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
627 658
628 /* prepare interface data */ 659 /* prepare interface data */
@@ -650,6 +681,21 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
650 for_each_cpu_mask(j, policy->cpus) 681 for_each_cpu_mask(j, policy->cpus)
651 cpufreq_cpu_data[j] = policy; 682 cpufreq_cpu_data[j] = policy;
652 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 683 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
684
685 /* symlink affected CPUs */
686 for_each_cpu_mask(j, policy->cpus) {
687 if (j == cpu)
688 continue;
689 if (!cpu_online(j))
690 continue;
691
692 dprintk("CPU already managed, adding link\n");
693 cpufreq_cpu_get(cpu);
694 cpu_sys_dev = get_cpu_sysdev(j);
695 sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
696 "cpufreq");
697 }
698
653 policy->governor = NULL; /* to assure that the starting sequence is 699 policy->governor = NULL; /* to assure that the starting sequence is
654 * run in cpufreq_set_policy */ 700 * run in cpufreq_set_policy */
655 mutex_unlock(&policy->lock); 701 mutex_unlock(&policy->lock);
@@ -724,10 +770,11 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
724 770
725#ifdef CONFIG_SMP 771#ifdef CONFIG_SMP
726 /* if this isn't the CPU which is the parent of the kobj, we 772 /* if this isn't the CPU which is the parent of the kobj, we
727 * only need to unlink, put and exit 773 * only need to unlink, put and exit
728 */ 774 */
729 if (unlikely(cpu != data->cpu)) { 775 if (unlikely(cpu != data->cpu)) {
730 dprintk("removing link\n"); 776 dprintk("removing link\n");
777 cpu_clear(cpu, data->cpus);
731 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 778 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
732 sysfs_remove_link(&sys_dev->kobj, "cpufreq"); 779 sysfs_remove_link(&sys_dev->kobj, "cpufreq");
733 cpufreq_cpu_put(data); 780 cpufreq_cpu_put(data);
@@ -740,7 +787,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
740 if (!kobject_get(&data->kobj)) { 787 if (!kobject_get(&data->kobj)) {
741 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 788 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
742 cpufreq_debug_enable_ratelimit(); 789 cpufreq_debug_enable_ratelimit();
743 return -EFAULT; 790 return -EFAULT;
744 } 791 }
745 792
746#ifdef CONFIG_SMP 793#ifdef CONFIG_SMP
@@ -783,7 +830,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
783 kobject_put(&data->kobj); 830 kobject_put(&data->kobj);
784 831
785 /* we need to make sure that the underlying kobj is actually 832 /* we need to make sure that the underlying kobj is actually
786 * not referenced anymore by anybody before we proceed with 833 * not referenced anymore by anybody before we proceed with
787 * unloading. 834 * unloading.
788 */ 835 */
789 dprintk("waiting for dropping of refcount\n"); 836 dprintk("waiting for dropping of refcount\n");
@@ -831,7 +878,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne
831} 878}
832 879
833 880
834/** 881/**
835 * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur 882 * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur
836 * @cpu: CPU number 883 * @cpu: CPU number
837 * 884 *
@@ -855,7 +902,7 @@ unsigned int cpufreq_quick_get(unsigned int cpu)
855EXPORT_SYMBOL(cpufreq_quick_get); 902EXPORT_SYMBOL(cpufreq_quick_get);
856 903
857 904
858/** 905/**
859 * cpufreq_get - get the current CPU frequency (in kHz) 906 * cpufreq_get - get the current CPU frequency (in kHz)
860 * @cpu: CPU number 907 * @cpu: CPU number
861 * 908 *
@@ -1072,7 +1119,7 @@ static struct sysdev_driver cpufreq_sysdev_driver = {
1072 * @nb: notifier function to register 1119 * @nb: notifier function to register
1073 * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER 1120 * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
1074 * 1121 *
1075 * Add a driver to one of two lists: either a list of drivers that 1122 * Add a driver to one of two lists: either a list of drivers that
1076 * are notified about clock rate changes (once before and once after 1123 * are notified about clock rate changes (once before and once after
1077 * the transition), or a list of drivers that are notified about 1124 * the transition), or a list of drivers that are notified about
1078 * changes in cpufreq policy. 1125 * changes in cpufreq policy.
@@ -1225,7 +1272,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1225 return -EINVAL; 1272 return -EINVAL;
1226 1273
1227 mutex_lock(&cpufreq_governor_mutex); 1274 mutex_lock(&cpufreq_governor_mutex);
1228 1275
1229 list_for_each_entry(t, &cpufreq_governor_list, governor_list) { 1276 list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
1230 if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) { 1277 if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
1231 mutex_unlock(&cpufreq_governor_mutex); 1278 mutex_unlock(&cpufreq_governor_mutex);
@@ -1234,7 +1281,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1234 } 1281 }
1235 list_add(&governor->governor_list, &cpufreq_governor_list); 1282 list_add(&governor->governor_list, &cpufreq_governor_list);
1236 1283
1237 mutex_unlock(&cpufreq_governor_mutex); 1284 mutex_unlock(&cpufreq_governor_mutex);
1238 return 0; 1285 return 0;
1239} 1286}
1240EXPORT_SYMBOL_GPL(cpufreq_register_governor); 1287EXPORT_SYMBOL_GPL(cpufreq_register_governor);
@@ -1497,9 +1544,9 @@ static struct notifier_block cpufreq_cpu_notifier =
1497 * @driver_data: A struct cpufreq_driver containing the values# 1544 * @driver_data: A struct cpufreq_driver containing the values#
1498 * submitted by the CPU Frequency driver. 1545 * submitted by the CPU Frequency driver.
1499 * 1546 *
1500 * Registers a CPU Frequency driver to this core code. This code 1547 * Registers a CPU Frequency driver to this core code. This code
1501 * returns zero on success, -EBUSY when another driver got here first 1548 * returns zero on success, -EBUSY when another driver got here first
1502 * (and isn't unregistered in the meantime). 1549 * (and isn't unregistered in the meantime).
1503 * 1550 *
1504 */ 1551 */
1505int cpufreq_register_driver(struct cpufreq_driver *driver_data) 1552int cpufreq_register_driver(struct cpufreq_driver *driver_data)
@@ -1560,7 +1607,7 @@ EXPORT_SYMBOL_GPL(cpufreq_register_driver);
1560/** 1607/**
1561 * cpufreq_unregister_driver - unregister the current CPUFreq driver 1608 * cpufreq_unregister_driver - unregister the current CPUFreq driver
1562 * 1609 *
1563 * Unregister the current CPUFreq driver. Only call this if you have 1610 * Unregister the current CPUFreq driver. Only call this if you have
1564 * the right to do so, i.e. if you have succeeded in initialising before! 1611 * the right to do so, i.e. if you have succeeded in initialising before!
1565 * Returns zero if successful, and -EINVAL if the cpufreq_driver is 1612 * Returns zero if successful, and -EINVAL if the cpufreq_driver is
1566 * currently not initialised. 1613 * currently not initialised.
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 9ee9411f186f..69aa1db8336c 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -38,17 +38,17 @@
38#define MIN_FREQUENCY_UP_THRESHOLD (11) 38#define MIN_FREQUENCY_UP_THRESHOLD (11)
39#define MAX_FREQUENCY_UP_THRESHOLD (100) 39#define MAX_FREQUENCY_UP_THRESHOLD (100)
40 40
41/* 41/*
42 * The polling frequency of this governor depends on the capability of 42 * The polling frequency of this governor depends on the capability of
43 * the processor. Default polling frequency is 1000 times the transition 43 * the processor. Default polling frequency is 1000 times the transition
44 * latency of the processor. The governor will work on any processor with 44 * latency of the processor. The governor will work on any processor with
45 * transition latency <= 10mS, using appropriate sampling 45 * transition latency <= 10mS, using appropriate sampling
46 * rate. 46 * rate.
47 * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL) 47 * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL)
48 * this governor will not work. 48 * this governor will not work.
49 * All times here are in uS. 49 * All times here are in uS.
50 */ 50 */
51static unsigned int def_sampling_rate; 51static unsigned int def_sampling_rate;
52#define MIN_SAMPLING_RATE_RATIO (2) 52#define MIN_SAMPLING_RATE_RATIO (2)
53/* for correct statistics, we need at least 10 ticks between each measure */ 53/* for correct statistics, we need at least 10 ticks between each measure */
54#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) 54#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
@@ -62,28 +62,28 @@ static unsigned int def_sampling_rate;
62static void do_dbs_timer(void *data); 62static void do_dbs_timer(void *data);
63 63
64struct cpu_dbs_info_s { 64struct cpu_dbs_info_s {
65 struct cpufreq_policy *cur_policy; 65 struct cpufreq_policy *cur_policy;
66 unsigned int prev_cpu_idle_up; 66 unsigned int prev_cpu_idle_up;
67 unsigned int prev_cpu_idle_down; 67 unsigned int prev_cpu_idle_down;
68 unsigned int enable; 68 unsigned int enable;
69}; 69};
70static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 70static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
71 71
72static unsigned int dbs_enable; /* number of CPUs using this policy */ 72static unsigned int dbs_enable; /* number of CPUs using this policy */
73 73
74static DEFINE_MUTEX (dbs_mutex); 74static DEFINE_MUTEX (dbs_mutex);
75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL);
76 76
77struct dbs_tuners { 77struct dbs_tuners {
78 unsigned int sampling_rate; 78 unsigned int sampling_rate;
79 unsigned int sampling_down_factor; 79 unsigned int sampling_down_factor;
80 unsigned int up_threshold; 80 unsigned int up_threshold;
81 unsigned int ignore_nice; 81 unsigned int ignore_nice;
82}; 82};
83 83
84static struct dbs_tuners dbs_tuners_ins = { 84static struct dbs_tuners dbs_tuners_ins = {
85 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, 85 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
86 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, 86 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
87}; 87};
88 88
89static inline unsigned int get_cpu_idle_time(unsigned int cpu) 89static inline unsigned int get_cpu_idle_time(unsigned int cpu)
@@ -106,8 +106,8 @@ static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
106 return sprintf (buf, "%u\n", MIN_SAMPLING_RATE); 106 return sprintf (buf, "%u\n", MIN_SAMPLING_RATE);
107} 107}
108 108
109#define define_one_ro(_name) \ 109#define define_one_ro(_name) \
110static struct freq_attr _name = \ 110static struct freq_attr _name = \
111__ATTR(_name, 0444, show_##_name, NULL) 111__ATTR(_name, 0444, show_##_name, NULL)
112 112
113define_one_ro(sampling_rate_max); 113define_one_ro(sampling_rate_max);
@@ -125,7 +125,7 @@ show_one(sampling_down_factor, sampling_down_factor);
125show_one(up_threshold, up_threshold); 125show_one(up_threshold, up_threshold);
126show_one(ignore_nice_load, ignore_nice); 126show_one(ignore_nice_load, ignore_nice);
127 127
128static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 128static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
129 const char *buf, size_t count) 129 const char *buf, size_t count)
130{ 130{
131 unsigned int input; 131 unsigned int input;
@@ -144,7 +144,7 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
144 return count; 144 return count;
145} 145}
146 146
147static ssize_t store_sampling_rate(struct cpufreq_policy *unused, 147static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
148 const char *buf, size_t count) 148 const char *buf, size_t count)
149{ 149{
150 unsigned int input; 150 unsigned int input;
@@ -163,7 +163,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
163 return count; 163 return count;
164} 164}
165 165
166static ssize_t store_up_threshold(struct cpufreq_policy *unused, 166static ssize_t store_up_threshold(struct cpufreq_policy *unused,
167 const char *buf, size_t count) 167 const char *buf, size_t count)
168{ 168{
169 unsigned int input; 169 unsigned int input;
@@ -171,7 +171,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
171 ret = sscanf (buf, "%u", &input); 171 ret = sscanf (buf, "%u", &input);
172 172
173 mutex_lock(&dbs_mutex); 173 mutex_lock(&dbs_mutex);
174 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || 174 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
175 input < MIN_FREQUENCY_UP_THRESHOLD) { 175 input < MIN_FREQUENCY_UP_THRESHOLD) {
176 mutex_unlock(&dbs_mutex); 176 mutex_unlock(&dbs_mutex);
177 return -EINVAL; 177 return -EINVAL;
@@ -190,14 +190,14 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
190 int ret; 190 int ret;
191 191
192 unsigned int j; 192 unsigned int j;
193 193
194 ret = sscanf (buf, "%u", &input); 194 ret = sscanf (buf, "%u", &input);
195 if ( ret != 1 ) 195 if ( ret != 1 )
196 return -EINVAL; 196 return -EINVAL;
197 197
198 if ( input > 1 ) 198 if ( input > 1 )
199 input = 1; 199 input = 1;
200 200
201 mutex_lock(&dbs_mutex); 201 mutex_lock(&dbs_mutex);
202 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ 202 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */
203 mutex_unlock(&dbs_mutex); 203 mutex_unlock(&dbs_mutex);
@@ -259,16 +259,16 @@ static void dbs_check_cpu(int cpu)
259 return; 259 return;
260 260
261 policy = this_dbs_info->cur_policy; 261 policy = this_dbs_info->cur_policy;
262 /* 262 /*
263 * Every sampling_rate, we check, if current idle time is less 263 * Every sampling_rate, we check, if current idle time is less
264 * than 20% (default), then we try to increase frequency 264 * than 20% (default), then we try to increase frequency
265 * Every sampling_rate*sampling_down_factor, we look for a the lowest 265 * Every sampling_rate*sampling_down_factor, we look for a the lowest
266 * frequency which can sustain the load while keeping idle time over 266 * frequency which can sustain the load while keeping idle time over
267 * 30%. If such a frequency exist, we try to decrease to this frequency. 267 * 30%. If such a frequency exist, we try to decrease to this frequency.
268 * 268 *
269 * Any frequency increase takes it to the maximum frequency. 269 * Any frequency increase takes it to the maximum frequency.
270 * Frequency reduction happens at minimum steps of 270 * Frequency reduction happens at minimum steps of
271 * 5% (default) of current frequency 271 * 5% (default) of current frequency
272 */ 272 */
273 273
274 /* Check for frequency increase */ 274 /* Check for frequency increase */
@@ -298,14 +298,14 @@ static void dbs_check_cpu(int cpu)
298 struct cpu_dbs_info_s *j_dbs_info; 298 struct cpu_dbs_info_s *j_dbs_info;
299 299
300 j_dbs_info = &per_cpu(cpu_dbs_info, j); 300 j_dbs_info = &per_cpu(cpu_dbs_info, j);
301 j_dbs_info->prev_cpu_idle_down = 301 j_dbs_info->prev_cpu_idle_down =
302 j_dbs_info->prev_cpu_idle_up; 302 j_dbs_info->prev_cpu_idle_up;
303 } 303 }
304 /* if we are already at full speed then break out early */ 304 /* if we are already at full speed then break out early */
305 if (policy->cur == policy->max) 305 if (policy->cur == policy->max)
306 return; 306 return;
307 307
308 __cpufreq_driver_target(policy, policy->max, 308 __cpufreq_driver_target(policy, policy->max,
309 CPUFREQ_RELATION_H); 309 CPUFREQ_RELATION_H);
310 return; 310 return;
311 } 311 }
@@ -347,7 +347,7 @@ static void dbs_check_cpu(int cpu)
347 * policy. To be safe, we focus 10 points under the threshold. 347 * policy. To be safe, we focus 10 points under the threshold.
348 */ 348 */
349 freq_next = ((total_ticks - idle_ticks) * 100) / total_ticks; 349 freq_next = ((total_ticks - idle_ticks) * 100) / total_ticks;
350 freq_next = (freq_next * policy->cur) / 350 freq_next = (freq_next * policy->cur) /
351 (dbs_tuners_ins.up_threshold - 10); 351 (dbs_tuners_ins.up_threshold - 10);
352 352
353 if (freq_next <= ((policy->cur * 95) / 100)) 353 if (freq_next <= ((policy->cur * 95) / 100))
@@ -355,15 +355,15 @@ static void dbs_check_cpu(int cpu)
355} 355}
356 356
357static void do_dbs_timer(void *data) 357static void do_dbs_timer(void *data)
358{ 358{
359 int i; 359 int i;
360 mutex_lock(&dbs_mutex); 360 mutex_lock(&dbs_mutex);
361 for_each_online_cpu(i) 361 for_each_online_cpu(i)
362 dbs_check_cpu(i); 362 dbs_check_cpu(i);
363 schedule_delayed_work(&dbs_work, 363 schedule_delayed_work(&dbs_work,
364 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 364 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
365 mutex_unlock(&dbs_mutex); 365 mutex_unlock(&dbs_mutex);
366} 366}
367 367
368static inline void dbs_timer_init(void) 368static inline void dbs_timer_init(void)
369{ 369{
@@ -390,7 +390,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
390 390
391 switch (event) { 391 switch (event) {
392 case CPUFREQ_GOV_START: 392 case CPUFREQ_GOV_START:
393 if ((!cpu_online(cpu)) || 393 if ((!cpu_online(cpu)) ||
394 (!policy->cur)) 394 (!policy->cur))
395 return -EINVAL; 395 return -EINVAL;
396 396
@@ -399,13 +399,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
399 return -EINVAL; 399 return -EINVAL;
400 if (this_dbs_info->enable) /* Already enabled */ 400 if (this_dbs_info->enable) /* Already enabled */
401 break; 401 break;
402 402
403 mutex_lock(&dbs_mutex); 403 mutex_lock(&dbs_mutex);
404 for_each_cpu_mask(j, policy->cpus) { 404 for_each_cpu_mask(j, policy->cpus) {
405 struct cpu_dbs_info_s *j_dbs_info; 405 struct cpu_dbs_info_s *j_dbs_info;
406 j_dbs_info = &per_cpu(cpu_dbs_info, j); 406 j_dbs_info = &per_cpu(cpu_dbs_info, j);
407 j_dbs_info->cur_policy = policy; 407 j_dbs_info->cur_policy = policy;
408 408
409 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); 409 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j);
410 j_dbs_info->prev_cpu_idle_down 410 j_dbs_info->prev_cpu_idle_down
411 = j_dbs_info->prev_cpu_idle_up; 411 = j_dbs_info->prev_cpu_idle_up;
@@ -435,7 +435,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
435 435
436 dbs_timer_init(); 436 dbs_timer_init();
437 } 437 }
438 438
439 mutex_unlock(&dbs_mutex); 439 mutex_unlock(&dbs_mutex);
440 break; 440 break;
441 441
@@ -448,9 +448,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
448 * Stop the timerschedule work, when this governor 448 * Stop the timerschedule work, when this governor
449 * is used for first time 449 * is used for first time
450 */ 450 */
451 if (dbs_enable == 0) 451 if (dbs_enable == 0)
452 dbs_timer_exit(); 452 dbs_timer_exit();
453 453
454 mutex_unlock(&dbs_mutex); 454 mutex_unlock(&dbs_mutex);
455 455
456 break; 456 break;
@@ -460,11 +460,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
460 if (policy->max < this_dbs_info->cur_policy->cur) 460 if (policy->max < this_dbs_info->cur_policy->cur)
461 __cpufreq_driver_target( 461 __cpufreq_driver_target(
462 this_dbs_info->cur_policy, 462 this_dbs_info->cur_policy,
463 policy->max, CPUFREQ_RELATION_H); 463 policy->max, CPUFREQ_RELATION_H);
464 else if (policy->min > this_dbs_info->cur_policy->cur) 464 else if (policy->min > this_dbs_info->cur_policy->cur)
465 __cpufreq_driver_target( 465 __cpufreq_driver_target(
466 this_dbs_info->cur_policy, 466 this_dbs_info->cur_policy,
467 policy->min, CPUFREQ_RELATION_L); 467 policy->min, CPUFREQ_RELATION_L);
468 mutex_unlock(&dbs_mutex); 468 mutex_unlock(&dbs_mutex);
469 break; 469 break;
470 } 470 }
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c
index 8d536b40deb8..de91e3371ef8 100644
--- a/drivers/cpufreq/cpufreq_performance.c
+++ b/drivers/cpufreq/cpufreq_performance.c
@@ -32,7 +32,7 @@ static int cpufreq_governor_performance(struct cpufreq_policy *policy,
32 } 32 }
33 return 0; 33 return 0;
34} 34}
35 35
36struct cpufreq_governor cpufreq_gov_performance = { 36struct cpufreq_governor cpufreq_gov_performance = {
37 .name = "performance", 37 .name = "performance",
38 .governor = cpufreq_governor_performance, 38 .governor = cpufreq_governor_performance,
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c
index c85edda7feb0..0a2596044e65 100644
--- a/drivers/cpufreq/cpufreq_powersave.c
+++ b/drivers/cpufreq/cpufreq_powersave.c
@@ -31,7 +31,7 @@ static int cpufreq_governor_powersave(struct cpufreq_policy *policy,
31 } 31 }
32 return 0; 32 return 0;
33} 33}
34 34
35static struct cpufreq_governor cpufreq_gov_powersave = { 35static struct cpufreq_governor cpufreq_gov_powersave = {
36 .name = "powersave", 36 .name = "powersave",
37 .governor = cpufreq_governor_powersave, 37 .governor = cpufreq_governor_powersave,
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 0bddb8e694d9..9694b6ed3268 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -2,7 +2,7 @@
2 * drivers/cpufreq/cpufreq_stats.c 2 * drivers/cpufreq/cpufreq_stats.c
3 * 3 *
4 * Copyright (C) 2003-2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>. 4 * Copyright (C) 2003-2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
5 * (C) 2004 Zou Nan hai <nanhai.zou@intel.com>. 5 * (C) 2004 Zou Nan hai <nanhai.zou@intel.com>.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -90,7 +90,7 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf)
90 return 0; 90 return 0;
91 cpufreq_stats_update(stat->cpu); 91 cpufreq_stats_update(stat->cpu);
92 for (i = 0; i < stat->state_num; i++) { 92 for (i = 0; i < stat->state_num; i++) {
93 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], 93 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
94 (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i])); 94 (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i]));
95 } 95 }
96 return len; 96 return len;
@@ -171,7 +171,7 @@ cpufreq_stats_free_table (unsigned int cpu)
171{ 171{
172 struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; 172 struct cpufreq_stats *stat = cpufreq_stats_table[cpu];
173 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 173 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
174 if (policy && policy->cpu == cpu) 174 if (policy && policy->cpu == cpu)
175 sysfs_remove_group(&policy->kobj, &stats_attr_group); 175 sysfs_remove_group(&policy->kobj, &stats_attr_group);
176 if (stat) { 176 if (stat) {
177 kfree(stat->time_in_state); 177 kfree(stat->time_in_state);
@@ -303,7 +303,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
303 return 0; 303 return 0;
304} 304}
305 305
306static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, 306static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
307 unsigned long action, void *hcpu) 307 unsigned long action, void *hcpu)
308{ 308{
309 unsigned int cpu = (unsigned long)hcpu; 309 unsigned int cpu = (unsigned long)hcpu;
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index 92a0be22a2a9..071ee4f1bbf2 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -41,7 +41,7 @@ static DEFINE_MUTEX (userspace_mutex);
41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) 41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg)
42 42
43/* keep track of frequency transitions */ 43/* keep track of frequency transitions */
44static int 44static int
45userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 45userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
46 void *data) 46 void *data)
47{ 47{
@@ -58,7 +58,7 @@ static struct notifier_block userspace_cpufreq_notifier_block = {
58}; 58};
59 59
60 60
61/** 61/**
62 * cpufreq_set - set the CPU frequency 62 * cpufreq_set - set the CPU frequency
63 * @freq: target frequency in kHz 63 * @freq: target frequency in kHz
64 * @cpu: CPU for which the frequency is to be set 64 * @cpu: CPU for which the frequency is to be set
@@ -103,8 +103,8 @@ static ssize_t show_speed (struct cpufreq_policy *policy, char *buf)
103 return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]); 103 return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]);
104} 104}
105 105
106static ssize_t 106static ssize_t
107store_speed (struct cpufreq_policy *policy, const char *buf, size_t count) 107store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
108{ 108{
109 unsigned int freq = 0; 109 unsigned int freq = 0;
110 unsigned int ret; 110 unsigned int ret;
@@ -118,7 +118,7 @@ store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
118 return count; 118 return count;
119} 119}
120 120
121static struct freq_attr freq_attr_scaling_setspeed = 121static struct freq_attr freq_attr_scaling_setspeed =
122{ 122{
123 .attr = { .name = "scaling_setspeed", .mode = 0644, .owner = THIS_MODULE }, 123 .attr = { .name = "scaling_setspeed", .mode = 0644, .owner = THIS_MODULE },
124 .show = show_speed, 124 .show = show_speed,
@@ -135,7 +135,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
135 return -EINVAL; 135 return -EINVAL;
136 BUG_ON(!policy->cur); 136 BUG_ON(!policy->cur);
137 mutex_lock(&userspace_mutex); 137 mutex_lock(&userspace_mutex);
138 cpu_is_managed[cpu] = 1; 138 cpu_is_managed[cpu] = 1;
139 cpu_min_freq[cpu] = policy->min; 139 cpu_min_freq[cpu] = policy->min;
140 cpu_max_freq[cpu] = policy->max; 140 cpu_max_freq[cpu] = policy->max;
141 cpu_cur_freq[cpu] = policy->cur; 141 cpu_cur_freq[cpu] = policy->cur;
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index ba460bdea60f..a4818ce88919 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -59,9 +59,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
59 if (!cpu_online(policy->cpu)) 59 if (!cpu_online(policy->cpu))
60 return -EINVAL; 60 return -EINVAL;
61 61
62 cpufreq_verify_within_limits(policy, 62 cpufreq_verify_within_limits(policy,
63 policy->cpuinfo.min_freq, 63 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
64 policy->cpuinfo.max_freq);
65 64
66 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 65 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
67 unsigned int freq = table[i].frequency; 66 unsigned int freq = table[i].frequency;
@@ -76,9 +75,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
76 if (!count) 75 if (!count)
77 policy->max = next_larger; 76 policy->max = next_larger;
78 77
79 cpufreq_verify_within_limits(policy, 78 cpufreq_verify_within_limits(policy,
80 policy->cpuinfo.min_freq, 79 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
81 policy->cpuinfo.max_freq);
82 80
83 dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); 81 dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu);
84 82
@@ -199,7 +197,7 @@ EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
199 * if you use these, you must assure that the frequency table is valid 197 * if you use these, you must assure that the frequency table is valid
200 * all the time between get_attr and put_attr! 198 * all the time between get_attr and put_attr!
201 */ 199 */
202void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 200void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
203 unsigned int cpu) 201 unsigned int cpu)
204{ 202{
205 dprintk("setting show_table for cpu %u to %p\n", cpu, table); 203 dprintk("setting show_table for cpu %u to %p\n", cpu, table);
diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
index ca8e69d2f64d..e4c48e329367 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)
71 * @drv: the driver structure to register 71 * @drv: the driver structure to register
72 * 72 *
73 * Adds the driver structure to the list of registered drivers 73 * Adds the driver structure to the list of registered drivers
74 * Returns the number of DIO devices which were claimed by the driver 74 * Returns zero or a negative error value.
75 * during registration. The driver remains registered even if the
76 * return value is zero.
77 */ 75 */
78 76
79int dio_register_driver(struct dio_driver *drv) 77int dio_register_driver(struct dio_driver *drv)
80{ 78{
81 int count = 0;
82
83 /* initialize common driver fields */ 79 /* initialize common driver fields */
84 drv->driver.name = drv->name; 80 drv->driver.name = drv->name;
85 drv->driver.bus = &dio_bus_type; 81 drv->driver.bus = &dio_bus_type;
86 82
87 /* register with core */ 83 /* register with core */
88 count = driver_register(&drv->driver); 84 return driver_register(&drv->driver);
89 return count ? count : 1;
90} 85}
91 86
92 87
diff --git a/drivers/eisa/.gitignore b/drivers/eisa/.gitignore
new file mode 100644
index 000000000000..4b335c0aedb0
--- /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 4196137e66de..6078e2f58817 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -135,13 +135,8 @@ struct bus_type eisa_bus_type = {
135 135
136int eisa_driver_register (struct eisa_driver *edrv) 136int eisa_driver_register (struct eisa_driver *edrv)
137{ 137{
138 int r;
139
140 edrv->driver.bus = &eisa_bus_type; 138 edrv->driver.bus = &eisa_bus_type;
141 if ((r = driver_register (&edrv->driver)) < 0) 139 return driver_register (&edrv->driver);
142 return r;
143
144 return 0;
145} 140}
146 141
147void eisa_driver_unregister (struct eisa_driver *edrv) 142void eisa_driver_unregister (struct eisa_driver *edrv)
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index 47b4d49f75c6..14e810f3c2c0 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -456,7 +456,7 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data,
456 long v = simple_strtol(buf, NULL, 10); 456 long v = simple_strtol(buf, NULL, 10);
457 457
458 mutex_lock(&data->update_lock); 458 mutex_lock(&data->update_lock);
459 data->temp_max[n - 1] = TEMP_TO_REG(v);; 459 data->temp_max[n - 1] = TEMP_TO_REG(v);
460 gl520_write_value(client, reg, data->temp_max[n - 1]); 460 gl520_write_value(client, reg, data->temp_max[n - 1]);
461 mutex_unlock(&data->update_lock); 461 mutex_unlock(&data->update_lock);
462 return count; 462 return count;
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index ceaa6b0bdfd6..0d8699b3f488 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)
53#define CTRL1(c) _rtc8564_ctrl1(c) 53#define CTRL1(c) _rtc8564_ctrl1(c)
54#define CTRL2(c) _rtc8564_ctrl2(c) 54#define CTRL2(c) _rtc8564_ctrl2(c)
55 55
56static int debug;; 56static int debug;
57module_param(debug, int, S_IRUGO | S_IWUSR); 57module_param(debug, int, S_IRUGO | S_IWUSR);
58 58
59static struct i2c_driver rtc8564_driver; 59static struct i2c_driver rtc8564_driver;
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index e238b7da824b..ccf528d733bf 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -978,8 +978,6 @@ static void idedisk_setup (ide_drive_t *drive)
978 ide_dma_verbose(drive); 978 ide_dma_verbose(drive);
979 printk("\n"); 979 printk("\n");
980 980
981 drive->no_io_32bit = id->dword_io ? 1 : 0;
982
983 /* write cache enabled? */ 981 /* write cache enabled? */
984 if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5))) 982 if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5)))
985 drive->wcache = 1; 983 drive->wcache = 1;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 0523da77425a..c481be8b807f 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)
175 if (rq->rq_disk) { 175 if (rq->rq_disk) {
176 ide_driver_t *drv; 176 ide_driver_t *drv;
177 177
178 drv = *(ide_driver_t **)rq->rq_disk->private_data;; 178 drv = *(ide_driver_t **)rq->rq_disk->private_data;
179 drv->end_request(drive, 1, rq->nr_sectors); 179 drv->end_request(drive, 1, rq->nr_sectors);
180 } else 180 } else
181 ide_end_request(drive, 1, rq->nr_sectors); 181 ide_end_request(drive, 1, rq->nr_sectors);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 427d1c204174..1b7b4c531bc2 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)
858 } 858 }
859 } 859 }
860 } 860 }
861
862 for (unit = 0; unit < MAX_DRIVES; ++unit) {
863 ide_drive_t *drive = &hwif->drives[unit];
864
865 if (hwif->no_io_32bit)
866 drive->no_io_32bit = 1;
867 else
868 drive->no_io_32bit = drive->id->dword_io ? 1 : 0;
869 }
861} 870}
862 871
863static int hwif_init(ide_hwif_t *hwif); 872static int hwif_init(ide_hwif_t *hwif);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index b2cc43702f65..3fdab563fec2 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -2058,7 +2058,7 @@ static void __init parse_options (char *line)
2058 } 2058 }
2059} 2059}
2060 2060
2061int init_module (void) 2061int __init init_module (void)
2062{ 2062{
2063 parse_options(options); 2063 parse_options(options);
2064 return ide_init(); 2064 return ide_init();
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index b05235639918..19f26c5c9479 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -42,6 +42,7 @@
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43#include <asm/atomic.h> 43#include <asm/atomic.h>
44#include <linux/devfs_fs_kernel.h> 44#include <linux/devfs_fs_kernel.h>
45#include <linux/compat.h>
45 46
46#include "csr1212.h" 47#include "csr1212.h"
47#include "ieee1394.h" 48#include "ieee1394.h"
@@ -406,6 +407,65 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
406 queue_complete_req(req); 407 queue_complete_req(req);
407} 408}
408 409
410#ifdef CONFIG_COMPAT
411struct compat_raw1394_req {
412 __u32 type;
413 __s32 error;
414 __u32 misc;
415
416 __u32 generation;
417 __u32 length;
418
419 __u64 address;
420
421 __u64 tag;
422
423 __u64 sendb;
424 __u64 recvb;
425} __attribute__((packed));
426
427static const char __user *raw1394_compat_write(const char __user *buf)
428{
429 struct compat_raw1394_req __user *cr = (typeof(cr)) buf;
430 struct raw1394_request __user *r;
431 r = compat_alloc_user_space(sizeof(struct raw1394_request));
432
433#define C(x) __copy_in_user(&r->x, &cr->x, sizeof(r->x))
434
435 if (copy_in_user(r, cr, sizeof(struct compat_raw1394_req)) ||
436 C(address) ||
437 C(tag) ||
438 C(sendb) ||
439 C(recvb))
440 return ERR_PTR(-EFAULT);
441 return (const char __user *)r;
442}
443#undef C
444
445#define P(x) __put_user(r->x, &cr->x)
446
447static int
448raw1394_compat_read(const char __user *buf, struct raw1394_request *r)
449{
450 struct compat_raw1394_req __user *cr = (typeof(cr)) r;
451 if (!access_ok(VERIFY_WRITE,cr,sizeof(struct compat_raw1394_req)) ||
452 P(type) ||
453 P(error) ||
454 P(misc) ||
455 P(generation) ||
456 P(length) ||
457 P(address) ||
458 P(tag) ||
459 P(sendb) ||
460 P(recvb))
461 return -EFAULT;
462 return sizeof(struct compat_raw1394_req);
463}
464#undef P
465
466#endif
467
468
409static ssize_t raw1394_read(struct file *file, char __user * buffer, 469static ssize_t raw1394_read(struct file *file, char __user * buffer,
410 size_t count, loff_t * offset_is_ignored) 470 size_t count, loff_t * offset_is_ignored)
411{ 471{
@@ -415,6 +475,11 @@ static ssize_t raw1394_read(struct file *file, char __user * buffer,
415 struct pending_request *req; 475 struct pending_request *req;
416 ssize_t ret; 476 ssize_t ret;
417 477
478#ifdef CONFIG_COMPAT
479 if (count == sizeof(struct compat_raw1394_req)) {
480 /* ok */
481 } else
482#endif
418 if (count != sizeof(struct raw1394_request)) { 483 if (count != sizeof(struct raw1394_request)) {
419 return -EINVAL; 484 return -EINVAL;
420 } 485 }
@@ -446,12 +511,22 @@ static ssize_t raw1394_read(struct file *file, char __user * buffer,
446 req->req.error = RAW1394_ERROR_MEMFAULT; 511 req->req.error = RAW1394_ERROR_MEMFAULT;
447 } 512 }
448 } 513 }
449 if (copy_to_user(buffer, &req->req, sizeof(req->req))) {
450 ret = -EFAULT;
451 goto out;
452 }
453 514
454 ret = (ssize_t) sizeof(struct raw1394_request); 515#ifdef CONFIG_COMPAT
516 if (count == sizeof(struct compat_raw1394_req) &&
517 sizeof(struct compat_raw1394_req) !=
518 sizeof(struct raw1394_request)) {
519 ret = raw1394_compat_read(buffer, &req->req);
520
521 } else
522#endif
523 {
524 if (copy_to_user(buffer, &req->req, sizeof(req->req))) {
525 ret = -EFAULT;
526 goto out;
527 }
528 ret = (ssize_t) sizeof(struct raw1394_request);
529 }
455 out: 530 out:
456 free_pending_request(req); 531 free_pending_request(req);
457 return ret; 532 return ret;
@@ -2274,6 +2349,7 @@ static int state_connected(struct file_info *fi, struct pending_request *req)
2274 return handle_async_request(fi, req, node); 2349 return handle_async_request(fi, req, node);
2275} 2350}
2276 2351
2352
2277static ssize_t raw1394_write(struct file *file, const char __user * buffer, 2353static ssize_t raw1394_write(struct file *file, const char __user * buffer,
2278 size_t count, loff_t * offset_is_ignored) 2354 size_t count, loff_t * offset_is_ignored)
2279{ 2355{
@@ -2281,6 +2357,15 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
2281 struct pending_request *req; 2357 struct pending_request *req;
2282 ssize_t retval = 0; 2358 ssize_t retval = 0;
2283 2359
2360#ifdef CONFIG_COMPAT
2361 if (count == sizeof(struct compat_raw1394_req) &&
2362 sizeof(struct compat_raw1394_req) !=
2363 sizeof(struct raw1394_request)) {
2364 buffer = raw1394_compat_write(buffer);
2365 if (IS_ERR(buffer))
2366 return PTR_ERR(buffer);
2367 } else
2368#endif
2284 if (count != sizeof(struct raw1394_request)) { 2369 if (count != sizeof(struct raw1394_request)) {
2285 return -EINVAL; 2370 return -EINVAL;
2286 } 2371 }
@@ -2893,6 +2978,7 @@ static struct file_operations raw1394_fops = {
2893 .write = raw1394_write, 2978 .write = raw1394_write,
2894 .mmap = raw1394_mmap, 2979 .mmap = raw1394_mmap,
2895 .ioctl = raw1394_ioctl, 2980 .ioctl = raw1394_ioctl,
2981 // .compat_ioctl = ... someone needs to do this
2896 .poll = raw1394_poll, 2982 .poll = raw1394_poll,
2897 .open = raw1394_open, 2983 .open = raw1394_open,
2898 .release = raw1394_release, 2984 .release = raw1394_release,
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index f673c461e30b..1bc2678c2fae 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -483,13 +483,20 @@ out:
483 return err; 483 return err;
484} 484}
485 485
486static void mthca_path_set(struct ib_ah_attr *ah, struct mthca_qp_path *path) 486static int mthca_path_set(struct mthca_dev *dev, struct ib_ah_attr *ah,
487 struct mthca_qp_path *path)
487{ 488{
488 path->g_mylmc = ah->src_path_bits & 0x7f; 489 path->g_mylmc = ah->src_path_bits & 0x7f;
489 path->rlid = cpu_to_be16(ah->dlid); 490 path->rlid = cpu_to_be16(ah->dlid);
490 path->static_rate = !!ah->static_rate; 491 path->static_rate = !!ah->static_rate;
491 492
492 if (ah->ah_flags & IB_AH_GRH) { 493 if (ah->ah_flags & IB_AH_GRH) {
494 if (ah->grh.sgid_index >= dev->limits.gid_table_len) {
495 mthca_dbg(dev, "sgid_index (%u) too large. max is %d\n",
496 ah->grh.sgid_index, dev->limits.gid_table_len-1);
497 return -1;
498 }
499
493 path->g_mylmc |= 1 << 7; 500 path->g_mylmc |= 1 << 7;
494 path->mgid_index = ah->grh.sgid_index; 501 path->mgid_index = ah->grh.sgid_index;
495 path->hop_limit = ah->grh.hop_limit; 502 path->hop_limit = ah->grh.hop_limit;
@@ -500,6 +507,8 @@ static void mthca_path_set(struct ib_ah_attr *ah, struct mthca_qp_path *path)
500 memcpy(path->rgid, ah->grh.dgid.raw, 16); 507 memcpy(path->rgid, ah->grh.dgid.raw, 16);
501 } else 508 } else
502 path->sl_tclass_flowlabel = cpu_to_be32(ah->sl << 28); 509 path->sl_tclass_flowlabel = cpu_to_be32(ah->sl << 28);
510
511 return 0;
503} 512}
504 513
505int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) 514int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
@@ -592,8 +601,14 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
592 601
593 if (qp->transport == MLX || qp->transport == UD) 602 if (qp->transport == MLX || qp->transport == UD)
594 qp_context->mtu_msgmax = (IB_MTU_2048 << 5) | 11; 603 qp_context->mtu_msgmax = (IB_MTU_2048 << 5) | 11;
595 else if (attr_mask & IB_QP_PATH_MTU) 604 else if (attr_mask & IB_QP_PATH_MTU) {
605 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) {
606 mthca_dbg(dev, "path MTU (%u) is invalid\n",
607 attr->path_mtu);
608 return -EINVAL;
609 }
596 qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31; 610 qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31;
611 }
597 612
598 if (mthca_is_memfree(dev)) { 613 if (mthca_is_memfree(dev)) {
599 if (qp->rq.max) 614 if (qp->rq.max)
@@ -642,7 +657,9 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
642 } 657 }
643 658
644 if (attr_mask & IB_QP_AV) { 659 if (attr_mask & IB_QP_AV) {
645 mthca_path_set(&attr->ah_attr, &qp_context->pri_path); 660 if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path))
661 return -EINVAL;
662
646 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH); 663 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH);
647 } 664 }
648 665
@@ -664,7 +681,9 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
664 return -EINVAL; 681 return -EINVAL;
665 } 682 }
666 683
667 mthca_path_set(&attr->alt_ah_attr, &qp_context->alt_path); 684 if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path))
685 return -EINVAL;
686
668 qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index | 687 qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index |
669 attr->alt_port_num << 24); 688 attr->alt_port_num << 24);
670 qp_context->alt_path.ackto = attr->alt_timeout << 3; 689 qp_context->alt_path.ackto = attr->alt_timeout << 3;
@@ -758,21 +777,20 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
758 777
759 err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0, 778 err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0,
760 mailbox, sqd_event, &status); 779 mailbox, sqd_event, &status);
780 if (err)
781 goto out;
761 if (status) { 782 if (status) {
762 mthca_warn(dev, "modify QP %d->%d returned status %02x.\n", 783 mthca_warn(dev, "modify QP %d->%d returned status %02x.\n",
763 cur_state, new_state, status); 784 cur_state, new_state, status);
764 err = -EINVAL; 785 err = -EINVAL;
786 goto out;
765 } 787 }
766 788
767 if (!err) { 789 qp->state = new_state;
768 qp->state = new_state; 790 if (attr_mask & IB_QP_ACCESS_FLAGS)
769 if (attr_mask & IB_QP_ACCESS_FLAGS) 791 qp->atomic_rd_en = attr->qp_access_flags;
770 qp->atomic_rd_en = attr->qp_access_flags; 792 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
771 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) 793 qp->resp_depth = attr->max_dest_rd_atomic;
772 qp->resp_depth = attr->max_dest_rd_atomic;
773 }
774
775 mthca_free_mailbox(dev, mailbox);
776 794
777 if (is_sqp(dev, qp)) 795 if (is_sqp(dev, qp))
778 store_attrs(to_msqp(qp), attr, attr_mask); 796 store_attrs(to_msqp(qp), attr, attr_mask);
@@ -797,7 +815,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
797 * If we moved a kernel QP to RESET, clean up all old CQ 815 * If we moved a kernel QP to RESET, clean up all old CQ
798 * entries and reinitialize the QP. 816 * entries and reinitialize the QP.
799 */ 817 */
800 if (!err && new_state == IB_QPS_RESET && !qp->ibqp.uobject) { 818 if (new_state == IB_QPS_RESET && !qp->ibqp.uobject) {
801 mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, 819 mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn,
802 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); 820 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
803 if (qp->ibqp.send_cq != qp->ibqp.recv_cq) 821 if (qp->ibqp.send_cq != qp->ibqp.recv_cq)
@@ -816,6 +834,8 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
816 } 834 }
817 } 835 }
818 836
837out:
838 mthca_free_mailbox(dev, mailbox);
819 return err; 839 return err;
820} 840}
821 841
@@ -1177,10 +1197,6 @@ int mthca_alloc_qp(struct mthca_dev *dev,
1177{ 1197{
1178 int err; 1198 int err;
1179 1199
1180 err = mthca_set_qp_size(dev, cap, pd, qp);
1181 if (err)
1182 return err;
1183
1184 switch (type) { 1200 switch (type) {
1185 case IB_QPT_RC: qp->transport = RC; break; 1201 case IB_QPT_RC: qp->transport = RC; break;
1186 case IB_QPT_UC: qp->transport = UC; break; 1202 case IB_QPT_UC: qp->transport = UC; break;
@@ -1188,6 +1204,10 @@ int mthca_alloc_qp(struct mthca_dev *dev,
1188 default: return -EINVAL; 1204 default: return -EINVAL;
1189 } 1205 }
1190 1206
1207 err = mthca_set_qp_size(dev, cap, pd, qp);
1208 if (err)
1209 return err;
1210
1191 qp->qpn = mthca_alloc(&dev->qp_table.alloc); 1211 qp->qpn = mthca_alloc(&dev->qp_table.alloc);
1192 if (qp->qpn == -1) 1212 if (qp->qpn == -1)
1193 return -ENOMEM; 1213 return -ENOMEM;
@@ -1220,6 +1240,7 @@ int mthca_alloc_sqp(struct mthca_dev *dev,
1220 u32 mqpn = qpn * 2 + dev->qp_table.sqp_start + port - 1; 1240 u32 mqpn = qpn * 2 + dev->qp_table.sqp_start + port - 1;
1221 int err; 1241 int err;
1222 1242
1243 sqp->qp.transport = MLX;
1223 err = mthca_set_qp_size(dev, cap, pd, &sqp->qp); 1244 err = mthca_set_qp_size(dev, cap, pd, &sqp->qp);
1224 if (err) 1245 if (err)
1225 return err; 1246 return err;
@@ -1980,8 +2001,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1980 wmb(); 2001 wmb();
1981 ((struct mthca_next_seg *) prev_wqe)->ee_nds = 2002 ((struct mthca_next_seg *) prev_wqe)->ee_nds =
1982 cpu_to_be32(MTHCA_NEXT_DBD | size | 2003 cpu_to_be32(MTHCA_NEXT_DBD | size |
1983 ((wr->send_flags & IB_SEND_FENCE) ? 2004 ((wr->send_flags & IB_SEND_FENCE) ?
1984 MTHCA_NEXT_FENCE : 0)); 2005 MTHCA_NEXT_FENCE : 0));
1985 2006
1986 if (!size0) { 2007 if (!size0) {
1987 size0 = size; 2008 size0 = size;
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 47a6a754a591..0cfd15802217 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -205,6 +205,10 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
205 ds = max(64UL, 205 ds = max(64UL,
206 roundup_pow_of_two(sizeof (struct mthca_next_seg) + 206 roundup_pow_of_two(sizeof (struct mthca_next_seg) +
207 srq->max_gs * sizeof (struct mthca_data_seg))); 207 srq->max_gs * sizeof (struct mthca_data_seg)));
208
209 if (ds > dev->limits.max_desc_sz)
210 return -EINVAL;
211
208 srq->wqe_shift = long_log2(ds); 212 srq->wqe_shift = long_log2(ds);
209 213
210 srq->srqn = mthca_alloc(&dev->srq_table.alloc); 214 srq->srqn = mthca_alloc(&dev->srq_table.alloc);
@@ -354,6 +358,8 @@ int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
354 return -EINVAL; 358 return -EINVAL;
355 359
356 if (attr_mask & IB_SRQ_LIMIT) { 360 if (attr_mask & IB_SRQ_LIMIT) {
361 if (attr->srq_limit > srq->max)
362 return -EINVAL;
357 ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status); 363 ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
358 if (ret) 364 if (ret)
359 return ret; 365 return ret;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 1251f86ec856..b640107fb732 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -72,13 +72,14 @@ enum {
72 IPOIB_MAX_MCAST_QUEUE = 3, 72 IPOIB_MAX_MCAST_QUEUE = 3,
73 73
74 IPOIB_FLAG_OPER_UP = 0, 74 IPOIB_FLAG_OPER_UP = 0,
75 IPOIB_FLAG_ADMIN_UP = 1, 75 IPOIB_FLAG_INITIALIZED = 1,
76 IPOIB_PKEY_ASSIGNED = 2, 76 IPOIB_FLAG_ADMIN_UP = 2,
77 IPOIB_PKEY_STOP = 3, 77 IPOIB_PKEY_ASSIGNED = 3,
78 IPOIB_FLAG_SUBINTERFACE = 4, 78 IPOIB_PKEY_STOP = 4,
79 IPOIB_MCAST_RUN = 5, 79 IPOIB_FLAG_SUBINTERFACE = 5,
80 IPOIB_STOP_REAPER = 6, 80 IPOIB_MCAST_RUN = 6,
81 IPOIB_MCAST_STARTED = 7, 81 IPOIB_STOP_REAPER = 7,
82 IPOIB_MCAST_STARTED = 8,
82 83
83 IPOIB_MAX_BACKOFF_SECONDS = 16, 84 IPOIB_MAX_BACKOFF_SECONDS = 16,
84 85
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index a1f5a05f2f36..ed65202878d8 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -423,13 +423,33 @@ int ipoib_ib_dev_open(struct net_device *dev)
423 clear_bit(IPOIB_STOP_REAPER, &priv->flags); 423 clear_bit(IPOIB_STOP_REAPER, &priv->flags);
424 queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ); 424 queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, HZ);
425 425
426 set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
427
426 return 0; 428 return 0;
427} 429}
428 430
431static void ipoib_pkey_dev_check_presence(struct net_device *dev)
432{
433 struct ipoib_dev_priv *priv = netdev_priv(dev);
434 u16 pkey_index = 0;
435
436 if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index))
437 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
438 else
439 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
440}
441
429int ipoib_ib_dev_up(struct net_device *dev) 442int ipoib_ib_dev_up(struct net_device *dev)
430{ 443{
431 struct ipoib_dev_priv *priv = netdev_priv(dev); 444 struct ipoib_dev_priv *priv = netdev_priv(dev);
432 445
446 ipoib_pkey_dev_check_presence(dev);
447
448 if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
449 ipoib_dbg(priv, "PKEY is not assigned.\n");
450 return 0;
451 }
452
433 set_bit(IPOIB_FLAG_OPER_UP, &priv->flags); 453 set_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
434 454
435 return ipoib_mcast_start_thread(dev); 455 return ipoib_mcast_start_thread(dev);
@@ -483,6 +503,8 @@ int ipoib_ib_dev_stop(struct net_device *dev)
483 struct ipoib_tx_buf *tx_req; 503 struct ipoib_tx_buf *tx_req;
484 int i; 504 int i;
485 505
506 clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
507
486 /* 508 /*
487 * Move our QP to the error state and then reinitialize in 509 * Move our QP to the error state and then reinitialize in
488 * when all work requests have completed or have been flushed. 510 * when all work requests have completed or have been flushed.
@@ -587,8 +609,15 @@ void ipoib_ib_dev_flush(void *_dev)
587 struct net_device *dev = (struct net_device *)_dev; 609 struct net_device *dev = (struct net_device *)_dev;
588 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv; 610 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv;
589 611
590 if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) 612 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) {
613 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
614 return;
615 }
616
617 if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
618 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_ADMIN_UP not set.\n");
591 return; 619 return;
620 }
592 621
593 ipoib_dbg(priv, "flushing\n"); 622 ipoib_dbg(priv, "flushing\n");
594 623
@@ -605,7 +634,7 @@ void ipoib_ib_dev_flush(void *_dev)
605 634
606 /* Flush any child interfaces too */ 635 /* Flush any child interfaces too */
607 list_for_each_entry(cpriv, &priv->child_intfs, list) 636 list_for_each_entry(cpriv, &priv->child_intfs, list)
608 ipoib_ib_dev_flush(&cpriv->dev); 637 ipoib_ib_dev_flush(cpriv->dev);
609 638
610 mutex_unlock(&priv->vlan_mutex); 639 mutex_unlock(&priv->vlan_mutex);
611} 640}
@@ -632,17 +661,6 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
632 * change async notification is available. 661 * change async notification is available.
633 */ 662 */
634 663
635static void ipoib_pkey_dev_check_presence(struct net_device *dev)
636{
637 struct ipoib_dev_priv *priv = netdev_priv(dev);
638 u16 pkey_index = 0;
639
640 if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index))
641 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
642 else
643 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
644}
645
646void ipoib_pkey_poll(void *dev_ptr) 664void ipoib_pkey_poll(void *dev_ptr)
647{ 665{
648 struct net_device *dev = dev_ptr; 666 struct net_device *dev = dev_ptr;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 37da8d3dc388..53a32f65788d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -736,6 +736,11 @@ static void ipoib_set_mcast_list(struct net_device *dev)
736{ 736{
737 struct ipoib_dev_priv *priv = netdev_priv(dev); 737 struct ipoib_dev_priv *priv = netdev_priv(dev);
738 738
739 if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) {
740 ipoib_dbg(priv, "IPOIB_FLAG_OPER_UP not set");
741 return;
742 }
743
739 queue_work(ipoib_workqueue, &priv->restart_task); 744 queue_work(ipoib_workqueue, &priv->restart_task);
740} 745}
741 746
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 18d2f53ec34c..5f0388027b25 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -251,10 +251,12 @@ void ipoib_event(struct ib_event_handler *handler,
251 struct ipoib_dev_priv *priv = 251 struct ipoib_dev_priv *priv =
252 container_of(handler, struct ipoib_dev_priv, event_handler); 252 container_of(handler, struct ipoib_dev_priv, event_handler);
253 253
254 if (record->event == IB_EVENT_PORT_ACTIVE || 254 if (record->event == IB_EVENT_PORT_ERR ||
255 record->event == IB_EVENT_PKEY_CHANGE ||
256 record->event == IB_EVENT_PORT_ACTIVE ||
255 record->event == IB_EVENT_LID_CHANGE || 257 record->event == IB_EVENT_LID_CHANGE ||
256 record->event == IB_EVENT_SM_CHANGE) { 258 record->event == IB_EVENT_SM_CHANGE) {
257 ipoib_dbg(priv, "Port active event\n"); 259 ipoib_dbg(priv, "Port state change event\n");
258 queue_work(ipoib_workqueue, &priv->flush_task); 260 queue_work(ipoib_workqueue, &priv->flush_task);
259 } 261 }
260} 262}
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index a13dcdf90a4f..61924cc30e55 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -503,8 +503,10 @@ err:
503static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, 503static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
504 struct srp_request *req) 504 struct srp_request *req)
505{ 505{
506 struct scatterlist *scat;
506 struct srp_cmd *cmd = req->cmd->buf; 507 struct srp_cmd *cmd = req->cmd->buf;
507 int len; 508 int len, nents, count;
509 int i;
508 u8 fmt; 510 u8 fmt;
509 511
510 if (!scmnd->request_buffer || scmnd->sc_data_direction == DMA_NONE) 512 if (!scmnd->request_buffer || scmnd->sc_data_direction == DMA_NONE)
@@ -517,82 +519,66 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
517 return -EINVAL; 519 return -EINVAL;
518 } 520 }
519 521
520 if (scmnd->use_sg) { 522 /*
521 struct scatterlist *scat = scmnd->request_buffer; 523 * This handling of non-SG commands can be killed when the
522 int n; 524 * SCSI midlayer no longer generates non-SG commands.
523 int i; 525 */
524 526 if (likely(scmnd->use_sg)) {
525 n = dma_map_sg(target->srp_host->dev->dma_device, 527 nents = scmnd->use_sg;
526 scat, scmnd->use_sg, scmnd->sc_data_direction); 528 scat = scmnd->request_buffer;
529 } else {
530 nents = 1;
531 scat = &req->fake_sg;
532 sg_init_one(scat, scmnd->request_buffer, scmnd->request_bufflen);
533 }
527 534
528 if (n == 1) { 535 count = dma_map_sg(target->srp_host->dev->dma_device, scat, nents,
529 struct srp_direct_buf *buf = (void *) cmd->add_data; 536 scmnd->sc_data_direction);
530 537
531 fmt = SRP_DATA_DESC_DIRECT; 538 if (count == 1) {
539 struct srp_direct_buf *buf = (void *) cmd->add_data;
532 540
533 buf->va = cpu_to_be64(sg_dma_address(scat)); 541 fmt = SRP_DATA_DESC_DIRECT;
534 buf->key = cpu_to_be32(target->srp_host->mr->rkey);
535 buf->len = cpu_to_be32(sg_dma_len(scat));
536 542
537 len = sizeof (struct srp_cmd) + 543 buf->va = cpu_to_be64(sg_dma_address(scat));
538 sizeof (struct srp_direct_buf); 544 buf->key = cpu_to_be32(target->srp_host->mr->rkey);
539 } else { 545 buf->len = cpu_to_be32(sg_dma_len(scat));
540 struct srp_indirect_buf *buf = (void *) cmd->add_data;
541 u32 datalen = 0;
542 546
543 fmt = SRP_DATA_DESC_INDIRECT; 547 len = sizeof (struct srp_cmd) +
548 sizeof (struct srp_direct_buf);
549 } else {
550 struct srp_indirect_buf *buf = (void *) cmd->add_data;
551 u32 datalen = 0;
544 552
545 if (scmnd->sc_data_direction == DMA_TO_DEVICE) 553 fmt = SRP_DATA_DESC_INDIRECT;
546 cmd->data_out_desc_cnt = n;
547 else
548 cmd->data_in_desc_cnt = n;
549 554
550 buf->table_desc.va = cpu_to_be64(req->cmd->dma + 555 if (scmnd->sc_data_direction == DMA_TO_DEVICE)
551 sizeof *cmd + 556 cmd->data_out_desc_cnt = count;
552 sizeof *buf); 557 else
553 buf->table_desc.key = 558 cmd->data_in_desc_cnt = count;
559
560 buf->table_desc.va = cpu_to_be64(req->cmd->dma +
561 sizeof *cmd +
562 sizeof *buf);
563 buf->table_desc.key =
564 cpu_to_be32(target->srp_host->mr->rkey);
565 buf->table_desc.len =
566 cpu_to_be32(count * sizeof (struct srp_direct_buf));
567
568 for (i = 0; i < count; ++i) {
569 buf->desc_list[i].va = cpu_to_be64(sg_dma_address(&scat[i]));
570 buf->desc_list[i].key =
554 cpu_to_be32(target->srp_host->mr->rkey); 571 cpu_to_be32(target->srp_host->mr->rkey);
555 buf->table_desc.len = 572 buf->desc_list[i].len = cpu_to_be32(sg_dma_len(&scat[i]));
556 cpu_to_be32(n * sizeof (struct srp_direct_buf));
557
558 for (i = 0; i < n; ++i) {
559 buf->desc_list[i].va = cpu_to_be64(sg_dma_address(&scat[i]));
560 buf->desc_list[i].key =
561 cpu_to_be32(target->srp_host->mr->rkey);
562 buf->desc_list[i].len = cpu_to_be32(sg_dma_len(&scat[i]));
563
564 datalen += sg_dma_len(&scat[i]);
565 }
566 573
567 buf->len = cpu_to_be32(datalen); 574 datalen += sg_dma_len(&scat[i]);
568
569 len = sizeof (struct srp_cmd) +
570 sizeof (struct srp_indirect_buf) +
571 n * sizeof (struct srp_direct_buf);
572 }
573 } else {
574 struct srp_direct_buf *buf = (void *) cmd->add_data;
575 dma_addr_t dma;
576
577 dma = dma_map_single(target->srp_host->dev->dma_device,
578 scmnd->request_buffer, scmnd->request_bufflen,
579 scmnd->sc_data_direction);
580 if (dma_mapping_error(dma)) {
581 printk(KERN_WARNING PFX "unable to map %p/%d (dir %d)\n",
582 scmnd->request_buffer, (int) scmnd->request_bufflen,
583 scmnd->sc_data_direction);
584 return -EINVAL;
585 } 575 }
586 576
587 pci_unmap_addr_set(req, direct_mapping, dma); 577 buf->len = cpu_to_be32(datalen);
588 578
589 buf->va = cpu_to_be64(dma); 579 len = sizeof (struct srp_cmd) +
590 buf->key = cpu_to_be32(target->srp_host->mr->rkey); 580 sizeof (struct srp_indirect_buf) +
591 buf->len = cpu_to_be32(scmnd->request_bufflen); 581 count * sizeof (struct srp_direct_buf);
592
593 fmt = SRP_DATA_DESC_DIRECT;
594
595 len = sizeof (struct srp_cmd) + sizeof (struct srp_direct_buf);
596 } 582 }
597 583
598 if (scmnd->sc_data_direction == DMA_TO_DEVICE) 584 if (scmnd->sc_data_direction == DMA_TO_DEVICE)
@@ -600,7 +586,6 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
600 else 586 else
601 cmd->buf_fmt = fmt; 587 cmd->buf_fmt = fmt;
602 588
603
604 return len; 589 return len;
605} 590}
606 591
@@ -608,20 +593,28 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
608 struct srp_target_port *target, 593 struct srp_target_port *target,
609 struct srp_request *req) 594 struct srp_request *req)
610{ 595{
596 struct scatterlist *scat;
597 int nents;
598
611 if (!scmnd->request_buffer || 599 if (!scmnd->request_buffer ||
612 (scmnd->sc_data_direction != DMA_TO_DEVICE && 600 (scmnd->sc_data_direction != DMA_TO_DEVICE &&
613 scmnd->sc_data_direction != DMA_FROM_DEVICE)) 601 scmnd->sc_data_direction != DMA_FROM_DEVICE))
614 return; 602 return;
615 603
616 if (scmnd->use_sg) 604 /*
617 dma_unmap_sg(target->srp_host->dev->dma_device, 605 * This handling of non-SG commands can be killed when the
618 (struct scatterlist *) scmnd->request_buffer, 606 * SCSI midlayer no longer generates non-SG commands.
619 scmnd->use_sg, scmnd->sc_data_direction); 607 */
620 else 608 if (likely(scmnd->use_sg)) {
621 dma_unmap_single(target->srp_host->dev->dma_device, 609 nents = scmnd->use_sg;
622 pci_unmap_addr(req, direct_mapping), 610 scat = (struct scatterlist *) scmnd->request_buffer;
623 scmnd->request_bufflen, 611 } else {
624 scmnd->sc_data_direction); 612 nents = 1;
613 scat = (struct scatterlist *) scmnd->request_buffer;
614 }
615
616 dma_unmap_sg(target->srp_host->dev->dma_device, scat, nents,
617 scmnd->sc_data_direction);
625} 618}
626 619
627static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) 620static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 4e7727df32f1..bd7f7c3115de 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -38,6 +38,7 @@
38#include <linux/types.h> 38#include <linux/types.h>
39#include <linux/list.h> 39#include <linux/list.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/scatterlist.h>
41 42
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <scsi/scsi_cmnd.h> 44#include <scsi/scsi_cmnd.h>
@@ -94,7 +95,11 @@ struct srp_request {
94 struct scsi_cmnd *scmnd; 95 struct scsi_cmnd *scmnd;
95 struct srp_iu *cmd; 96 struct srp_iu *cmd;
96 struct srp_iu *tsk_mgmt; 97 struct srp_iu *tsk_mgmt;
97 DECLARE_PCI_UNMAP_ADDR(direct_mapping) 98 /*
99 * Fake scatterlist used when scmnd->use_sg==0. Can be killed
100 * when the SCSI midlayer no longer generates non-SG commands.
101 */
102 struct scatterlist fake_sg;
98 struct completion done; 103 struct completion done;
99 short next; 104 short next;
100 u8 cmd_done; 105 u8 cmd_done;
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index 5704204964a3..ea499783fb12 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) {
556 do_gettimeofday(&(mlc->instart)); 556 do_gettimeofday(&(mlc->instart));
557 mlc->icount = 15; 557 mlc->icount = 15;
558 memset(mlc->ipacket, 0, 16 * sizeof(hil_packet)); 558 memset(mlc->ipacket, 0, 16 * sizeof(hil_packet));
559 if (down_trylock(&(mlc->isem))) BUG(); 559 BUG_ON(down_trylock(&(mlc->isem)));
560 560
561 return; 561 return;
562} 562}
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 8c12a974b411..a81f987978c8 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -23,6 +23,7 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h> 25#include <linux/spi/ads7846.h>
26#include <linux/interrupt.h>
26 27
27#ifdef CONFIG_ARM 28#ifdef CONFIG_ARM
28#include <asm/mach-types.h> 29#include <asm/mach-types.h>
diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c
index 91dd0551fc7c..4d64e5cbcdbf 100644
--- a/drivers/isdn/hardware/avm/b1dma.c
+++ b/drivers/isdn/hardware/avm/b1dma.c
@@ -39,7 +39,7 @@ MODULE_AUTHOR("Carsten Paeth");
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41static int suppress_pollack = 0; 41static int suppress_pollack = 0;
42MODULE_PARM(suppress_pollack, "0-1i"); 42module_param(suppress_pollack, bool, 0);
43 43
44/* ------------------------------------------------------------- */ 44/* ------------------------------------------------------------- */
45 45
diff --git a/drivers/isdn/hardware/avm/b1isa.c b/drivers/isdn/hardware/avm/b1isa.c
index 38bd4dfecbd1..80fb488848b8 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];
169static int io[MAX_CARDS]; 169static int io[MAX_CARDS];
170static int irq[MAX_CARDS]; 170static int irq[MAX_CARDS];
171 171
172MODULE_PARM(io, "1-" __MODULE_STRING(MAX_CARDS) "i"); 172module_param_array(io, int, NULL, 0);
173MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_CARDS) "i"); 173module_param_array(irq, int, NULL, 0);
174MODULE_PARM_DESC(io, "I/O base address(es)"); 174MODULE_PARM_DESC(io, "I/O base address(es)");
175MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); 175MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
176 176
diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
index 724aac2c1cca..f7253b2136ea 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);
50MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM C2/C4 cards"); 50MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM C2/C4 cards");
51MODULE_AUTHOR("Carsten Paeth"); 51MODULE_AUTHOR("Carsten Paeth");
52MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
53MODULE_PARM(suppress_pollack, "0-1i"); 53module_param(suppress_pollack, bool, 0);
54 54
55/* ------------------------------------------------------------- */ 55/* ------------------------------------------------------------- */
56 56
diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c
index 3b701d97bdf1..5a2f854d55b5 100644
--- a/drivers/isdn/hardware/avm/t1isa.c
+++ b/drivers/isdn/hardware/avm/t1isa.c
@@ -519,9 +519,9 @@ static int io[MAX_CARDS];
519static int irq[MAX_CARDS]; 519static int irq[MAX_CARDS];
520static int cardnr[MAX_CARDS]; 520static int cardnr[MAX_CARDS];
521 521
522MODULE_PARM(io, "1-" __MODULE_STRING(MAX_CARDS) "i"); 522module_param_array(io, int, NULL, 0);
523MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_CARDS) "i"); 523module_param_array(irq, int, NULL, 0);
524MODULE_PARM(cardnr, "1-" __MODULE_STRING(MAX_CARDS) "i"); 524module_param_array(cardnr, int, NULL, 0);
525MODULE_PARM_DESC(io, "I/O base address(es)"); 525MODULE_PARM_DESC(io, "I/O base address(es)");
526MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); 526MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
527MODULE_PARM_DESC(cardnr, "Card number(s) (as jumpered)"); 527MODULE_PARM_DESC(cardnr, "Card number(s) (as jumpered)");
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index e19a01a305a9..48d134be9908 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)
38{ 38{
39 hysdn_card *card = dev_id; /* parameter from irq */ 39 hysdn_card *card = dev_id; /* parameter from irq */
40 tErgDpram *dpr; 40 tErgDpram *dpr;
41 ulong flags; 41 unsigned long flags;
42 uchar volatile b; 42 unsigned char volatile b;
43 43
44 if (!card) 44 if (!card)
45 return IRQ_NONE; /* error -> spurious interrupt */ 45 return IRQ_NONE; /* error -> spurious interrupt */
@@ -77,7 +77,7 @@ ergo_irq_bh(hysdn_card * card)
77{ 77{
78 tErgDpram *dpr; 78 tErgDpram *dpr;
79 int again; 79 int again;
80 ulong flags; 80 unsigned long flags;
81 81
82 if (card->state != CARD_STATE_RUN) 82 if (card->state != CARD_STATE_RUN)
83 return; /* invalid call */ 83 return; /* invalid call */
@@ -131,8 +131,8 @@ ergo_irq_bh(hysdn_card * card)
131static void 131static void
132ergo_stopcard(hysdn_card * card) 132ergo_stopcard(hysdn_card * card)
133{ 133{
134 ulong flags; 134 unsigned long flags;
135 uchar val; 135 unsigned char val;
136 136
137 hysdn_net_release(card); /* first release the net device if existing */ 137 hysdn_net_release(card); /* first release the net device if existing */
138#ifdef CONFIG_HYSDN_CAPI 138#ifdef CONFIG_HYSDN_CAPI
@@ -157,7 +157,7 @@ ergo_stopcard(hysdn_card * card)
157static void 157static void
158ergo_set_errlog_state(hysdn_card * card, int on) 158ergo_set_errlog_state(hysdn_card * card, int on)
159{ 159{
160 ulong flags; 160 unsigned long flags;
161 161
162 if (card->state != CARD_STATE_RUN) { 162 if (card->state != CARD_STATE_RUN) {
163 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ 163 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
@@ -217,9 +217,10 @@ ergo_testram(hysdn_card * card)
217/* Negative return values are interpreted as errors. */ 217/* Negative return values are interpreted as errors. */
218/*****************************************************************************/ 218/*****************************************************************************/
219static int 219static int
220ergo_writebootimg(struct HYSDN_CARD *card, uchar * buf, ulong offs) 220ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf,
221 unsigned long offs)
221{ 222{
222 uchar *dst; 223 unsigned char *dst;
223 tErgDpram *dpram; 224 tErgDpram *dpram;
224 int cnt = (BOOT_IMG_SIZE >> 2); /* number of words to move and swap (byte order!) */ 225 int cnt = (BOOT_IMG_SIZE >> 2); /* number of words to move and swap (byte order!) */
225 226
@@ -264,14 +265,14 @@ ergo_writebootimg(struct HYSDN_CARD *card, uchar * buf, ulong offs)
264/* case of errors a negative error value is returned. */ 265/* case of errors a negative error value is returned. */
265/********************************************************************************/ 266/********************************************************************************/
266static int 267static int
267ergo_writebootseq(struct HYSDN_CARD *card, uchar * buf, int len) 268ergo_writebootseq(struct HYSDN_CARD *card, unsigned char *buf, int len)
268{ 269{
269 tDpramBootSpooler *sp = (tDpramBootSpooler *) card->dpram; 270 tDpramBootSpooler *sp = (tDpramBootSpooler *) card->dpram;
270 uchar *dst; 271 unsigned char *dst;
271 uchar buflen; 272 unsigned char buflen;
272 int nr_write; 273 int nr_write;
273 uchar tmp_rdptr; 274 unsigned char tmp_rdptr;
274 uchar wr_mirror; 275 unsigned char wr_mirror;
275 int i; 276 int i;
276 277
277 if (card->debug_flags & LOG_POF_CARD) 278 if (card->debug_flags & LOG_POF_CARD)
@@ -330,7 +331,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
330{ 331{
331 tErgDpram *dpr = card->dpram; /* pointer to DPRAM structure */ 332 tErgDpram *dpr = card->dpram; /* pointer to DPRAM structure */
332 int timecnt = 10000 / 50; /* timeout is 10 secs max. */ 333 int timecnt = 10000 / 50; /* timeout is 10 secs max. */
333 ulong flags; 334 unsigned long flags;
334 int msg_size; 335 int msg_size;
335 int i; 336 int i;
336 337
@@ -345,7 +346,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
345 if ((dpr->ToPcChannel != CHAN_SYSTEM) || 346 if ((dpr->ToPcChannel != CHAN_SYSTEM) ||
346 (dpr->ToPcSize < MIN_RDY_MSG_SIZE) || 347 (dpr->ToPcSize < MIN_RDY_MSG_SIZE) ||
347 (dpr->ToPcSize > MAX_RDY_MSG_SIZE) || 348 (dpr->ToPcSize > MAX_RDY_MSG_SIZE) ||
348 ((*(ulong *) dpr->ToPcBuf) != RDY_MAGIC)) 349 ((*(unsigned long *) dpr->ToPcBuf) != RDY_MAGIC))
349 break; /* an error occurred */ 350 break; /* an error occurred */
350 351
351 /* Check for additional data delivered during SysReady */ 352 /* Check for additional data delivered during SysReady */
diff --git a/drivers/isdn/hysdn/boardergo.h b/drivers/isdn/hysdn/boardergo.h
index b56ff0889ead..c59422aa8c3f 100644
--- a/drivers/isdn/hysdn/boardergo.h
+++ b/drivers/isdn/hysdn/boardergo.h
@@ -23,36 +23,36 @@
23 23
24/* following DPRAM layout copied from OS2-driver boarderg.h */ 24/* following DPRAM layout copied from OS2-driver boarderg.h */
25typedef struct ErgDpram_tag { 25typedef struct ErgDpram_tag {
26/*0000 */ uchar ToHyBuf[ERG_TO_HY_BUF_SIZE]; 26/*0000 */ unsigned char ToHyBuf[ERG_TO_HY_BUF_SIZE];
27/*0E00 */ uchar ToPcBuf[ERG_TO_PC_BUF_SIZE]; 27/*0E00 */ unsigned char ToPcBuf[ERG_TO_PC_BUF_SIZE];
28 28
29 /*1C00 */ uchar bSoftUart[SIZE_RSV_SOFT_UART]; 29 /*1C00 */ unsigned char bSoftUart[SIZE_RSV_SOFT_UART];
30 /* size 0x1B0 */ 30 /* size 0x1B0 */
31 31
32 /*1DB0 *//* tErrLogEntry */ uchar volatile ErrLogMsg[64]; 32 /*1DB0 *//* tErrLogEntry */ unsigned char volatile ErrLogMsg[64];
33 /* size 64 bytes */ 33 /* size 64 bytes */
34 /*1DB0 ulong ulErrType; */ 34 /*1DB0 unsigned long ulErrType; */
35 /*1DB4 ulong ulErrSubtype; */ 35 /*1DB4 unsigned long ulErrSubtype; */
36 /*1DB8 ulong ucTextSize; */ 36 /*1DB8 unsigned long ucTextSize; */
37 /*1DB9 ulong ucText[ERRLOG_TEXT_SIZE]; *//* ASCIIZ of len ucTextSize-1 */ 37 /*1DB9 unsigned long ucText[ERRLOG_TEXT_SIZE]; *//* ASCIIZ of len ucTextSize-1 */
38 /*1DF0 */ 38 /*1DF0 */
39 39
40/*1DF0 */ word volatile ToHyChannel; 40/*1DF0 */ unsigned short volatile ToHyChannel;
41/*1DF2 */ word volatile ToHySize; 41/*1DF2 */ unsigned short volatile ToHySize;
42 /*1DF4 */ uchar volatile ToHyFlag; 42 /*1DF4 */ unsigned char volatile ToHyFlag;
43 /* !=0: msg for Hy waiting */ 43 /* !=0: msg for Hy waiting */
44 /*1DF5 */ uchar volatile ToPcFlag; 44 /*1DF5 */ unsigned char volatile ToPcFlag;
45 /* !=0: msg for PC waiting */ 45 /* !=0: msg for PC waiting */
46/*1DF6 */ word volatile ToPcChannel; 46/*1DF6 */ unsigned short volatile ToPcChannel;
47/*1DF8 */ word volatile ToPcSize; 47/*1DF8 */ unsigned short volatile ToPcSize;
48 /*1DFA */ uchar bRes1DBA[0x1E00 - 0x1DFA]; 48 /*1DFA */ unsigned char bRes1DBA[0x1E00 - 0x1DFA];
49 /* 6 bytes */ 49 /* 6 bytes */
50 50
51/*1E00 */ uchar bRestOfEntryTbl[0x1F00 - 0x1E00]; 51/*1E00 */ unsigned char bRestOfEntryTbl[0x1F00 - 0x1E00];
52/*1F00 */ ulong TrapTable[62]; 52/*1F00 */ unsigned long TrapTable[62];
53 /*1FF8 */ uchar bRes1FF8[0x1FFB - 0x1FF8]; 53 /*1FF8 */ unsigned char bRes1FF8[0x1FFB - 0x1FF8];
54 /* low part of reset vetor */ 54 /* low part of reset vetor */
55/*1FFB */ uchar ToPcIntMetro; 55/*1FFB */ unsigned char ToPcIntMetro;
56 /* notes: 56 /* notes:
57 * - metro has 32-bit boot ram - accessing 57 * - metro has 32-bit boot ram - accessing
58 * ToPcInt and ToHyInt would be the same; 58 * ToPcInt and ToHyInt would be the same;
@@ -65,16 +65,16 @@ typedef struct ErgDpram_tag {
65 * so E1 side should NOT change this byte 65 * so E1 side should NOT change this byte
66 * when writing! 66 * when writing!
67 */ 67 */
68/*1FFC */ uchar volatile ToHyNoDpramErrLog; 68/*1FFC */ unsigned char volatile ToHyNoDpramErrLog;
69 /* note: ToHyNoDpramErrLog is used to inform 69 /* note: ToHyNoDpramErrLog is used to inform
70 * boot loader, not to use DPRAM based 70 * boot loader, not to use DPRAM based
71 * ErrLog; when DOS driver is rewritten 71 * ErrLog; when DOS driver is rewritten
72 * this becomes obsolete 72 * this becomes obsolete
73 */ 73 */
74/*1FFD */ uchar bRes1FFD; 74/*1FFD */ unsigned char bRes1FFD;
75 /*1FFE */ uchar ToPcInt; 75 /*1FFE */ unsigned char ToPcInt;
76 /* E1_intclear; on CHAMP2: E1_intset */ 76 /* E1_intclear; on CHAMP2: E1_intset */
77 /*1FFF */ uchar ToHyInt; 77 /*1FFF */ unsigned char ToHyInt;
78 /* E1_intset; on CHAMP2: E1_intclear */ 78 /* E1_intset; on CHAMP2: E1_intclear */
79} tErgDpram; 79} tErgDpram;
80 80
diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c
index acc1d3cceebb..6bac43cc91bd 100644
--- a/drivers/isdn/hysdn/hycapi.c
+++ b/drivers/isdn/hysdn/hycapi.c
@@ -31,7 +31,7 @@
31static char hycapi_revision[]="$Revision: 1.8.6.4 $"; 31static char hycapi_revision[]="$Revision: 1.8.6.4 $";
32 32
33unsigned int hycapi_enable = 0xffffffff; 33unsigned int hycapi_enable = 0xffffffff;
34MODULE_PARM(hycapi_enable, "i"); 34module_param(hycapi_enable, uint, 0);
35 35
36typedef struct _hycapi_appl { 36typedef struct _hycapi_appl {
37 unsigned int ctrl_mask; 37 unsigned int ctrl_mask;
@@ -523,7 +523,7 @@ New nccis are created if necessary.
523*******************************************************************/ 523*******************************************************************/
524 524
525void 525void
526hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len) 526hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len)
527{ 527{
528 struct sk_buff *skb; 528 struct sk_buff *skb;
529 hycapictrl_info *cinfo = card->hyctrlinfo; 529 hycapictrl_info *cinfo = card->hyctrlinfo;
diff --git a/drivers/isdn/hysdn/hysdn_boot.c b/drivers/isdn/hysdn/hysdn_boot.c
index 7bfba196f315..6d0eb0f42fca 100644
--- a/drivers/isdn/hysdn/hysdn_boot.c
+++ b/drivers/isdn/hysdn/hysdn_boot.c
@@ -30,17 +30,17 @@
30/* needed during boot and so allocated dynamically. */ 30/* needed during boot and so allocated dynamically. */
31/************************************************************/ 31/************************************************************/
32struct boot_data { 32struct boot_data {
33 word Cryptor; /* for use with Decrypt function */ 33 unsigned short Cryptor; /* for use with Decrypt function */
34 word Nrecs; /* records remaining in file */ 34 unsigned short Nrecs; /* records remaining in file */
35 uchar pof_state; /* actual state of read handler */ 35 unsigned char pof_state;/* actual state of read handler */
36 uchar is_crypted; /* card data is crypted */ 36 unsigned char is_crypted;/* card data is crypted */
37 int BufSize; /* actual number of bytes bufferd */ 37 int BufSize; /* actual number of bytes bufferd */
38 int last_error; /* last occurred error */ 38 int last_error; /* last occurred error */
39 word pof_recid; /* actual pof recid */ 39 unsigned short pof_recid;/* actual pof recid */
40 ulong pof_reclen; /* total length of pof record data */ 40 unsigned long pof_reclen;/* total length of pof record data */
41 ulong pof_recoffset; /* actual offset inside pof record */ 41 unsigned long pof_recoffset;/* actual offset inside pof record */
42 union { 42 union {
43 uchar BootBuf[BOOT_BUF_SIZE]; /* buffer as byte count */ 43 unsigned char BootBuf[BOOT_BUF_SIZE];/* buffer as byte count */
44 tPofRecHdr PofRecHdr; /* header for actual record/chunk */ 44 tPofRecHdr PofRecHdr; /* header for actual record/chunk */
45 tPofFileHdr PofFileHdr; /* header from POF file */ 45 tPofFileHdr PofFileHdr; /* header from POF file */
46 tPofTimeStamp PofTime; /* time information */ 46 tPofTimeStamp PofTime; /* time information */
@@ -69,11 +69,11 @@ StartDecryption(struct boot_data *boot)
69static void 69static void
70DecryptBuf(struct boot_data *boot, int cnt) 70DecryptBuf(struct boot_data *boot, int cnt)
71{ 71{
72 uchar *bufp = boot->buf.BootBuf; 72 unsigned char *bufp = boot->buf.BootBuf;
73 73
74 while (cnt--) { 74 while (cnt--) {
75 boot->Cryptor = (boot->Cryptor >> 1) ^ ((boot->Cryptor & 1U) ? CRYPT_FEEDTERM : 0); 75 boot->Cryptor = (boot->Cryptor >> 1) ^ ((boot->Cryptor & 1U) ? CRYPT_FEEDTERM : 0);
76 *bufp++ ^= (uchar) boot->Cryptor; 76 *bufp++ ^= (unsigned char)boot->Cryptor;
77 } 77 }
78} /* DecryptBuf */ 78} /* DecryptBuf */
79 79
@@ -86,7 +86,7 @@ pof_handle_data(hysdn_card * card, int datlen)
86{ 86{
87 struct boot_data *boot = card->boot; /* pointer to boot specific data */ 87 struct boot_data *boot = card->boot; /* pointer to boot specific data */
88 long l; 88 long l;
89 uchar *imgp; 89 unsigned char *imgp;
90 int img_len; 90 int img_len;
91 91
92 /* handle the different record types */ 92 /* handle the different record types */
@@ -197,7 +197,7 @@ pof_write_buffer(hysdn_card * card, int datlen)
197 break; 197 break;
198 } 198 }
199 /* Setup the new state and vars */ 199 /* Setup the new state and vars */
200 boot->Nrecs = (word) (boot->buf.PofFileHdr.N_PofRecs); /* limited to 65535 */ 200 boot->Nrecs = (unsigned short)(boot->buf.PofFileHdr.N_PofRecs); /* limited to 65535 */
201 boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ 201 boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */
202 boot->last_error = sizeof(tPofRecHdr); /* new length */ 202 boot->last_error = sizeof(tPofRecHdr); /* new length */
203 break; 203 break;
@@ -268,7 +268,7 @@ pof_write_buffer(hysdn_card * card, int datlen)
268/* occurred. Additionally the pointer to the buffer data area is set on success */ 268/* occurred. Additionally the pointer to the buffer data area is set on success */
269/*******************************************************************************/ 269/*******************************************************************************/
270int 270int
271pof_write_open(hysdn_card * card, uchar ** bufp) 271pof_write_open(hysdn_card * card, unsigned char **bufp)
272{ 272{
273 struct boot_data *boot; /* pointer to boot specific data */ 273 struct boot_data *boot; /* pointer to boot specific data */
274 274
@@ -335,7 +335,7 @@ pof_write_close(hysdn_card * card)
335/* when POF has been booted. A return value of 0 is used if no error occurred. */ 335/* when POF has been booted. A return value of 0 is used if no error occurred. */
336/*********************************************************************************/ 336/*********************************************************************************/
337int 337int
338EvalSysrTokData(hysdn_card * card, uchar * cp, int len) 338EvalSysrTokData(hysdn_card *card, unsigned char *cp, int len)
339{ 339{
340 u_char *p; 340 u_char *p;
341 u_char crc; 341 u_char crc;
diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h
index 432f6f99089e..3a9b29b38bc4 100644
--- a/drivers/isdn/hysdn/hysdn_defs.h
+++ b/drivers/isdn/hysdn/hysdn_defs.h
@@ -20,14 +20,6 @@
20#include <linux/workqueue.h> 20#include <linux/workqueue.h>
21#include <linux/skbuff.h> 21#include <linux/skbuff.h>
22 22
23/****************************/
24/* storage type definitions */
25/****************************/
26#define uchar unsigned char
27#define uint unsigned int
28#define ulong unsigned long
29#define word unsigned short
30
31#include "ince1pc.h" 23#include "ince1pc.h"
32 24
33#ifdef CONFIG_HYSDN_CAPI 25#ifdef CONFIG_HYSDN_CAPI
@@ -147,18 +139,18 @@ typedef struct HYSDN_CARD {
147 139
148 /* general variables for the cards */ 140 /* general variables for the cards */
149 int myid; /* own driver card id */ 141 int myid; /* own driver card id */
150 uchar bus; /* pci bus the card is connected to */ 142 unsigned char bus; /* pci bus the card is connected to */
151 uchar devfn; /* slot+function bit encoded */ 143 unsigned char devfn; /* slot+function bit encoded */
152 word subsysid; /* PCI subsystem id */ 144 unsigned short subsysid;/* PCI subsystem id */
153 uchar brdtype; /* type of card */ 145 unsigned char brdtype; /* type of card */
154 uint bchans; /* number of available B-channels */ 146 unsigned int bchans; /* number of available B-channels */
155 uint faxchans; /* number of available fax-channels */ 147 unsigned int faxchans; /* number of available fax-channels */
156 uchar mac_addr[6]; /* MAC Address read from card */ 148 unsigned char mac_addr[6];/* MAC Address read from card */
157 uint irq; /* interrupt number */ 149 unsigned int irq; /* interrupt number */
158 uint iobase; /* IO-port base address */ 150 unsigned int iobase; /* IO-port base address */
159 ulong plxbase; /* PLX memory base */ 151 unsigned long plxbase; /* PLX memory base */
160 ulong membase; /* DPRAM memory base */ 152 unsigned long membase; /* DPRAM memory base */
161 ulong memend; /* DPRAM memory end */ 153 unsigned long memend; /* DPRAM memory end */
162 void *dpram; /* mapped dpram */ 154 void *dpram; /* mapped dpram */
163 int state; /* actual state of card -> CARD_STATE_** */ 155 int state; /* actual state of card -> CARD_STATE_** */
164 struct HYSDN_CARD *next; /* pointer to next card */ 156 struct HYSDN_CARD *next; /* pointer to next card */
@@ -168,26 +160,26 @@ typedef struct HYSDN_CARD {
168 void *procconf; /* pointer to procconf filesystem specific data */ 160 void *procconf; /* pointer to procconf filesystem specific data */
169 161
170 /* debugging and logging */ 162 /* debugging and logging */
171 uchar err_log_state; /* actual error log state of the card */ 163 unsigned char err_log_state;/* actual error log state of the card */
172 ulong debug_flags; /* tells what should be debugged and where */ 164 unsigned long debug_flags;/* tells what should be debugged and where */
173 void (*set_errlog_state) (struct HYSDN_CARD *, int); 165 void (*set_errlog_state) (struct HYSDN_CARD *, int);
174 166
175 /* interrupt handler + interrupt synchronisation */ 167 /* interrupt handler + interrupt synchronisation */
176 struct work_struct irq_queue; /* interrupt task queue */ 168 struct work_struct irq_queue; /* interrupt task queue */
177 uchar volatile irq_enabled; /* interrupt enabled if != 0 */ 169 unsigned char volatile irq_enabled;/* interrupt enabled if != 0 */
178 uchar volatile hw_lock; /* hardware is currently locked -> no access */ 170 unsigned char volatile hw_lock;/* hardware is currently locked -> no access */
179 171
180 /* boot process */ 172 /* boot process */
181 void *boot; /* pointer to boot private data */ 173 void *boot; /* pointer to boot private data */
182 int (*writebootimg) (struct HYSDN_CARD *, uchar *, ulong); 174 int (*writebootimg) (struct HYSDN_CARD *, unsigned char *, unsigned long);
183 int (*writebootseq) (struct HYSDN_CARD *, uchar *, int); 175 int (*writebootseq) (struct HYSDN_CARD *, unsigned char *, int);
184 int (*waitpofready) (struct HYSDN_CARD *); 176 int (*waitpofready) (struct HYSDN_CARD *);
185 int (*testram) (struct HYSDN_CARD *); 177 int (*testram) (struct HYSDN_CARD *);
186 178
187 /* scheduler for data transfer (only async parts) */ 179 /* scheduler for data transfer (only async parts) */
188 uchar async_data[256]; /* async data to be sent (normally for config) */ 180 unsigned char async_data[256];/* async data to be sent (normally for config) */
189 word volatile async_len; /* length of data to sent */ 181 unsigned short volatile async_len;/* length of data to sent */
190 word volatile async_channel; /* channel number for async transfer */ 182 unsigned short volatile async_channel;/* channel number for async transfer */
191 int volatile async_busy; /* flag != 0 sending in progress */ 183 int volatile async_busy; /* flag != 0 sending in progress */
192 int volatile net_tx_busy; /* a network packet tx is in progress */ 184 int volatile net_tx_busy; /* a network packet tx is in progress */
193 185
@@ -251,15 +243,18 @@ extern int ergo_inithardware(hysdn_card * card); /* get hardware -> module init
251 243
252/* hysdn_boot.c */ 244/* hysdn_boot.c */
253extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */ 245extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */
254extern int pof_write_open(hysdn_card *, uchar **); /* open proc file for writing pof */ 246extern int pof_write_open(hysdn_card *, unsigned char **); /* open proc file for writing pof */
255extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */ 247extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */
256extern int EvalSysrTokData(hysdn_card *, uchar *, int); /* Check Sysready Token Data */ 248extern int EvalSysrTokData(hysdn_card *, unsigned char *, int); /* Check Sysready Token Data */
257 249
258/* hysdn_sched.c */ 250/* hysdn_sched.c */
259extern int hysdn_sched_tx(hysdn_card *, uchar *, word volatile *, word volatile *, 251extern int hysdn_sched_tx(hysdn_card *, unsigned char *,
260 word); 252 unsigned short volatile *, unsigned short volatile *,
261extern int hysdn_sched_rx(hysdn_card *, uchar *, word, word); 253 unsigned short);
262extern int hysdn_tx_cfgline(hysdn_card *, uchar *, word); /* send one cfg line */ 254extern int hysdn_sched_rx(hysdn_card *, unsigned char *, unsigned short,
255 unsigned short);
256extern int hysdn_tx_cfgline(hysdn_card *, unsigned char *,
257 unsigned short); /* send one cfg line */
263 258
264/* hysdn_net.c */ 259/* hysdn_net.c */
265extern unsigned int hynet_enable; 260extern unsigned int hynet_enable;
@@ -269,14 +264,16 @@ extern int hysdn_net_release(hysdn_card *); /* delete the device */
269extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */ 264extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */
270extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */ 265extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */
271extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */ 266extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */
272extern void hysdn_rx_netpkt(hysdn_card *, uchar *, word); /* rxed packet from network */ 267extern void hysdn_rx_netpkt(hysdn_card *, unsigned char *,
268 unsigned short); /* rxed packet from network */
273 269
274#ifdef CONFIG_HYSDN_CAPI 270#ifdef CONFIG_HYSDN_CAPI
275extern unsigned int hycapi_enable; 271extern unsigned int hycapi_enable;
276extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */ 272extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */
277extern int hycapi_capi_release(hysdn_card *); /* delete the device */ 273extern int hycapi_capi_release(hysdn_card *); /* delete the device */
278extern int hycapi_capi_stop(hysdn_card *card); /* suspend */ 274extern int hycapi_capi_stop(hysdn_card *card); /* suspend */
279extern void hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len); 275extern void hycapi_rx_capipkt(hysdn_card * card, unsigned char * buf,
276 unsigned short len);
280extern void hycapi_tx_capiack(hysdn_card * card); 277extern void hycapi_tx_capiack(hysdn_card * card);
281extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card); 278extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card);
282extern int hycapi_init(void); 279extern int hycapi_init(void);
diff --git a/drivers/isdn/hysdn/hysdn_init.c b/drivers/isdn/hysdn/hysdn_init.c
index cb791f8e793a..b75ac5af236a 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 */
41/* the last entry contains all 0 */ 41/* the last entry contains all 0 */
42/**********************************************/ 42/**********************************************/
43static struct { 43static struct {
44 word subid; /* PCI sub id */ 44 unsigned short subid; /* PCI sub id */
45 uchar cardtyp; /* card type assigned */ 45 unsigned char cardtyp; /* card type assigned */
46} pci_subid_map[] = { 46} pci_subid_map[] = {
47 47
48 { 48 {
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c
index aa01628d74c6..d205249a1242 100644
--- a/drivers/isdn/hysdn/hysdn_net.c
+++ b/drivers/isdn/hysdn/hysdn_net.c
@@ -24,7 +24,7 @@
24#include "hysdn_defs.h" 24#include "hysdn_defs.h"
25 25
26unsigned int hynet_enable = 0xffffffff; 26unsigned int hynet_enable = 0xffffffff;
27MODULE_PARM(hynet_enable, "i"); 27module_param(hynet_enable, uint, 0);
28 28
29/* store the actual version for log reporting */ 29/* store the actual version for log reporting */
30char *hysdn_net_revision = "$Revision: 1.8.6.4 $"; 30char *hysdn_net_revision = "$Revision: 1.8.6.4 $";
@@ -83,12 +83,12 @@ net_open(struct net_device *dev)
83 83
84 /* Fill in the MAC-level header (if not already set) */ 84 /* Fill in the MAC-level header (if not already set) */
85 if (!card->mac_addr[0]) { 85 if (!card->mac_addr[0]) {
86 for (i = 0; i < ETH_ALEN - sizeof(ulong); i++) 86 for (i = 0; i < ETH_ALEN - sizeof(unsigned long); i++)
87 dev->dev_addr[i] = 0xfc; 87 dev->dev_addr[i] = 0xfc;
88 if ((in_dev = dev->ip_ptr) != NULL) { 88 if ((in_dev = dev->ip_ptr) != NULL) {
89 struct in_ifaddr *ifa = in_dev->ifa_list; 89 struct in_ifaddr *ifa = in_dev->ifa_list;
90 if (ifa != NULL) 90 if (ifa != NULL)
91 memcpy(dev->dev_addr + (ETH_ALEN - sizeof(ulong)), &ifa->ifa_local, sizeof(ulong)); 91 memcpy(dev->dev_addr + (ETH_ALEN - sizeof(unsigned long)), &ifa->ifa_local, sizeof(unsigned long));
92 } 92 }
93 } else 93 } else
94 memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN); 94 memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN);
@@ -197,7 +197,7 @@ hysdn_tx_netack(hysdn_card * card)
197/* we got a packet from the network, go and queue it */ 197/* we got a packet from the network, go and queue it */
198/*****************************************************/ 198/*****************************************************/
199void 199void
200hysdn_rx_netpkt(hysdn_card * card, uchar * buf, word len) 200hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len)
201{ 201{
202 struct net_local *lp = card->netif; 202 struct net_local *lp = card->netif;
203 struct sk_buff *skb; 203 struct sk_buff *skb;
diff --git a/drivers/isdn/hysdn/hysdn_pof.h b/drivers/isdn/hysdn/hysdn_pof.h
index 6cd81b9b08bc..a368d6caca0e 100644
--- a/drivers/isdn/hysdn/hysdn_pof.h
+++ b/drivers/isdn/hysdn/hysdn_pof.h
@@ -47,20 +47,20 @@
47 47
48/*--------------------------------------POF file record structs------------*/ 48/*--------------------------------------POF file record structs------------*/
49typedef struct PofFileHdr_tag { /* Pof file header */ 49typedef struct PofFileHdr_tag { /* Pof file header */
50/*00 */ ulong Magic __attribute__((packed)); 50/*00 */ unsigned long Magic __attribute__((packed));
51/*04 */ ulong N_PofRecs __attribute__((packed)); 51/*04 */ unsigned long N_PofRecs __attribute__((packed));
52/*08 */ 52/*08 */
53} tPofFileHdr; 53} tPofFileHdr;
54 54
55typedef struct PofRecHdr_tag { /* Pof record header */ 55typedef struct PofRecHdr_tag { /* Pof record header */
56/*00 */ word PofRecId __attribute__((packed)); 56/*00 */ unsigned short PofRecId __attribute__((packed));
57/*02 */ ulong PofRecDataLen __attribute__((packed)); 57/*02 */ unsigned long PofRecDataLen __attribute__((packed));
58/*06 */ 58/*06 */
59} tPofRecHdr; 59} tPofRecHdr;
60 60
61typedef struct PofTimeStamp_tag { 61typedef struct PofTimeStamp_tag {
62/*00 */ ulong UnixTime __attribute__((packed)); 62/*00 */ unsigned long UnixTime __attribute__((packed));
63 /*04 */ uchar DateTimeText[0x28] __attribute__((packed)); 63 /*04 */ unsigned char DateTimeText[0x28] __attribute__((packed));
64 /* =40 */ 64 /* =40 */
65/*2C */ 65/*2C */
66} tPofTimeStamp; 66} tPofTimeStamp;
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 40e56143c768..8e2b03889f3c 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -36,9 +36,9 @@ struct conf_writedata {
36 int buf_size; /* actual number of bytes in the buffer */ 36 int buf_size; /* actual number of bytes in the buffer */
37 int needed_size; /* needed size when reading pof */ 37 int needed_size; /* needed size when reading pof */
38 int state; /* actual interface states from above constants */ 38 int state; /* actual interface states from above constants */
39 uchar conf_line[CONF_LINE_LEN]; /* buffered conf line */ 39 unsigned char conf_line[CONF_LINE_LEN]; /* buffered conf line */
40 word channel; /* active channel number */ 40 unsigned short channel; /* active channel number */
41 uchar *pof_buffer; /* buffer when writing pof */ 41 unsigned char *pof_buffer; /* buffer when writing pof */
42}; 42};
43 43
44/***********************************************************************/ 44/***********************************************************************/
@@ -49,7 +49,7 @@ struct conf_writedata {
49static int 49static int
50process_line(struct conf_writedata *cnf) 50process_line(struct conf_writedata *cnf)
51{ 51{
52 uchar *cp = cnf->conf_line; 52 unsigned char *cp = cnf->conf_line;
53 int i; 53 int i;
54 54
55 if (cnf->card->debug_flags & LOG_CNF_LINE) 55 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
92{ 92{
93 struct conf_writedata *cnf; 93 struct conf_writedata *cnf;
94 int i; 94 int i;
95 uchar ch, *cp; 95 unsigned char ch, *cp;
96 96
97 if (!count) 97 if (!count)
98 return (0); /* nothing to handle */ 98 return (0); /* nothing to handle */
@@ -390,7 +390,7 @@ int
390hysdn_procconf_init(void) 390hysdn_procconf_init(void)
391{ 391{
392 hysdn_card *card; 392 hysdn_card *card;
393 uchar conf_name[20]; 393 unsigned char conf_name[20];
394 394
395 hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net); 395 hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
396 if (!hysdn_proc_entry) { 396 if (!hysdn_proc_entry) {
@@ -423,7 +423,7 @@ void
423hysdn_procconf_release(void) 423hysdn_procconf_release(void)
424{ 424{
425 hysdn_card *card; 425 hysdn_card *card;
426 uchar conf_name[20]; 426 unsigned char conf_name[20];
427 427
428 card = card_root; /* start with first card */ 428 card = card_root; /* start with first card */
429 while (card) { 429 while (card) {
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 6c26f1efabd5..c4301e8338ef 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);
28/*************************************************/ 28/*************************************************/
29struct log_data { 29struct log_data {
30 struct log_data *next; 30 struct log_data *next;
31 ulong usage_cnt; /* number of files still to work */ 31 unsigned long usage_cnt;/* number of files still to work */
32 void *proc_ctrl; /* pointer to own control procdata structure */ 32 void *proc_ctrl; /* pointer to own control procdata structure */
33 char log_start[2]; /* log string start (final len aligned by size) */ 33 char log_start[2]; /* log string start (final len aligned by size) */
34}; 34};
@@ -42,7 +42,7 @@ struct procdata {
42 struct log_data *log_head, *log_tail; /* head and tail for queue */ 42 struct log_data *log_head, *log_tail; /* head and tail for queue */
43 int if_used; /* open count for interface */ 43 int if_used; /* open count for interface */
44 int volatile del_lock; /* lock for delete operations */ 44 int volatile del_lock; /* lock for delete operations */
45 uchar logtmp[LOG_MAX_LINELEN]; 45 unsigned char logtmp[LOG_MAX_LINELEN];
46 wait_queue_head_t rd_queue; 46 wait_queue_head_t rd_queue;
47}; 47};
48 48
@@ -153,9 +153,9 @@ put_log_buffer(hysdn_card * card, char *cp)
153static ssize_t 153static ssize_t
154hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off) 154hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
155{ 155{
156 ulong u = 0; 156 unsigned long u = 0;
157 int found = 0; 157 int found = 0;
158 uchar *cp, valbuf[128]; 158 unsigned char *cp, valbuf[128];
159 long base = 10; 159 long base = 10;
160 hysdn_card *card = (hysdn_card *) file->private_data; 160 hysdn_card *card = (hysdn_card *) file->private_data;
161 161
@@ -249,7 +249,7 @@ hysdn_log_open(struct inode *ino, struct file *filep)
249{ 249{
250 hysdn_card *card; 250 hysdn_card *card;
251 struct procdata *pd = NULL; 251 struct procdata *pd = NULL;
252 ulong flags; 252 unsigned long flags;
253 253
254 lock_kernel(); 254 lock_kernel();
255 card = card_root; 255 card = card_root;
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 4fa3b01707cd..133032920ff8 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -30,7 +30,8 @@
30/* to keep the data until later. */ 30/* to keep the data until later. */
31/*****************************************************************************/ 31/*****************************************************************************/
32int 32int
33hysdn_sched_rx(hysdn_card * card, uchar * buf, word len, word chan) 33hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len,
34 unsigned short chan)
34{ 35{
35 36
36 switch (chan) { 37 switch (chan) {
@@ -72,7 +73,9 @@ hysdn_sched_rx(hysdn_card * card, uchar * buf, word len, word chan)
72/* sending. */ 73/* sending. */
73/*****************************************************************************/ 74/*****************************************************************************/
74int 75int
75hysdn_sched_tx(hysdn_card * card, uchar * buf, word volatile *len, word volatile *chan, word maxlen) 76hysdn_sched_tx(hysdn_card *card, unsigned char *buf,
77 unsigned short volatile *len, unsigned short volatile *chan,
78 unsigned short maxlen)
76{ 79{
77 struct sk_buff *skb; 80 struct sk_buff *skb;
78 81
@@ -145,10 +148,10 @@ hysdn_sched_tx(hysdn_card * card, uchar * buf, word volatile *len, word volatile
145/* are to be sent and this happens very seldom. */ 148/* are to be sent and this happens very seldom. */
146/*****************************************************************************/ 149/*****************************************************************************/
147int 150int
148hysdn_tx_cfgline(hysdn_card * card, uchar * line, word chan) 151hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
149{ 152{
150 int cnt = 50; /* timeout intervalls */ 153 int cnt = 50; /* timeout intervalls */
151 ulong flags; 154 unsigned long flags;
152 155
153 if (card->debug_flags & LOG_SCHED_ASYN) 156 if (card->debug_flags & LOG_SCHED_ASYN)
154 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); 157 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 4a115a87c782..7a36694df6d7 100644
--- a/drivers/isdn/hysdn/ince1pc.h
+++ b/drivers/isdn/hysdn/ince1pc.h
@@ -62,7 +62,7 @@
62 * s. RotlCRC algorithm 62 * s. RotlCRC algorithm
63 * 63 *
64 * RotlCRC algorithm: 64 * RotlCRC algorithm:
65 * ucSum= 0 1 uchar 65 * ucSum= 0 1 unsigned char
66 * for all NonEndTokenChunk bytes: 66 * for all NonEndTokenChunk bytes:
67 * ROTL(ucSum,1) rotate left by 1 67 * ROTL(ucSum,1) rotate left by 1
68 * ucSum += Char; add current byte with swap around 68 * ucSum += Char; add current byte with swap around
@@ -85,13 +85,13 @@
85 85
86typedef struct ErrLogEntry_tag { 86typedef struct ErrLogEntry_tag {
87 87
88/*00 */ ulong ulErrType; 88/*00 */ unsigned long ulErrType;
89 89
90/*04 */ ulong ulErrSubtype; 90/*04 */ unsigned long ulErrSubtype;
91 91
92/*08 */ uchar ucTextSize; 92/*08 */ unsigned char ucTextSize;
93 93
94 /*09 */ uchar ucText[ERRLOG_TEXT_SIZE]; 94 /*09 */ unsigned char ucText[ERRLOG_TEXT_SIZE];
95 /* ASCIIZ of len ucTextSize-1 */ 95 /* ASCIIZ of len ucTextSize-1 */
96 96
97/*40 */ 97/*40 */
@@ -111,13 +111,13 @@ typedef struct ErrLogEntry_tag {
111#define DPRAM_SPOOLER_DATA_SIZE 0x20 111#define DPRAM_SPOOLER_DATA_SIZE 0x20
112typedef struct DpramBootSpooler_tag { 112typedef struct DpramBootSpooler_tag {
113 113
114/*00 */ uchar Len; 114/*00 */ unsigned char Len;
115 115
116/*01 */ volatile uchar RdPtr; 116/*01 */ volatile unsigned char RdPtr;
117 117
118/*02 */ uchar WrPtr; 118/*02 */ unsigned char WrPtr;
119 119
120/*03 */ uchar Data[DPRAM_SPOOLER_DATA_SIZE]; 120/*03 */ unsigned char Data[DPRAM_SPOOLER_DATA_SIZE];
121 121
122/*23 */ 122/*23 */
123} tDpramBootSpooler; 123} tDpramBootSpooler;
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 1a19a0f89428..b9fed8a3bcc6 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)
782 is->first = b; 782 is->first = b;
783 783
784 spin_unlock_irqrestore(&is->buflock, flags); 784 spin_unlock_irqrestore(&is->buflock, flags);
785 copy_to_user(buf, save_buf, count); 785 if (copy_to_user(buf, save_buf, count))
786 count = -EFAULT;
786 kfree(save_buf); 787 kfree(save_buf);
787 788
788 return count; 789 return count;
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index aeaa1db74bd8..3585fb1f3344 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)
2345 u_long flags; 2345 u_long flags;
2346 struct sk_buff *skb = NULL; 2346 struct sk_buff *skb = NULL;
2347 char *sp = NULL; 2347 char *sp = NULL;
2348 int l = strlen(msg); 2348 int l;
2349 2349
2350 if (!msg) { 2350 if (!msg) {
2351 printk(KERN_WARNING "isdn_tty: Null-Message in isdn_tty_at_cout\n"); 2351 printk(KERN_WARNING "isdn_tty: Null-Message in isdn_tty_at_cout\n");
2352 return; 2352 return;
2353 } 2353 }
2354
2355 l = strlen(msg);
2356
2354 spin_lock_irqsave(&info->readlock, flags); 2357 spin_lock_irqsave(&info->readlock, flags);
2355 tty = info->tty; 2358 tty = info->tty;
2356 if ((info->flags & ISDN_ASYNC_CLOSING) || (!tty)) { 2359 if ((info->flags & ISDN_ASYNC_CLOSING) || (!tty)) {
diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
index edf14a2aa3c8..743ac4077f35 100644
--- a/drivers/isdn/i4l/isdn_x25iface.c
+++ b/drivers/isdn/i4l/isdn_x25iface.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * stuff needed to support the Linux X.25 PLP code on top of devices that 8 * stuff needed to support the Linux X.25 PLP code on top of devices that
9 * can provide a lab_b service using the concap_proto mechanism. 9 * can provide a lab_b service using the concap_proto mechanism.
10 * This module supports a network interface wich provides lapb_sematics 10 * This module supports a network interface which provides lapb_sematics
11 * -- as defined in Documentation/networking/x25-iface.txt -- to 11 * -- as defined in Documentation/networking/x25-iface.txt -- to
12 * the upper layer and assumes that the lower layer provides a reliable 12 * the upper layer and assumes that the lower layer provides a reliable
13 * data link service by means of the concap_device_ops callbacks. 13 * 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 33d339700411..a67d31af797a 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -22,7 +22,7 @@ static char *isdnloop_id = "loop0";
22MODULE_DESCRIPTION("ISDN4Linux: Pseudo Driver that simulates an ISDN card"); 22MODULE_DESCRIPTION("ISDN4Linux: Pseudo Driver that simulates an ISDN card");
23MODULE_AUTHOR("Fritz Elfert"); 23MODULE_AUTHOR("Fritz Elfert");
24MODULE_LICENSE("GPL"); 24MODULE_LICENSE("GPL");
25MODULE_PARM(isdnloop_id, "s"); 25module_param(isdnloop_id, charp, 0);
26MODULE_PARM_DESC(isdnloop_id, "ID-String of first card"); 26MODULE_PARM_DESC(isdnloop_id, "ID-String of first card");
27 27
28static int isdnloop_addcard(char *); 28static int isdnloop_addcard(char *);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index eae4473eadde..e1c18aa1d712 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,
556 unsigned long flags; 556 unsigned long flags;
557 557
558 spin_lock_irqsave(&bitmap->lock, flags); 558 spin_lock_irqsave(&bitmap->lock, flags);
559 if (!bitmap || !bitmap->sb_page) { /* can't set the state */ 559 if (!bitmap->sb_page) { /* can't set the state */
560 spin_unlock_irqrestore(&bitmap->lock, flags); 560 spin_unlock_irqrestore(&bitmap->lock, flags);
561 return; 561 return;
562 } 562 }
@@ -1309,7 +1309,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
1309 case 1: 1309 case 1:
1310 *bmc = 2; 1310 *bmc = 2;
1311 } 1311 }
1312 if ((*bmc & COUNTER_MAX) == COUNTER_MAX) BUG(); 1312 BUG_ON((*bmc & COUNTER_MAX) == COUNTER_MAX);
1313 (*bmc)++; 1313 (*bmc)++;
1314 1314
1315 spin_unlock_irq(&bitmap->lock); 1315 spin_unlock_irq(&bitmap->lock);
diff --git a/drivers/md/dm-hw-handler.c b/drivers/md/dm-hw-handler.c
index 4cc0010e0156..baafaaba4d4b 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)
83 if (--hwhi->use == 0) 83 if (--hwhi->use == 0)
84 module_put(hwhi->hwht.module); 84 module_put(hwhi->hwht.module);
85 85
86 if (hwhi->use < 0) 86 BUG_ON(hwhi->use < 0);
87 BUG();
88 87
89 out: 88 out:
90 up_read(&_hwh_lock); 89 up_read(&_hwh_lock);
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index c2602b340491..baa9f58beffc 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -50,5 +50,19 @@ config VIDEO_IR
50config VIDEO_TVEEPROM 50config VIDEO_TVEEPROM
51 tristate 51 tristate
52 52
53config USB_DABUSB
54 tristate "DABUSB driver"
55 depends on USB
56 ---help---
57 A Digital Audio Broadcasting (DAB) Receiver for USB and Linux
58 brought to you by the DAB-Team
59 <http://wwwbode.cs.tum.edu/Par/arch/dab/>. This driver can be taken
60 as an example for URB-based bulk, control, and isochronous
61 transactions. URB's are explained in
62 <Documentation/usb/URB.txt>.
63
64 To compile this driver as a module, choose M here: the
65 module will be called dabusb.
66
53endmenu 67endmenu
54 68
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 3870fa948cc0..523ab3851c7b 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)
50/********************************************************************************/ 50/********************************************************************************/
51/* common dma functions */ 51/* common dma functions */
52 52
53void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf) 53void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
54 struct saa7146_buf *buf)
54{ 55{
55 DEB_EE(("dev:%p, buf:%p\n",dev,buf)); 56 DEB_EE(("dev:%p, buf:%p\n",dev,buf));
56 57
57 BUG_ON(in_interrupt()); 58 BUG_ON(in_interrupt());
58 59
59 videobuf_waiton(&buf->vb,0,0); 60 videobuf_waiton(&buf->vb,0,0);
60 videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma); 61 videobuf_dma_unmap(q, &buf->vb.dma);
61 videobuf_dma_free(&buf->vb.dma); 62 videobuf_dma_free(&buf->vb.dma);
62 buf->vb.state = STATE_NEEDS_INIT; 63 buf->vb.state = STATE_NEEDS_INIT;
63} 64}
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index 500bd3f05e16..063608462ebe 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
236 } 236 }
237 237
238 if (buf->vb.size != size) 238 if (buf->vb.size != size)
239 saa7146_dma_free(dev,buf); 239 saa7146_dma_free(dev,q,buf);
240 240
241 if (STATE_NEEDS_INIT == buf->vb.state) { 241 if (STATE_NEEDS_INIT == buf->vb.state) {
242 buf->vb.width = llength; 242 buf->vb.width = llength;
@@ -247,7 +247,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
247 saa7146_pgtable_free(dev->pci, &buf->pt[2]); 247 saa7146_pgtable_free(dev->pci, &buf->pt[2]);
248 saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); 248 saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
249 249
250 err = videobuf_iolock(dev->pci,&buf->vb, NULL); 250 err = videobuf_iolock(q,&buf->vb, NULL);
251 if (err) 251 if (err)
252 goto oops; 252 goto oops;
253 err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen); 253 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
261 261
262 oops: 262 oops:
263 DEB_VBI(("error out.\n")); 263 DEB_VBI(("error out.\n"));
264 saa7146_dma_free(dev,buf); 264 saa7146_dma_free(dev,q,buf);
265 265
266 return err; 266 return err;
267} 267}
@@ -301,7 +301,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
301 struct saa7146_buf *buf = (struct saa7146_buf *)vb; 301 struct saa7146_buf *buf = (struct saa7146_buf *)vb;
302 302
303 DEB_VBI(("vb:%p\n",vb)); 303 DEB_VBI(("vb:%p\n",vb));
304 saa7146_dma_free(dev,buf); 304 saa7146_dma_free(dev,q,buf);
305} 305}
306 306
307static struct videobuf_queue_ops vbi_qops = { 307static struct videobuf_queue_ops vbi_qops = {
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 6b42713d97f4..e7079d1bd537 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,
1275 buf->vb.field != field || 1275 buf->vb.field != field ||
1276 buf->vb.field != fh->video_fmt.field || 1276 buf->vb.field != fh->video_fmt.field ||
1277 buf->fmt != &fh->video_fmt) { 1277 buf->fmt != &fh->video_fmt) {
1278 saa7146_dma_free(dev,buf); 1278 saa7146_dma_free(dev,q,buf);
1279 } 1279 }
1280 1280
1281 if (STATE_NEEDS_INIT == buf->vb.state) { 1281 if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1304,7 +1304,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1304 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); 1304 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
1305 } 1305 }
1306 1306
1307 err = videobuf_iolock(dev->pci,&buf->vb, &vv->ov_fb); 1307 err = videobuf_iolock(q,&buf->vb, &vv->ov_fb);
1308 if (err) 1308 if (err)
1309 goto oops; 1309 goto oops;
1310 err = saa7146_pgtable_build(dev,buf); 1310 err = saa7146_pgtable_build(dev,buf);
@@ -1318,7 +1318,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1318 1318
1319 oops: 1319 oops:
1320 DEB_D(("error out.\n")); 1320 DEB_D(("error out.\n"));
1321 saa7146_dma_free(dev,buf); 1321 saa7146_dma_free(dev,q,buf);
1322 1322
1323 return err; 1323 return err;
1324} 1324}
@@ -1363,7 +1363,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1363 struct saa7146_buf *buf = (struct saa7146_buf *)vb; 1363 struct saa7146_buf *buf = (struct saa7146_buf *)vb;
1364 1364
1365 DEB_CAP(("vbuf:%p\n",vb)); 1365 DEB_CAP(("vbuf:%p\n",vb));
1366 saa7146_dma_free(dev,buf); 1366 saa7146_dma_free(dev,q,buf);
1367} 1367}
1368 1368
1369static struct videobuf_queue_ops video_qops = { 1369static 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 a6c91db40ad6..06ec9fff0ec1 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 [] = {
541 { USB_DEVICE(0x0af7, 0x0101) }, 541 { USB_DEVICE(0x0af7, 0x0101) },
542 { } 542 { }
543}; 543};
544MODULE_DEVICE_TABLE (usb, flexcop_usb_table);
544 545
545/* usb specific object needed to register this driver with the usb subsystem */ 546/* usb specific object needed to register this driver with the usb subsystem */
546static struct usb_driver flexcop_usb_driver = { 547static struct usb_driver flexcop_usb_driver = {
diff --git a/drivers/media/dvb/bt8xx/Makefile b/drivers/media/dvb/bt8xx/Makefile
index d188e4c670b5..9d197efb481d 100644
--- a/drivers/media/dvb/bt8xx/Makefile
+++ b/drivers/media/dvb/bt8xx/Makefile
@@ -1,3 +1,3 @@
1obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o 1obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o
2 2
3EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video -Idrivers/media/dvb/frontends 3EXTRA_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 e14bf43941e3..a14e737ec848 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)
81 return -EAGAIN; 81 return -EAGAIN;
82 82
83 if (num > 2) 83 if (num > 2)
84 warn("more than 2 i2c messages at a time is not handled yet. TODO."); 84 warn("more than two i2c messages at a time is not handled yet. TODO.");
85 85
86 for (i = 0; i < num; i++) { 86 for (i = 0; i < num; i++) {
87 87
88 switch (msg[i].addr) { 88 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
89 case 0x63: 89 switch (msg[i].addr) {
90 cxusb_gpio_tuner(d,0); 90 case 0x63:
91 break; 91 cxusb_gpio_tuner(d,0);
92 default: 92 break;
93 cxusb_gpio_tuner(d,1); 93 default:
94 break; 94 cxusb_gpio_tuner(d,1);
95 } 95 break;
96 }
96 97
97 /* read request */ 98 /* read request */
98 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { 99 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)
108 break; 109 break;
109 110
110 if (ibuf[0] != 0x08) 111 if (ibuf[0] != 0x08)
111 deb_info("i2c read could have been failed\n"); 112 deb_i2c("i2c read may have failed\n");
112 113
113 memcpy(msg[i+1].buf,&ibuf[1],msg[i+1].len); 114 memcpy(msg[i+1].buf,&ibuf[1],msg[i+1].len);
114 115
@@ -122,7 +123,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
122 if (cxusb_ctrl_msg(d,CMD_I2C_WRITE, obuf, 2+msg[i].len, &ibuf,1) < 0) 123 if (cxusb_ctrl_msg(d,CMD_I2C_WRITE, obuf, 2+msg[i].len, &ibuf,1) < 0)
123 break; 124 break;
124 if (ibuf != 0x08) 125 if (ibuf != 0x08)
125 deb_info("i2c write could have been failed\n"); 126 deb_i2c("i2c write may have failed\n");
126 } 127 }
127 } 128 }
128 129
@@ -410,7 +411,6 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const
410 if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) && 411 if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
411 fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) { 412 fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
412 413
413 /* FIXME: are we allowed to change the fw-data ? */
414 fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1; 414 fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1;
415 fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8; 415 fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8;
416 416
diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h
index 087c99427853..c8ef77554b00 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.h
+++ b/drivers/media/dvb/dvb-usb/cxusb.h
@@ -6,6 +6,8 @@
6 6
7extern int dvb_usb_cxusb_debug; 7extern int dvb_usb_cxusb_debug;
8#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) 8#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
9#define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
10 dprintk(dvb_usb_cxusb_debug,0x01,args)
9 11
10/* usb commands - some of it are guesses, don't have a reference yet */ 12/* usb commands - some of it are guesses, don't have a reference yet */
11#define CMD_I2C_WRITE 0x08 13#define CMD_I2C_WRITE 0x08
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index 2f23ceab8d44..603a22e4bfe2 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)
369 fm_matrix = 0x3001; // stereo 369 fm_matrix = 0x3001; // stereo
370 src = 0x0020; 370 src = 0x0020;
371 break; 371 break;
372 case V4L2_TUNER_MODE_LANG1_LANG2:
373 dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1_LANG2\n");
374 fm_matrix = 0x3000; // bilingual
375 src = 0x0020;
376 break;
372 case V4L2_TUNER_MODE_LANG1: 377 case V4L2_TUNER_MODE_LANG1:
373 dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n"); 378 dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n");
374 fm_matrix = 0x3000; // mono 379 fm_matrix = 0x3000; // mono
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c622a4da5663..f31a19890b15 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -16,31 +16,7 @@ config VIDEO_ADV_DEBUG
16 V4L devices. 16 V4L devices.
17 In doubt, say N. 17 In doubt, say N.
18 18
19config VIDEO_BT848 19source "drivers/media/video/bt8xx/Kconfig"
20 tristate "BT848 Video For Linux"
21 depends on VIDEO_DEV && PCI && I2C
22 select I2C_ALGOBIT
23 select FW_LOADER
24 select VIDEO_BTCX
25 select VIDEO_BUF
26 select VIDEO_IR
27 select VIDEO_TUNER
28 select VIDEO_TVEEPROM
29 select VIDEO_MSP3400
30 ---help---
31 Support for BT848 based frame grabber/overlay boards. This includes
32 the Miro, Hauppauge and STB boards. Please read the material in
33 <file:Documentation/video4linux/bttv/> for more information.
34
35 To compile this driver as a module, choose M here: the
36 module will be called bttv.
37
38config VIDEO_BT848_DVB
39 bool "DVB/ATSC Support for bt878 based TV cards"
40 depends on VIDEO_BT848 && DVB_CORE
41 select DVB_BT8XX
42 ---help---
43 This adds support for DVB/ATSC cards based on the BT878 chip.
44 20
45config VIDEO_SAA6588 21config VIDEO_SAA6588
46 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" 22 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards"
@@ -315,8 +291,6 @@ config VIDEO_HEXIUM_GEMINI
315 291
316source "drivers/media/video/cx88/Kconfig" 292source "drivers/media/video/cx88/Kconfig"
317 293
318source "drivers/media/video/em28xx/Kconfig"
319
320config VIDEO_OVCAMCHIP 294config VIDEO_OVCAMCHIP
321 tristate "OmniVision Camera Chip support" 295 tristate "OmniVision Camera Chip support"
322 depends on VIDEO_DEV && I2C 296 depends on VIDEO_DEV && I2C
@@ -391,4 +365,234 @@ config VIDEO_SAA7127
391 To compile this driver as a module, choose M here: the 365 To compile this driver as a module, choose M here: the
392 module will be called saa7127 366 module will be called saa7127
393 367
368#
369# USB Multimedia device configuration
370#
371
372menu "V4L USB devices"
373 depends on USB && VIDEO_DEV
374
375source "drivers/media/video/em28xx/Kconfig"
376
377config USB_VICAM
378 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
379 depends on USB && VIDEO_DEV && EXPERIMENTAL
380 ---help---
381 Say Y here if you have 3com homeconnect camera (vicam).
382
383 This driver uses the Video For Linux API. You must say Y or M to
384 "Video For Linux" (under Multimedia Devices) to use this driver.
385 Information on this API and pointers to "v4l" programs may be found
386 at <file:Documentation/video4linux/API.html>.
387
388 To compile this driver as a module, choose M here: the
389 module will be called vicam.
390
391config USB_DSBR
392 tristate "D-Link USB FM radio support (EXPERIMENTAL)"
393 depends on USB && VIDEO_DEV && EXPERIMENTAL
394 ---help---
395 Say Y here if you want to connect this type of radio to your
396 computer's USB port. Note that the audio is not digital, and
397 you must connect the line out connector to a sound card or a
398 set of speakers.
399
400 This driver uses the Video For Linux API. You must enable
401 (Y or M in config) Video For Linux (under Character Devices)
402 to use this driver. Information on this API and pointers to
403 "v4l" programs may be found at
404 <file:Documentation/video4linux/API.html>.
405
406 To compile this driver as a module, choose M here: the
407 module will be called dsbr100.
408
409config USB_ET61X251
410 tristate "USB ET61X[12]51 PC Camera Controller support"
411 depends on USB && VIDEO_DEV
412 ---help---
413 Say Y here if you want support for cameras based on Etoms ET61X151
414 or ET61X251 PC Camera Controllers.
415
416 See <file:Documentation/usb/et61x251.txt> for more informations.
417
418 This driver uses the Video For Linux API. You must say Y or M to
419 "Video For Linux" to use this driver.
420
421 To compile this driver as a module, choose M here: the
422 module will be called et61x251.
423
424config USB_IBMCAM
425 tristate "USB IBM (Xirlink) C-it Camera support"
426 depends on USB && VIDEO_DEV
427 ---help---
428 Say Y here if you want to connect a IBM "C-It" camera, also known as
429 "Xirlink PC Camera" to your computer's USB port. For more
430 information, read <file:Documentation/usb/ibmcam.txt>.
431
432 This driver uses the Video For Linux API. You must enable
433 (Y or M in config) Video For Linux (under Character Devices)
434 to use this driver. Information on this API and pointers to
435 "v4l" programs may be found at
436 <file:Documentation/video4linux/API.html>.
437
438 To compile this driver as a module, choose M here: the
439 module will be called ibmcam.
440
441 This camera has several configuration options which
442 can be specified when you load the module. Read
443 <file:Documentation/usb/ibmcam.txt> to learn more.
444
445config USB_KONICAWC
446 tristate "USB Konica Webcam support"
447 depends on USB && VIDEO_DEV
448 ---help---
449 Say Y here if you want support for webcams based on a Konica
450 chipset. This is known to work with the Intel YC76 webcam.
451
452 This driver uses the Video For Linux API. You must enable
453 (Y or M in config) Video For Linux (under Character Devices)
454 to use this driver. Information on this API and pointers to
455 "v4l" programs may be found at
456 <file:Documentation/video4linux/API.html>.
457
458 To compile this driver as a module, choose M here: the
459 module will be called konicawc.
460
461config USB_OV511
462 tristate "USB OV511 Camera support"
463 depends on USB && VIDEO_DEV
464 ---help---
465 Say Y here if you want to connect this type of camera to your
466 computer's USB port. See <file:Documentation/usb/ov511.txt> for more
467 information and for a list of supported cameras.
468
469 This driver uses the Video For Linux API. You must say Y or M to
470 "Video For Linux" (under Character Devices) to use this driver.
471 Information on this API and pointers to "v4l" programs may be found
472 at <file:Documentation/video4linux/API.html>.
473
474 To compile this driver as a module, choose M here: the
475 module will be called ov511.
476
477config USB_SE401
478 tristate "USB SE401 Camera support"
479 depends on USB && VIDEO_DEV
480 ---help---
481 Say Y here if you want to connect this type of camera to your
482 computer's USB port. See <file:Documentation/usb/se401.txt> for more
483 information and for a list of supported cameras.
484
485 This driver uses the Video For Linux API. You must say Y or M to
486 "Video For Linux" (under Multimedia Devices) to use this driver.
487 Information on this API and pointers to "v4l" programs may be found
488 at <file:Documentation/video4linux/API.html>.
489
490 To compile this driver as a module, choose M here: the
491 module will be called se401.
492
493config USB_SN9C102
494 tristate "USB SN9C10x PC Camera Controller support"
495 depends on USB && VIDEO_DEV
496 ---help---
497 Say Y here if you want support for cameras based on SONiX SN9C101,
498 SN9C102 or SN9C103 PC Camera Controllers.
499
500 See <file:Documentation/usb/sn9c102.txt> for more informations.
501
502 This driver uses the Video For Linux API. You must say Y or M to
503 "Video For Linux" to use this driver.
504
505 To compile this driver as a module, choose M here: the
506 module will be called sn9c102.
507
508config USB_STV680
509 tristate "USB STV680 (Pencam) Camera support"
510 depends on USB && VIDEO_DEV
511 ---help---
512 Say Y here if you want to connect this type of camera to your
513 computer's USB port. This includes the Pencam line of cameras.
514 See <file:Documentation/usb/stv680.txt> for more information and for
515 a list of supported cameras.
516
517 This driver uses the Video For Linux API. You must say Y or M to
518 "Video For Linux" (under Multimedia Devices) to use this driver.
519 Information on this API and pointers to "v4l" programs may be found
520 at <file:Documentation/video4linux/API.html>.
521
522 To compile this driver as a module, choose M here: the
523 module will be called stv680.
524
525config USB_W9968CF
526 tristate "USB W996[87]CF JPEG Dual Mode Camera support"
527 depends on USB && VIDEO_DEV && I2C && VIDEO_OVCAMCHIP
528 ---help---
529 Say Y here if you want support for cameras based on OV681 or
530 Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips.
531
532 This driver has an optional plugin, which is distributed as a
533 separate module only (released under GPL). It allows to use higher
534 resolutions and framerates, but cannot be included in the official
535 Linux kernel for performance purposes.
536
537 See <file:Documentation/usb/w9968cf.txt> for more informations.
538
539 This driver uses the Video For Linux and the I2C APIs. It needs the
540 OmniVision Camera Chip support as well. You must say Y or M to
541 "Video For Linux", "I2C Support" and "OmniVision Camera Chip
542 support" to use this driver.
543
544 To compile this driver as a module, choose M here: the
545 module will be called w9968cf.
546
547config USB_ZC0301
548 tristate "USB ZC0301 Image Processor and Control Chip support"
549 depends on USB && VIDEO_DEV
550 ---help---
551 Say Y here if you want support for cameras based on the ZC0301
552 Image Processor and Control Chip.
553
554 See <file:Documentation/usb/zc0301.txt> for more informations.
555
556 This driver uses the Video For Linux API. You must say Y or M to
557 "Video For Linux" to use this driver.
558
559 To compile this driver as a module, choose M here: the
560 module will be called zc0301.
561
562config USB_PWC
563 tristate "USB Philips Cameras"
564 depends on USB && VIDEO_DEV
565 ---help---
566 Say Y or M here if you want to use one of these Philips & OEM
567 webcams:
568 * Philips PCA645, PCA646
569 * Philips PCVC675, PCVC680, PCVC690
570 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
571 * Askey VC010
572 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
573 and 'Orbit'/'Sphere'
574 * Samsung MPC-C10, MPC-C30
575 * Creative Webcam 5, Pro Ex
576 * SOTEC Afina Eye
577 * Visionite VCS-UC300, VCS-UM100
578
579 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
580 and never will be, but the 665 and 720/20 are supported by other
581 drivers.
582
583 See <file:Documentation/usb/philips.txt> for more information and
584 installation instructions.
585
586 The built-in microphone is enabled by selecting USB Audio support.
587
588 This driver uses the Video For Linux API. You must say Y or M to
589 "Video For Linux" (under Character Devices) to use this driver.
590 Information on this API and pointers to "v4l" programs may be found
591 at <file:Documentation/video4linux/API.html>.
592
593 To compile this driver as a module, choose M here: the
594 module will be called pwc.
595
596endmenu # V4L USB devices
597
394endmenu 598endmenu
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index f2bd4c0c4f10..1c0e72e5a593 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -2,9 +2,6 @@
2# Makefile for the video capture/playback device drivers. 2# Makefile for the video capture/playback device drivers.
3# 3#
4 4
5bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
6 bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \
7 bttv-input.o
8zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o 5zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o
9zr36067-objs := zoran_procfs.o zoran_device.o \ 6zr36067-objs := zoran_procfs.o zoran_device.o \
10 zoran_driver.o zoran_card.o 7 zoran_driver.o zoran_card.o
@@ -15,8 +12,8 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
15 12
16obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o 13obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o
17 14
18obj-$(CONFIG_VIDEO_BT848) += bttv.o tvaudio.o \ 15obj-$(CONFIG_VIDEO_BT848) += bt8xx/
19 tda7432.o tda9875.o ir-kbd-i2c.o 16obj-$(CONFIG_VIDEO_BT848) += tvaudio.o tda7432.o tda9875.o ir-kbd-i2c.o
20obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o 17obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
21 18
22obj-$(CONFIG_VIDEO_ZR36120) += zoran.o 19obj-$(CONFIG_VIDEO_ZR36120) += zoran.o
@@ -68,4 +65,23 @@ obj-$(CONFIG_VIDEO_CX25840) += cx25840/
68obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o 65obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
69obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o 66obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
70 67
68et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
69zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
70
71obj-$(CONFIG_USB_DABUSB) += dabusb.o
72obj-$(CONFIG_USB_DSBR) += dsbr100.o
73obj-$(CONFIG_USB_OV511) += ov511.o
74obj-$(CONFIG_USB_SE401) += se401.o
75obj-$(CONFIG_USB_STV680) += stv680.o
76obj-$(CONFIG_USB_W9968CF) += w9968cf.o
77
78obj-$(CONFIG_USB_SN9C102) += sn9c102/
79obj-$(CONFIG_USB_ET61X251) += et61x251/
80obj-$(CONFIG_USB_PWC) += pwc/
81obj-$(CONFIG_USB_ZC0301) += zc0301/
82
83obj-$(CONFIG_USB_IBMCAM) += usbvideo/
84obj-$(CONFIG_USB_KONICAWC) += usbvideo/
85obj-$(CONFIG_USB_VICAM) += usbvideo/
86
71EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 87EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 671e36db224d..48709582a186 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * adv7170 - adv7170, adv7171 video encoder driver version 0.0.1 2 * adv7170 - adv7170, adv7171 video encoder driver version 0.0.1
3 * 3 *
4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com> 4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
5 * 5 *
6 * Based on adv7176 driver by: 6 * Based on adv7176 driver by:
7 * 7 *
8 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 8 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
9 * Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net> 9 * Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net>
@@ -173,7 +173,7 @@ adv7170_write_block (struct i2c_client *client,
173static const unsigned char init_NTSC[] = { 173static const unsigned char init_NTSC[] = {
174 0x00, 0x10, // MR0 174 0x00, 0x10, // MR0
175 0x01, 0x20, // MR1 175 0x01, 0x20, // MR1
176 0x02, 0x0e, // MR2 RTC control: bits 2 and 1 176 0x02, 0x0e, // MR2 RTC control: bits 2 and 1
177 0x03, 0x80, // MR3 177 0x03, 0x80, // MR3
178 0x04, 0x30, // MR4 178 0x04, 0x30, // MR4
179 0x05, 0x00, // Reserved 179 0x05, 0x00, // Reserved
@@ -196,7 +196,7 @@ static const unsigned char init_NTSC[] = {
196 0x16, 0x00, // CGMS_WSS_0 196 0x16, 0x00, // CGMS_WSS_0
197 0x17, 0x00, // CGMS_WSS_1 197 0x17, 0x00, // CGMS_WSS_1
198 0x18, 0x00, // CGMS_WSS_2 198 0x18, 0x00, // CGMS_WSS_2
199 0x19, 0x00, // Teletext Ctl 199 0x19, 0x00, // Teletext Ctl
200}; 200};
201 201
202static const unsigned char init_PAL[] = { 202static const unsigned char init_PAL[] = {
@@ -381,7 +381,7 @@ static unsigned short normal_i2c[] =
381}; 381};
382 382
383static unsigned short ignore = I2C_CLIENT_END; 383static unsigned short ignore = I2C_CLIENT_END;
384 384
385static struct i2c_client_address_data addr_data = { 385static struct i2c_client_address_data addr_data = {
386 .normal_i2c = normal_i2c, 386 .normal_i2c = normal_i2c,
387 .probe = &ignore, 387 .probe = &ignore,
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 085e8863cacb..68e7d7aff5e6 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * adv7175 - adv7175a video encoder driver version 0.0.3 2 * adv7175 - adv7175a video encoder driver version 0.0.3
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -233,7 +233,7 @@ adv7175_command (struct i2c_client *client,
233 sizeof(init_common)); 233 sizeof(init_common));
234 adv7175_write(client, 0x07, TR0MODE | TR0RST); 234 adv7175_write(client, 0x07, TR0MODE | TR0RST);
235 adv7175_write(client, 0x07, TR0MODE); 235 adv7175_write(client, 0x07, TR0MODE);
236 break; 236 break;
237 237
238 case ENCODER_GET_CAPABILITIES: 238 case ENCODER_GET_CAPABILITIES:
239 { 239 {
@@ -399,7 +399,7 @@ static unsigned short normal_i2c[] =
399}; 399};
400 400
401static unsigned short ignore = I2C_CLIENT_END; 401static unsigned short ignore = I2C_CLIENT_END;
402 402
403static struct i2c_client_address_data addr_data = { 403static struct i2c_client_address_data addr_data = {
404 .normal_i2c = normal_i2c, 404 .normal_i2c = normal_i2c,
405 .probe = &ignore, 405 .probe = &ignore,
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index c586f64b6b7f..dbe025170599 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,
161{ 161{
162 int i; 162 int i;
163 163
164 /* Slave Address */ 164 /* Slave Address */
165 ar_outl(addr, PLDI2CDATA); 165 ar_outl(addr, PLDI2CDATA);
166 wait_for_vsync(); 166 wait_for_vsync();
167 167
168 /* Start */ 168 /* Start */
169 ar_outl(1, PLDI2CCND); 169 ar_outl(1, PLDI2CCND);
170 wait_acknowledge(); 170 wait_acknowledge();
171 171
172 /* Transfer data 1 */ 172 /* Transfer data 1 */
173 ar_outl(data1, PLDI2CDATA); 173 ar_outl(data1, PLDI2CDATA);
174 wait_for_vsync(); 174 wait_for_vsync();
175 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); 175 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
176 wait_acknowledge(); 176 wait_acknowledge();
177 177
178 /* Transfer data 2 */ 178 /* Transfer data 2 */
179 ar_outl(data2, PLDI2CDATA); 179 ar_outl(data2, PLDI2CDATA);
180 wait_for_vsync(); 180 wait_for_vsync();
181 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); 181 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
182 wait_acknowledge(); 182 wait_acknowledge();
183 183
184 if (n == 3) { 184 if (n == 3) {
185 /* Transfer data 3 */ 185 /* Transfer data 3 */
186 ar_outl(data3, PLDI2CDATA); 186 ar_outl(data3, PLDI2CDATA);
187 wait_for_vsync(); 187 wait_for_vsync();
188 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN); 188 ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
189 wait_acknowledge(); 189 wait_acknowledge();
190 } 190 }
191 191
192 /* Stop */ 192 /* Stop */
193 for (i = 0; i < 100; i++) 193 for (i = 0; i < 100; i++)
194 cpu_relax(); 194 cpu_relax();
195 ar_outl(2, PLDI2CCND); 195 ar_outl(2, PLDI2CCND);
196 ar_outl(2, PLDI2CCND); 196 ar_outl(2, PLDI2CCND);
197 197
198 while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB) 198 while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB)
199 cpu_relax(); 199 cpu_relax();
@@ -204,24 +204,24 @@ void init_iic(void)
204{ 204{
205 DEBUG(1, "init_iic:\n"); 205 DEBUG(1, "init_iic:\n");
206 206
207 /* 207 /*
208 * ICU Setting (iic) 208 * ICU Setting (iic)
209 */ 209 */
210 /* I2C Setting */ 210 /* I2C Setting */
211 ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */ 211 ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */
212 ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */ 212 ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */
213 ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */ 213 ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */
214 214
215 /* I2C CLK */ 215 /* I2C CLK */
216 /* 50MH-100k */ 216 /* 50MH-100k */
217 if (freq == 75) { 217 if (freq == 75) {
218 ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */ 218 ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */
219 } else if (freq == 50) { 219 } else if (freq == 50) {
220 ar_outl(244, PLDI2CFREQ); /* BCLK = 50MHz */ 220 ar_outl(244, PLDI2CFREQ); /* BCLK = 50MHz */
221 } else { 221 } else {
222 ar_outl(244, PLDI2CFREQ); /* default: BCLK = 50MHz */ 222 ar_outl(244, PLDI2CFREQ); /* default: BCLK = 50MHz */
223 } 223 }
224 ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */ 224 ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */
225} 225}
226 226
227/************************************************************************** 227/**************************************************************************
@@ -253,7 +253,7 @@ static inline void wait_for_vertical_sync(int exp_line)
253 253
254 /* 254 /*
255 * check HCOUNT because we cannot check vertical sync. 255 * check HCOUNT because we cannot check vertical sync.
256 */ 256 */
257 for (; tmout >= 0; tmout--) { 257 for (; tmout >= 0; tmout--) {
258 l = ar_inl(ARVHCOUNT); 258 l = ar_inl(ARVHCOUNT);
259 if (l == exp_line) 259 if (l == exp_line)
@@ -562,8 +562,8 @@ static void ar_interrupt(int irq, void *dev, struct pt_regs *regs)
562 /* operations for interlace mode */ 562 /* operations for interlace mode */
563 if ( line_count < (AR_HEIGHT_VGA/2) ) /* even line */ 563 if ( line_count < (AR_HEIGHT_VGA/2) ) /* even line */
564 line_number = (line_count << 1); 564 line_number = (line_count << 1);
565 else /* odd line */ 565 else /* odd line */
566 line_number = 566 line_number =
567 (((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1); 567 (((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1);
568 } else { 568 } else {
569 line_number = line_count; 569 line_number = line_count;
@@ -651,7 +651,7 @@ static int ar_initialize(struct video_device *dev)
651 cr |= ARVCR1_NORMAL; 651 cr |= ARVCR1_NORMAL;
652 ar_outl(cr, ARVCR1); 652 ar_outl(cr, ARVCR1);
653 653
654 /* 654 /*
655 * Initialize IIC so that CPU can communicate with AR LSI, 655 * Initialize IIC so that CPU can communicate with AR LSI,
656 * and send boot commands to AR LSI. 656 * and send boot commands to AR LSI.
657 */ 657 */
@@ -846,7 +846,7 @@ static int __init ar_init(void)
846 * so register video device as a frame grabber type. 846 * so register video device as a frame grabber type.
847 * device is named "video[0-64]". 847 * device is named "video[0-64]".
848 * video_register_device() initializes h/w using ar_initialize(). 848 * video_register_device() initializes h/w using ar_initialize().
849 */ 849 */
850 if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) { 850 if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) {
851 /* return -1, -ENFILE(full) or others */ 851 /* return -1, -ENFILE(full) or others */
852 printk("arv: register video (Colour AR) failed.\n"); 852 printk("arv: register video (Colour AR) failed.\n");
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index d8a18a6a5bee..e7b38fdd5e3c 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * bt819 - BT819A VideoStream Decoder (Rockwell Part) 2 * bt819 - BT819A VideoStream Decoder (Rockwell Part)
3 * 3 *
4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org> 4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -6,7 +6,7 @@
6 * 6 *
7 * Modifications for LML33/DC10plus unified driver 7 * Modifications for LML33/DC10plus unified driver
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net> 10 * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
11 * - moved over to linux>=2.4.x i2c protocol (9/9/2002) 11 * - moved over to linux>=2.4.x i2c protocol (9/9/2002)
12 * 12 *
@@ -206,9 +206,9 @@ bt819_init (struct i2c_client *client)
206 Bug in the bt819 stepping on my board? 206 Bug in the bt819 stepping on my board?
207 */ 207 */
208 0x14, 0x00, /* 0x14 Vertial Scaling lsb */ 208 0x14, 0x00, /* 0x14 Vertial Scaling lsb */
209 0x16, 0x07, /* 0x16 Video Timing Polarity 209 0x16, 0x07, /* 0x16 Video Timing Polarity
210 ACTIVE=active low 210 ACTIVE=active low
211 FIELD: high=odd, 211 FIELD: high=odd,
212 vreset=active high, 212 vreset=active high,
213 hreset=active high */ 213 hreset=active high */
214 0x18, 0x68, /* 0x18 AGC Delay */ 214 0x18, 0x68, /* 0x18 AGC Delay */
@@ -497,7 +497,7 @@ static unsigned short normal_i2c[] = {
497}; 497};
498 498
499static unsigned short ignore = I2C_CLIENT_END; 499static unsigned short ignore = I2C_CLIENT_END;
500 500
501static struct i2c_client_address_data addr_data = { 501static struct i2c_client_address_data addr_data = {
502 .normal_i2c = normal_i2c, 502 .normal_i2c = normal_i2c,
503 .probe = &ignore, 503 .probe = &ignore,
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 4d47a0a0e974..af3b61d4fa7d 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * bt856 - BT856A Digital Video Encoder (Rockwell Part) 2 * bt856 - BT856A Digital Video Encoder (Rockwell Part)
3 * 3 *
4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org> 4 * Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -285,7 +285,7 @@ bt856_command (struct i2c_client *client,
285static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; 285static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END };
286 286
287static unsigned short ignore = I2C_CLIENT_END; 287static unsigned short ignore = I2C_CLIENT_END;
288 288
289static struct i2c_client_address_data addr_data = { 289static struct i2c_client_address_data addr_data = {
290 .normal_i2c = normal_i2c, 290 .normal_i2c = normal_i2c,
291 .probe = &ignore, 291 .probe = &ignore,
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
new file mode 100644
index 000000000000..085477c12612
--- /dev/null
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -0,0 +1,25 @@
1config VIDEO_BT848
2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C
4 select I2C_ALGOBIT
5 select FW_LOADER
6 select VIDEO_BTCX
7 select VIDEO_BUF
8 select VIDEO_IR
9 select VIDEO_TUNER
10 select VIDEO_TVEEPROM
11 select VIDEO_MSP3400
12 ---help---
13 Support for BT848 based frame grabber/overlay boards. This includes
14 the Miro, Hauppauge and STB boards. Please read the material in
15 <file:Documentation/video4linux/bttv/> for more information.
16
17 To compile this driver as a module, choose M here: the
18 module will be called bttv.
19
20config VIDEO_BT848_DVB
21 bool "DVB/ATSC Support for bt878 based TV cards"
22 depends on VIDEO_BT848 && DVB_CORE
23 select DVB_BT8XX
24 ---help---
25 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 000000000000..94350f21cdc0
--- /dev/null
+++ b/drivers/media/video/bt8xx/Makefile
@@ -0,0 +1,12 @@
1#
2# Makefile for the video capture/playback device drivers.
3#
4
5bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
6 bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \
7 bttv-input.o
8
9obj-$(CONFIG_VIDEO_BT848) += bttv.o
10
11EXTRA_CFLAGS += -I$(src)/..
12EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt8xx/bt832.c
index cc54b62f4601..a51876137880 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt8xx/bt832.c
@@ -30,7 +30,6 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <media/audiochip.h>
34#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
35 34
36#include "bttv.h" 35#include "bttv.h"
@@ -39,7 +38,7 @@
39MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
40 39
41/* Addresses to scan */ 40/* Addresses to scan */
42static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1, 41static unsigned short normal_i2c[] = { I2C_ADDR_BT832_ALT1>>1, I2C_ADDR_BT832_ALT2>>1,
43 I2C_CLIENT_END }; 42 I2C_CLIENT_END };
44I2C_CLIENT_INSMOD; 43I2C_CLIENT_INSMOD;
45 44
diff --git a/drivers/media/video/bt832.h b/drivers/media/video/bt8xx/bt832.h
index 1ce8fa71f7db..1ce8fa71f7db 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 0bcd95303bb0..0bcd95303bb0 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 abfa6ad857a0..f209a7492051 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -39,6 +39,7 @@
39 39
40#include "bttvp.h" 40#include "bttvp.h"
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/tvaudio.h>
42 43
43/* fwd decl */ 44/* fwd decl */
44static void boot_msp34xx(struct bttv *btv, int pin); 45static void boot_msp34xx(struct bttv *btv, int pin);
@@ -336,7 +337,8 @@ struct tvcard bttv_tvcards[] = {
336 .svhs = 2, 337 .svhs = 2,
337 .gpiomask = 15, 338 .gpiomask = 15,
338 .muxsel = { 2, 3, 1, 1 }, 339 .muxsel = { 2, 3, 1, 1 },
339 .audiomux = { 2, 0, 0, 0, 10 }, 340 .gpiomux = { 2, 0, 0, 0 },
341 .gpiomute = 10,
340 .needs_tvaudio = 1, 342 .needs_tvaudio = 1,
341 .tuner_type = -1, 343 .tuner_type = -1,
342 .tuner_addr = ADDR_UNSET, 344 .tuner_addr = ADDR_UNSET,
@@ -350,7 +352,8 @@ struct tvcard bttv_tvcards[] = {
350 .svhs = 2, 352 .svhs = 2,
351 .gpiomask = 7, 353 .gpiomask = 7,
352 .muxsel = { 2, 3, 1, 1 }, 354 .muxsel = { 2, 3, 1, 1 },
353 .audiomux = { 0, 1, 2, 3, 4 }, 355 .gpiomux = { 0, 1, 2, 3 },
356 .gpiomute = 4,
354 .needs_tvaudio = 1, 357 .needs_tvaudio = 1,
355 .tuner_type = -1, 358 .tuner_type = -1,
356 .tuner_addr = ADDR_UNSET, 359 .tuner_addr = ADDR_UNSET,
@@ -364,7 +367,8 @@ struct tvcard bttv_tvcards[] = {
364 .svhs = 2, 367 .svhs = 2,
365 .gpiomask = 7, 368 .gpiomask = 7,
366 .muxsel = { 2, 3, 1, 1 }, 369 .muxsel = { 2, 3, 1, 1 },
367 .audiomux = { 4, 0, 2, 3, 1 }, 370 .gpiomux = { 4, 0, 2, 3 },
371 .gpiomute = 1,
368 .no_msp34xx = 1, 372 .no_msp34xx = 1,
369 .needs_tvaudio = 1, 373 .needs_tvaudio = 1,
370 .tuner_type = TUNER_PHILIPS_NTSC, 374 .tuner_type = TUNER_PHILIPS_NTSC,
@@ -383,7 +387,7 @@ struct tvcard bttv_tvcards[] = {
383 .svhs = 2, 387 .svhs = 2,
384 .gpiomask = 0, 388 .gpiomask = 0,
385 .muxsel = { 2, 3, 1, 1 }, 389 .muxsel = { 2, 3, 1, 1 },
386 .audiomux = { 0 }, 390 .gpiomux = { 0 },
387 .needs_tvaudio = 0, 391 .needs_tvaudio = 0,
388 .tuner_type = 4, 392 .tuner_type = 4,
389 .tuner_addr = ADDR_UNSET, 393 .tuner_addr = ADDR_UNSET,
@@ -397,7 +401,8 @@ struct tvcard bttv_tvcards[] = {
397 .svhs = 2, 401 .svhs = 2,
398 .gpiomask = 3, 402 .gpiomask = 3,
399 .muxsel = { 2, 3, 1, 0 }, 403 .muxsel = { 2, 3, 1, 0 },
400 .audiomux = { 0, 1, 0, 1, 3 }, 404 .gpiomux = { 0, 1, 0, 1 },
405 .gpiomute = 3,
401 .needs_tvaudio = 1, 406 .needs_tvaudio = 1,
402 .tuner_type = -1, 407 .tuner_type = -1,
403 .tuner_addr = ADDR_UNSET, 408 .tuner_addr = ADDR_UNSET,
@@ -411,7 +416,7 @@ struct tvcard bttv_tvcards[] = {
411 .svhs = 3, 416 .svhs = 3,
412 .muxsel = { 2, 3, 1, 1 }, 417 .muxsel = { 2, 3, 1, 1 },
413 .gpiomask = 0x0f, 418 .gpiomask = 0x0f,
414 .audiomux = { 0x0c, 0x04, 0x08, 0x04, 0 }, 419 .gpiomux = { 0x0c, 0x04, 0x08, 0x04 },
415 /* 0x04 for some cards ?? */ 420 /* 0x04 for some cards ?? */
416 .needs_tvaudio = 1, 421 .needs_tvaudio = 1,
417 .tuner_type = -1, 422 .tuner_type = -1,
@@ -428,7 +433,7 @@ struct tvcard bttv_tvcards[] = {
428 .svhs = 3, 433 .svhs = 3,
429 .gpiomask = 0, 434 .gpiomask = 0,
430 .muxsel = { 2, 3, 1, 0, 0 }, 435 .muxsel = { 2, 3, 1, 0, 0 },
431 .audiomux = { 0 }, 436 .gpiomux = { 0 },
432 .needs_tvaudio = 1, 437 .needs_tvaudio = 1,
433 .tuner_type = -1, 438 .tuner_type = -1,
434 .tuner_addr = ADDR_UNSET, 439 .tuner_addr = ADDR_UNSET,
@@ -444,7 +449,8 @@ struct tvcard bttv_tvcards[] = {
444 .svhs = 2, 449 .svhs = 2,
445 .gpiomask = 0xc00, 450 .gpiomask = 0xc00,
446 .muxsel = { 2, 3, 1, 1 }, 451 .muxsel = { 2, 3, 1, 1 },
447 .audiomux = { 0, 0xc00, 0x800, 0x400, 0xc00, 0 }, 452 .gpiomux = { 0, 0xc00, 0x800, 0x400 },
453 .gpiomute = 0xc00,
448 .needs_tvaudio = 1, 454 .needs_tvaudio = 1,
449 .pll = PLL_28, 455 .pll = PLL_28,
450 .tuner_type = -1, 456 .tuner_type = -1,
@@ -459,7 +465,7 @@ struct tvcard bttv_tvcards[] = {
459 .svhs = 2, 465 .svhs = 2,
460 .gpiomask = 3, 466 .gpiomask = 3,
461 .muxsel = { 2, 3, 1, 1 }, 467 .muxsel = { 2, 3, 1, 1 },
462 .audiomux = { 1, 1, 2, 3, 0 }, 468 .gpiomux = { 1, 1, 2, 3 },
463 .needs_tvaudio = 0, 469 .needs_tvaudio = 0,
464 .pll = PLL_28, 470 .pll = PLL_28,
465 .tuner_type = TUNER_TEMIC_PAL, 471 .tuner_type = TUNER_TEMIC_PAL,
@@ -474,7 +480,8 @@ struct tvcard bttv_tvcards[] = {
474 .svhs = 2, 480 .svhs = 2,
475 .gpiomask = 0x0f, /* old: 7 */ 481 .gpiomask = 0x0f, /* old: 7 */
476 .muxsel = { 2, 0, 1, 1 }, 482 .muxsel = { 2, 0, 1, 1 },
477 .audiomux = { 0, 1, 2, 3, 4 }, 483 .gpiomux = { 0, 1, 2, 3 },
484 .gpiomute = 4,
478 .needs_tvaudio = 1, 485 .needs_tvaudio = 1,
479 .pll = PLL_28, 486 .pll = PLL_28,
480 .tuner_type = -1, 487 .tuner_type = -1,
@@ -489,7 +496,8 @@ struct tvcard bttv_tvcards[] = {
489 .svhs = 2, 496 .svhs = 2,
490 .gpiomask = 0x3014f, 497 .gpiomask = 0x3014f,
491 .muxsel = { 2, 3, 1, 1 }, 498 .muxsel = { 2, 3, 1, 1 },
492 .audiomux = { 0x20001,0x10001, 0, 0,10 }, 499 .gpiomux = { 0x20001,0x10001, 0, 0 },
500 .gpiomute = 10,
493 .needs_tvaudio = 1, 501 .needs_tvaudio = 1,
494 .tuner_type = -1, 502 .tuner_type = -1,
495 .tuner_addr = ADDR_UNSET, 503 .tuner_addr = ADDR_UNSET,
@@ -505,7 +513,7 @@ struct tvcard bttv_tvcards[] = {
505 .svhs = 2, 513 .svhs = 2,
506 .gpiomask = 15, 514 .gpiomask = 15,
507 .muxsel = { 2, 3, 1, 1 }, 515 .muxsel = { 2, 3, 1, 1 },
508 .audiomux = { 13, 14, 11, 7, 0, 0 }, 516 .gpiomux = { 13, 14, 11, 7 },
509 .needs_tvaudio = 1, 517 .needs_tvaudio = 1,
510 .tuner_type = -1, 518 .tuner_type = -1,
511 .tuner_addr = ADDR_UNSET, 519 .tuner_addr = ADDR_UNSET,
@@ -519,7 +527,7 @@ struct tvcard bttv_tvcards[] = {
519 .svhs = 2, 527 .svhs = 2,
520 .gpiomask = 15, 528 .gpiomask = 15,
521 .muxsel = { 2, 3, 1, 1 }, 529 .muxsel = { 2, 3, 1, 1 },
522 .audiomux = { 13, 14, 11, 7, 0, 0 }, 530 .gpiomux = { 13, 14, 11, 7 },
523 .needs_tvaudio = 1, 531 .needs_tvaudio = 1,
524 .msp34xx_alt = 1, 532 .msp34xx_alt = 1,
525 .pll = PLL_28, 533 .pll = PLL_28,
@@ -537,7 +545,8 @@ struct tvcard bttv_tvcards[] = {
537 .svhs = 2, 545 .svhs = 2,
538 .gpiomask = 7, 546 .gpiomask = 7,
539 .muxsel = { 2, 3, 1, 1 }, 547 .muxsel = { 2, 3, 1, 1 },
540 .audiomux = { 0, 2, 1, 3, 4 }, /* old: {0, 1, 2, 3, 4} */ 548 .gpiomux = { 0, 2, 1, 3 }, /* old: {0, 1, 2, 3, 4} */
549 .gpiomute = 4,
541 .needs_tvaudio = 1, 550 .needs_tvaudio = 1,
542 .pll = PLL_28, 551 .pll = PLL_28,
543 .tuner_type = -1, 552 .tuner_type = -1,
@@ -552,7 +561,8 @@ struct tvcard bttv_tvcards[] = {
552 .svhs = 2, 561 .svhs = 2,
553 .gpiomask = 15, 562 .gpiomask = 15,
554 .muxsel = { 2, 3, 1, 1 }, 563 .muxsel = { 2, 3, 1, 1 },
555 .audiomux = { 0 , 0, 1 , 0, 10 }, 564 .gpiomux = { 0, 0, 1, 0 },
565 .gpiomute = 10,
556 .needs_tvaudio = 1, 566 .needs_tvaudio = 1,
557 .tuner_type = -1, 567 .tuner_type = -1,
558 .tuner_addr = ADDR_UNSET, 568 .tuner_addr = ADDR_UNSET,
@@ -570,10 +580,11 @@ struct tvcard bttv_tvcards[] = {
570 .muxsel = { 2, 3, 1, 1 }, 580 .muxsel = { 2, 3, 1, 1 },
571 #if 0 581 #if 0
572 /* old */ 582 /* old */
573 .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 }, 583 .gpiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000 },
574 #else 584 #else
575 /* 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> */ 585 /* 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> */
576 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, 586 .gpiomux = { 0x001e00, 0, 0x018000, 0x014000 },
587 .gpiomute = 0x002000,
577 #endif 588 #endif
578 .needs_tvaudio = 1, 589 .needs_tvaudio = 1,
579 .pll = PLL_28, 590 .pll = PLL_28,
@@ -587,7 +598,8 @@ struct tvcard bttv_tvcards[] = {
587 .svhs = 2, 598 .svhs = 2,
588 .gpiomask = 0x8300f8, 599 .gpiomask = 0x8300f8,
589 .muxsel = { 2, 3, 1, 1,0 }, 600 .muxsel = { 2, 3, 1, 1,0 },
590 .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007 }, 601 .gpiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007 },
602 .gpiomute = 0xcfa007,
591 .needs_tvaudio = 1, 603 .needs_tvaudio = 1,
592 .tuner_type = -1, 604 .tuner_type = -1,
593 .tuner_addr = ADDR_UNSET, 605 .tuner_addr = ADDR_UNSET,
@@ -603,7 +615,7 @@ struct tvcard bttv_tvcards[] = {
603 .svhs = 2, 615 .svhs = 2,
604 .gpiomask = 0, 616 .gpiomask = 0,
605 .muxsel = { 2, 3, 1, 1 }, 617 .muxsel = { 2, 3, 1, 1 },
606 .audiomux = { 1, 0, 0, 0, 0 }, 618 .gpiomux = { 1, 0, 0, 0 },
607 .needs_tvaudio = 1, 619 .needs_tvaudio = 1,
608 .tuner_type = -1, 620 .tuner_type = -1,
609 .tuner_addr = ADDR_UNSET, 621 .tuner_addr = ADDR_UNSET,
@@ -617,7 +629,7 @@ struct tvcard bttv_tvcards[] = {
617 .svhs = -1, 629 .svhs = -1,
618 .gpiomask = 0x8dff00, 630 .gpiomask = 0x8dff00,
619 .muxsel = { 2, 3, 1, 1 }, 631 .muxsel = { 2, 3, 1, 1 },
620 .audiomux = { 0 }, 632 .gpiomux = { 0 },
621 .no_msp34xx = 1, 633 .no_msp34xx = 1,
622 .tuner_type = -1, 634 .tuner_type = -1,
623 .tuner_addr = ADDR_UNSET, 635 .tuner_addr = ADDR_UNSET,
@@ -644,7 +656,8 @@ struct tvcard bttv_tvcards[] = {
644 .svhs = 2, 656 .svhs = 2,
645 .gpiomask = 0x1800, 657 .gpiomask = 0x1800,
646 .muxsel = { 2, 3, 1, 1 }, 658 .muxsel = { 2, 3, 1, 1 },
647 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 }, 659 .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
660 .gpiomute = 0x1800,
648 .pll = PLL_28, 661 .pll = PLL_28,
649 .tuner_type = TUNER_PHILIPS_PAL_I, 662 .tuner_type = TUNER_PHILIPS_PAL_I,
650 .tuner_addr = ADDR_UNSET, 663 .tuner_addr = ADDR_UNSET,
@@ -658,7 +671,8 @@ struct tvcard bttv_tvcards[] = {
658 .svhs = 2, 671 .svhs = 2,
659 .gpiomask = 0xc00, 672 .gpiomask = 0xc00,
660 .muxsel = { 2, 3, 1, 1 }, 673 .muxsel = { 2, 3, 1, 1 },
661 .audiomux = { 0, 1, 0x800, 0x400, 0xc00, 0 }, 674 .gpiomux = { 0, 1, 0x800, 0x400 },
675 .gpiomute = 0xc00,
662 .needs_tvaudio = 1, 676 .needs_tvaudio = 1,
663 .pll = PLL_28, 677 .pll = PLL_28,
664 .tuner_type = -1, 678 .tuner_type = -1,
@@ -674,7 +688,7 @@ struct tvcard bttv_tvcards[] = {
674 .gpiomask = 7, 688 .gpiomask = 7,
675 .muxsel = { 2, 3, -1 }, 689 .muxsel = { 2, 3, -1 },
676 .digital_mode = DIGITAL_MODE_CAMERA, 690 .digital_mode = DIGITAL_MODE_CAMERA,
677 .audiomux = { 0, 0, 0, 0, 0 }, 691 .gpiomux = { 0, 0, 0, 0 },
678 .no_msp34xx = 1, 692 .no_msp34xx = 1,
679 .pll = PLL_28, 693 .pll = PLL_28,
680 .tuner_type = TUNER_ALPS_TSBB5_PAL_I, 694 .tuner_type = TUNER_ALPS_TSBB5_PAL_I,
@@ -691,7 +705,8 @@ struct tvcard bttv_tvcards[] = {
691 .svhs = 2, 705 .svhs = 2,
692 .gpiomask = 0xe00, 706 .gpiomask = 0xe00,
693 .muxsel = { 2, 3, 1, 1 }, 707 .muxsel = { 2, 3, 1, 1 },
694 .audiomux = {0x400, 0x400, 0x400, 0x400, 0xc00 }, 708 .gpiomux = {0x400, 0x400, 0x400, 0x400 },
709 .gpiomute = 0xc00,
695 .needs_tvaudio = 1, 710 .needs_tvaudio = 1,
696 .pll = PLL_28, 711 .pll = PLL_28,
697 .tuner_type = -1, 712 .tuner_type = -1,
@@ -707,7 +722,8 @@ struct tvcard bttv_tvcards[] = {
707 .svhs = 2, 722 .svhs = 2,
708 .gpiomask = 0x1f0fff, 723 .gpiomask = 0x1f0fff,
709 .muxsel = { 2, 3, 1, 1 }, 724 .muxsel = { 2, 3, 1, 1 },
710 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000 }, 725 .gpiomux = { 0x20000, 0x30000, 0x10000, 0 },
726 .gpiomute = 0x40000,
711 .needs_tvaudio = 0, 727 .needs_tvaudio = 0,
712 .tuner_type = TUNER_PHILIPS_PAL, 728 .tuner_type = TUNER_PHILIPS_PAL,
713 .tuner_addr = ADDR_UNSET, 729 .tuner_addr = ADDR_UNSET,
@@ -722,7 +738,8 @@ struct tvcard bttv_tvcards[] = {
722 .svhs = 3, 738 .svhs = 3,
723 .gpiomask = 7, 739 .gpiomask = 7,
724 .muxsel = { 2, 0, 1, 1 }, 740 .muxsel = { 2, 0, 1, 1 },
725 .audiomux = { 0, 1, 2, 3, 4 }, 741 .gpiomux = { 0, 1, 2, 3 },
742 .gpiomute = 4,
726 .needs_tvaudio = 1, 743 .needs_tvaudio = 1,
727 .tuner_type = -1, 744 .tuner_type = -1,
728 .tuner_addr = ADDR_UNSET, 745 .tuner_addr = ADDR_UNSET,
@@ -736,7 +753,8 @@ struct tvcard bttv_tvcards[] = {
736 .svhs = 2, 753 .svhs = 2,
737 .gpiomask = 0x1800, 754 .gpiomask = 0x1800,
738 .muxsel = { 2, 3, 1, 1 }, 755 .muxsel = { 2, 3, 1, 1 },
739 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 }, 756 .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
757 .gpiomute = 0x1800,
740 .pll = PLL_28, 758 .pll = PLL_28,
741 .tuner_type = TUNER_PHILIPS_SECAM, 759 .tuner_type = TUNER_PHILIPS_SECAM,
742 .tuner_addr = ADDR_UNSET, 760 .tuner_addr = ADDR_UNSET,
@@ -752,7 +770,8 @@ struct tvcard bttv_tvcards[] = {
752 .svhs = 2, 770 .svhs = 2,
753 .gpiomask = 0x1f0fff, 771 .gpiomask = 0x1f0fff,
754 .muxsel = { 2, 3, 1, 1 }, 772 .muxsel = { 2, 3, 1, 1 },
755 .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000 }, 773 .gpiomux = { 0x20000, 0x30000, 0x10000, 0x00000 },
774 .gpiomute = 0x40000,
756 .needs_tvaudio = 0, 775 .needs_tvaudio = 0,
757 .tuner_type = TUNER_PHILIPS_PAL, 776 .tuner_type = TUNER_PHILIPS_PAL,
758 .tuner_addr = ADDR_UNSET, 777 .tuner_addr = ADDR_UNSET,
@@ -799,7 +818,7 @@ struct tvcard bttv_tvcards[] = {
799 .svhs = 1, /* was: 4 */ 818 .svhs = 1, /* was: 4 */
800 .gpiomask = 0, 819 .gpiomask = 0,
801 .muxsel = { 2, 3, 1, 0, 0}, 820 .muxsel = { 2, 3, 1, 0, 0},
802 .audiomux = { 0 }, 821 .gpiomux = { 0 },
803 .needs_tvaudio = 1, 822 .needs_tvaudio = 1,
804 .tuner_type = -1, 823 .tuner_type = -1,
805 .tuner_addr = ADDR_UNSET, 824 .tuner_addr = ADDR_UNSET,
@@ -815,7 +834,8 @@ struct tvcard bttv_tvcards[] = {
815 .svhs = 2, 834 .svhs = 2,
816 .gpiomask = 0x1800, /* 0x8dfe00 */ 835 .gpiomask = 0x1800, /* 0x8dfe00 */
817 .muxsel = { 2, 3, 1, 1 }, 836 .muxsel = { 2, 3, 1, 1 },
818 .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 }, 837 .gpiomux = { 0, 0x0800, 0x1000, 0x1000 },
838 .gpiomute = 0x1800,
819 .pll = PLL_28, 839 .pll = PLL_28,
820 .tuner_type = -1, 840 .tuner_type = -1,
821 .tuner_addr = ADDR_UNSET, 841 .tuner_addr = ADDR_UNSET,
@@ -829,7 +849,7 @@ struct tvcard bttv_tvcards[] = {
829 .svhs = 3, 849 .svhs = 3,
830 .gpiomask = 1, 850 .gpiomask = 1,
831 .muxsel = { 2, 3, 1, 1 }, 851 .muxsel = { 2, 3, 1, 1 },
832 .audiomux = { 1, 0, 0, 0, 0 }, 852 .gpiomux = { 1, 0, 0, 0 },
833 .pll = PLL_28, 853 .pll = PLL_28,
834 .tuner_type = TUNER_PHILIPS_PAL, 854 .tuner_type = TUNER_PHILIPS_PAL,
835 .tuner_addr = ADDR_UNSET, 855 .tuner_addr = ADDR_UNSET,
@@ -845,7 +865,7 @@ struct tvcard bttv_tvcards[] = {
845 .svhs = 2, 865 .svhs = 2,
846 .gpiomask = 0, 866 .gpiomask = 0,
847 .muxsel = { 2, 3, 1, 1 }, 867 .muxsel = { 2, 3, 1, 1 },
848 .audiomux = { 0 }, 868 .gpiomux = { 0 },
849 .needs_tvaudio = 0, 869 .needs_tvaudio = 0,
850 .tuner_type = 4, 870 .tuner_type = 4,
851 .tuner_addr = ADDR_UNSET, 871 .tuner_addr = ADDR_UNSET,
@@ -859,7 +879,8 @@ struct tvcard bttv_tvcards[] = {
859 .svhs = 2, 879 .svhs = 2,
860 .gpiomask = 0xffff00, 880 .gpiomask = 0xffff00,
861 .muxsel = { 2, 3, 1, 1 }, 881 .muxsel = { 2, 3, 1, 1 },
862 .audiomux = { 0x500, 0, 0x300, 0x900, 0x900 }, 882 .gpiomux = { 0x500, 0, 0x300, 0x900 },
883 .gpiomute = 0x900,
863 .needs_tvaudio = 1, 884 .needs_tvaudio = 1,
864 .pll = PLL_28, 885 .pll = PLL_28,
865 .tuner_type = TUNER_PHILIPS_PAL, 886 .tuner_type = TUNER_PHILIPS_PAL,
@@ -875,11 +896,12 @@ struct tvcard bttv_tvcards[] = {
875 .muxsel = { 2, 3, 1, 1, 0 }, /* TV, CVid, SVid, CVid over SVid connector */ 896 .muxsel = { 2, 3, 1, 1, 0 }, /* TV, CVid, SVid, CVid over SVid connector */
876 #if 0 897 #if 0
877 .gpiomask = 0xc33000, 898 .gpiomask = 0xc33000,
878 .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 }, 899 .gpiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
879 #else 900 #else
880 /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */ 901 /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */
881 .gpiomask = 0xb33000, 902 .gpiomask = 0xb33000,
882 .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 }, 903 .gpiomux = { 0x122000,0x1000,0x0000,0x620000 },
904 .gpiomute = 0x800000,
883 #endif 905 #endif
884 /* Audio Routing for "WinFast 2000 XP" (no tv stereo !) 906 /* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
885 gpio23 -- hef4052:nEnable (0x800000) 907 gpio23 -- hef4052:nEnable (0x800000)
@@ -909,7 +931,8 @@ struct tvcard bttv_tvcards[] = {
909 .svhs = 2, 931 .svhs = 2,
910 .gpiomask = 0x1800, 932 .gpiomask = 0x1800,
911 .muxsel = { 2, 3, 1, 1 }, 933 .muxsel = { 2, 3, 1, 1 },
912 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 }, 934 .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
935 .gpiomute = 0x1800,
913 .pll = PLL_28, 936 .pll = PLL_28,
914 .tuner_type = -1, 937 .tuner_type = -1,
915 .tuner_addr = ADDR_UNSET, 938 .tuner_addr = ADDR_UNSET,
@@ -925,7 +948,8 @@ struct tvcard bttv_tvcards[] = {
925 .svhs = 2, 948 .svhs = 2,
926 .gpiomask = 0x1800, 949 .gpiomask = 0x1800,
927 .muxsel = { 2, 3, 1, 1 }, 950 .muxsel = { 2, 3, 1, 1 },
928 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, 951 .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
952 .gpiomute = 0x1800,
929 .pll = PLL_28, 953 .pll = PLL_28,
930 .tuner_type = -1, 954 .tuner_type = -1,
931 .tuner_addr = ADDR_UNSET, 955 .tuner_addr = ADDR_UNSET,
@@ -940,7 +964,8 @@ struct tvcard bttv_tvcards[] = {
940 .svhs = 2, 964 .svhs = 2,
941 .gpiomask = 0xff, 965 .gpiomask = 0xff,
942 .muxsel = { 2, 3, 1, 1 }, 966 .muxsel = { 2, 3, 1, 1 },
943 .audiomux = { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 }, 967 .gpiomux = { 0x21, 0x20, 0x24, 0x2c },
968 .gpiomute = 0x29,
944 .no_msp34xx = 1, 969 .no_msp34xx = 1,
945 .pll = PLL_28, 970 .pll = PLL_28,
946 .tuner_type = -1, 971 .tuner_type = -1,
@@ -955,7 +980,8 @@ struct tvcard bttv_tvcards[] = {
955 .svhs = 2, 980 .svhs = 2,
956 .gpiomask = 0x551e00, 981 .gpiomask = 0x551e00,
957 .muxsel = { 2, 3, 1, 0 }, 982 .muxsel = { 2, 3, 1, 0 },
958 .audiomux = { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 }, 983 .gpiomux = { 0x551400, 0x551200, 0, 0 },
984 .gpiomute = 0x551c00,
959 .needs_tvaudio = 1, 985 .needs_tvaudio = 1,
960 .pll = PLL_28, 986 .pll = PLL_28,
961 .tuner_type = 1, 987 .tuner_type = 1,
@@ -971,7 +997,8 @@ struct tvcard bttv_tvcards[] = {
971 .svhs = 2, 997 .svhs = 2,
972 .gpiomask = 0x03000F, 998 .gpiomask = 0x03000F,
973 .muxsel = { 2, 3, 1, 1 }, 999 .muxsel = { 2, 3, 1, 1 },
974 .audiomux = { 2, 0xd0001, 0, 0, 1 }, 1000 .gpiomux = { 2, 0xd0001, 0, 0 },
1001 .gpiomute = 1,
975 .needs_tvaudio = 0, 1002 .needs_tvaudio = 0,
976 .pll = PLL_28, 1003 .pll = PLL_28,
977 .tuner_type = -1, 1004 .tuner_type = -1,
@@ -988,7 +1015,8 @@ struct tvcard bttv_tvcards[] = {
988 .svhs = 2, 1015 .svhs = 2,
989 .gpiomask = 7, 1016 .gpiomask = 7,
990 .muxsel = { 2, 3, 1, 1 }, 1017 .muxsel = { 2, 3, 1, 1 },
991 .audiomux = { 4, 0, 2, 3, 1 }, 1018 .gpiomux = { 4, 0, 2, 3 },
1019 .gpiomute = 1,
992 .no_msp34xx = 1, 1020 .no_msp34xx = 1,
993 .needs_tvaudio = 1, 1021 .needs_tvaudio = 1,
994 .tuner_type = TUNER_PHILIPS_NTSC, 1022 .tuner_type = TUNER_PHILIPS_NTSC,
@@ -1005,7 +1033,7 @@ struct tvcard bttv_tvcards[] = {
1005 .svhs = 2, 1033 .svhs = 2,
1006 .gpiomask = 15, 1034 .gpiomask = 15,
1007 .muxsel = { 2, 3, 1, 1 }, 1035 .muxsel = { 2, 3, 1, 1 },
1008 .audiomux = { 13, 4, 11, 7, 0, 0 }, 1036 .gpiomux = { 13, 4, 11, 7 },
1009 .needs_tvaudio = 1, 1037 .needs_tvaudio = 1,
1010 .pll = PLL_28, 1038 .pll = PLL_28,
1011 .tuner_type = -1, 1039 .tuner_type = -1,
@@ -1022,7 +1050,7 @@ struct tvcard bttv_tvcards[] = {
1022 .svhs = 2, 1050 .svhs = 2,
1023 .gpiomask = 0, 1051 .gpiomask = 0,
1024 .muxsel = { 2, 3, 1, 1}, 1052 .muxsel = { 2, 3, 1, 1},
1025 .audiomux = { 0, 0, 0, 0, 0}, 1053 .gpiomux = { 0, 0, 0, 0},
1026 .needs_tvaudio = 1, 1054 .needs_tvaudio = 1,
1027 .no_msp34xx = 1, 1055 .no_msp34xx = 1,
1028 .pll = PLL_28, 1056 .pll = PLL_28,
@@ -1038,7 +1066,8 @@ struct tvcard bttv_tvcards[] = {
1038 .svhs = 2, 1066 .svhs = 2,
1039 .gpiomask = 0xe00b, 1067 .gpiomask = 0xe00b,
1040 .muxsel = { 2, 3, 1, 1 }, 1068 .muxsel = { 2, 3, 1, 1 },
1041 .audiomux = { 0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc }, 1069 .gpiomux = { 0xff9ff6, 0xff9ff6, 0xff1ff7, 0 },
1070 .gpiomute = 0xff3ffc,
1042 .no_msp34xx = 1, 1071 .no_msp34xx = 1,
1043 .tuner_type = -1, 1072 .tuner_type = -1,
1044 .tuner_addr = ADDR_UNSET, 1073 .tuner_addr = ADDR_UNSET,
@@ -1054,7 +1083,8 @@ struct tvcard bttv_tvcards[] = {
1054 .svhs = -1, 1083 .svhs = -1,
1055 .gpiomask = 3, 1084 .gpiomask = 3,
1056 .muxsel = { 2, 3, 1, 1 }, 1085 .muxsel = { 2, 3, 1, 1 },
1057 .audiomux = { 1, 1, 0, 2, 3 }, 1086 .gpiomux = { 1, 1, 0, 2 },
1087 .gpiomute = 3,
1058 .no_msp34xx = 1, 1088 .no_msp34xx = 1,
1059 .pll = PLL_NONE, 1089 .pll = PLL_NONE,
1060 .tuner_type = -1, 1090 .tuner_type = -1,
@@ -1069,7 +1099,7 @@ struct tvcard bttv_tvcards[] = {
1069 .svhs = 3, 1099 .svhs = 3,
1070 .gpiomask = 0, 1100 .gpiomask = 0,
1071 .muxsel = { 2, 3, 1, 0, 0 }, 1101 .muxsel = { 2, 3, 1, 0, 0 },
1072 .audiomux = { 0 }, 1102 .gpiomux = { 0 },
1073 .no_msp34xx = 1, 1103 .no_msp34xx = 1,
1074 .pll = PLL_28, 1104 .pll = PLL_28,
1075 .tuner_type = -1, 1105 .tuner_type = -1,
@@ -1084,7 +1114,8 @@ struct tvcard bttv_tvcards[] = {
1084 .svhs = 2, 1114 .svhs = 2,
1085 .gpiomask = 0xbcf03f, 1115 .gpiomask = 0xbcf03f,
1086 .muxsel = { 2, 3, 1, 1 }, 1116 .muxsel = { 2, 3, 1, 1 },
1087 .audiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f }, 1117 .gpiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0 },
1118 .gpiomute = 0xbcb03f,
1088 .no_msp34xx = 1, 1119 .no_msp34xx = 1,
1089 .pll = PLL_28, 1120 .pll = PLL_28,
1090 .tuner_type = 21, 1121 .tuner_type = 21,
@@ -1099,7 +1130,8 @@ struct tvcard bttv_tvcards[] = {
1099 .svhs = 2, 1130 .svhs = 2,
1100 .gpiomask = 0x70000, 1131 .gpiomask = 0x70000,
1101 .muxsel = { 2, 3, 1, 1 }, 1132 .muxsel = { 2, 3, 1, 1 },
1102 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 }, 1133 .gpiomux = { 0x20000, 0x30000, 0x10000, 0 },
1134 .gpiomute = 0x40000,
1103 .needs_tvaudio = 1, 1135 .needs_tvaudio = 1,
1104 .no_msp34xx = 1, 1136 .no_msp34xx = 1,
1105 .pll = PLL_35, 1137 .pll = PLL_35,
@@ -1118,7 +1150,8 @@ struct tvcard bttv_tvcards[] = {
1118 .svhs = 2, 1150 .svhs = 2,
1119 .gpiomask = 15, 1151 .gpiomask = 15,
1120 .muxsel = { 2, 3, 1, 1 }, 1152 .muxsel = { 2, 3, 1, 1 },
1121 .audiomux = {2,0,0,0,1 }, 1153 .gpiomux = {2,0,0,0 },
1154 .gpiomute = 1,
1122 .needs_tvaudio = 1, 1155 .needs_tvaudio = 1,
1123 .pll = PLL_28, 1156 .pll = PLL_28,
1124 .tuner_type = -1, 1157 .tuner_type = -1,
@@ -1133,7 +1166,7 @@ struct tvcard bttv_tvcards[] = {
1133 .svhs = 2, 1166 .svhs = 2,
1134 .gpiomask = 0x010f00, 1167 .gpiomask = 0x010f00,
1135 .muxsel = {2, 3, 0, 0 }, 1168 .muxsel = {2, 3, 0, 0 },
1136 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0 }, 1169 .gpiomux = {0x10000, 0, 0x10000, 0 },
1137 .no_msp34xx = 1, 1170 .no_msp34xx = 1,
1138 .pll = PLL_28, 1171 .pll = PLL_28,
1139 .tuner_type = TUNER_ALPS_TSHC6_NTSC, 1172 .tuner_type = TUNER_ALPS_TSHC6_NTSC,
@@ -1150,7 +1183,8 @@ struct tvcard bttv_tvcards[] = {
1150 .gpiomask = 0xAA0000, 1183 .gpiomask = 0xAA0000,
1151 .muxsel = { 2,3,1,1,-1 }, 1184 .muxsel = { 2,3,1,1,-1 },
1152 .digital_mode = DIGITAL_MODE_CAMERA, 1185 .digital_mode = DIGITAL_MODE_CAMERA,
1153 .audiomux = { 0x20000, 0, 0x80000, 0x80000, 0xa8000, 0x46000 }, 1186 .gpiomux = { 0x20000, 0, 0x80000, 0x80000 },
1187 .gpiomute = 0xa8000,
1154 .no_msp34xx = 1, 1188 .no_msp34xx = 1,
1155 .pll = PLL_28, 1189 .pll = PLL_28,
1156 .tuner_type = TUNER_PHILIPS_PAL_I, 1190 .tuner_type = TUNER_PHILIPS_PAL_I,
@@ -1175,7 +1209,8 @@ struct tvcard bttv_tvcards[] = {
1175 .svhs = 2, 1209 .svhs = 2,
1176 .gpiomask = 7, 1210 .gpiomask = 7,
1177 .muxsel = { 2, 0, 1, 1 }, 1211 .muxsel = { 2, 0, 1, 1 },
1178 .audiomux = { 0, 1, 2, 3, 4 }, 1212 .gpiomux = { 0, 1, 2, 3 },
1213 .gpiomute = 4,
1179 .pll = PLL_28, 1214 .pll = PLL_28,
1180 .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */, 1215 .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */,
1181 .tuner_addr = ADDR_UNSET, 1216 .tuner_addr = ADDR_UNSET,
@@ -1192,7 +1227,8 @@ struct tvcard bttv_tvcards[] = {
1192 .svhs = 3, 1227 .svhs = 3,
1193 .gpiomask = 0x03000F, 1228 .gpiomask = 0x03000F,
1194 .muxsel = { 2, 3, 1, 1 }, 1229 .muxsel = { 2, 3, 1, 1 },
1195 .audiomux = { 1, 0xd0001, 0, 0, 10 }, 1230 .gpiomux = { 1, 0xd0001, 0, 0 },
1231 .gpiomute = 10,
1196 /* sound path (5 sources): 1232 /* sound path (5 sources):
1197 MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) 1233 MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable)
1198 0= ext. Audio IN 1234 0= ext. Audio IN
@@ -1218,7 +1254,8 @@ struct tvcard bttv_tvcards[] = {
1218 .svhs = 2, 1254 .svhs = 2,
1219 .gpiomask = 0x1c, 1255 .gpiomask = 0x1c,
1220 .muxsel = { 2, 3, 1, 1 }, 1256 .muxsel = { 2, 3, 1, 1 },
1221 .audiomux = { 0, 0, 0x10, 8, 4 }, 1257 .gpiomux = { 0, 0, 0x10, 8 },
1258 .gpiomute = 4,
1222 .needs_tvaudio = 1, 1259 .needs_tvaudio = 1,
1223 .pll = PLL_28, 1260 .pll = PLL_28,
1224 .tuner_type = TUNER_PHILIPS_PAL, 1261 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1230,7 +1267,7 @@ struct tvcard bttv_tvcards[] = {
1230 /* Tim Röstermundt <rosterm@uni-muenster.de> 1267 /* Tim Röstermundt <rosterm@uni-muenster.de>
1231 in de.comp.os.unix.linux.hardware: 1268 in de.comp.os.unix.linux.hardware:
1232 options bttv card=0 pll=1 radio=1 gpiomask=0x18e0 1269 options bttv card=0 pll=1 radio=1 gpiomask=0x18e0
1233 audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff 1270 gpiomux =0x44c71f,0x44d71f,0,0x44d71f,0x44dfff
1234 options tuner type=5 */ 1271 options tuner type=5 */
1235 .name = "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]", 1272 .name = "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]",
1236 .video_inputs = 4, 1273 .video_inputs = 4,
@@ -1239,7 +1276,8 @@ struct tvcard bttv_tvcards[] = {
1239 .svhs = 2, 1276 .svhs = 2,
1240 .gpiomask = 0x18e0, 1277 .gpiomask = 0x18e0,
1241 .muxsel = { 2, 3, 1, 1 }, 1278 .muxsel = { 2, 3, 1, 1 },
1242 .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 }, 1279 .gpiomux = { 0x0000,0x0800,0x1000,0x1000 },
1280 .gpiomute = 0x18e0,
1243 /* For cards with tda9820/tda9821: 1281 /* For cards with tda9820/tda9821:
1244 0x0000: Tuner normal stereo 1282 0x0000: Tuner normal stereo
1245 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) 1283 0x0080: Tuner A2 SAP (second audio program = Zweikanalton)
@@ -1259,7 +1297,8 @@ struct tvcard bttv_tvcards[] = {
1259 .svhs = 2, 1297 .svhs = 2,
1260 .gpiomask = 0xF, 1298 .gpiomask = 0xF,
1261 .muxsel = { 2, 3, 1, 0 }, 1299 .muxsel = { 2, 3, 1, 0 },
1262 .audiomux = { 2, 0, 0, 0, 10 }, 1300 .gpiomux = { 2, 0, 0, 0 },
1301 .gpiomute = 10,
1263 .needs_tvaudio = 0, 1302 .needs_tvaudio = 0,
1264 .pll = PLL_28, 1303 .pll = PLL_28,
1265 .tuner_type = TUNER_TEMIC_PAL, 1304 .tuner_type = TUNER_TEMIC_PAL,
@@ -1277,7 +1316,8 @@ struct tvcard bttv_tvcards[] = {
1277 .svhs = 2, 1316 .svhs = 2,
1278 .gpiomask = 0x1800, 1317 .gpiomask = 0x1800,
1279 .muxsel = { 2, 3, 1, 1 }, 1318 .muxsel = { 2, 3, 1, 1 },
1280 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, 1319 .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
1320 .gpiomute = 0x1800,
1281 .pll = PLL_28, 1321 .pll = PLL_28,
1282 .tuner_type = 5, 1322 .tuner_type = 5,
1283 .tuner_addr = ADDR_UNSET, 1323 .tuner_addr = ADDR_UNSET,
@@ -1294,7 +1334,7 @@ struct tvcard bttv_tvcards[] = {
1294 .svhs = 1, 1334 .svhs = 1,
1295 .gpiomask = 0, 1335 .gpiomask = 0,
1296 .muxsel = { 3, 1 }, 1336 .muxsel = { 3, 1 },
1297 .audiomux = { 0 }, 1337 .gpiomux = { 0 },
1298 .needs_tvaudio = 0, 1338 .needs_tvaudio = 0,
1299 .no_msp34xx = 1, 1339 .no_msp34xx = 1,
1300 .pll = PLL_35, 1340 .pll = PLL_35,
@@ -1311,7 +1351,8 @@ struct tvcard bttv_tvcards[] = {
1311 .svhs = 2, 1351 .svhs = 2,
1312 .gpiomask = 0xe00, 1352 .gpiomask = 0xe00,
1313 .muxsel = { 2, 3, 1, 1}, 1353 .muxsel = { 2, 3, 1, 1},
1314 .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 }, 1354 .gpiomux = { 0x400, 0x400, 0x400, 0x400 },
1355 .gpiomute = 0x800,
1315 .needs_tvaudio = 1, 1356 .needs_tvaudio = 1,
1316 .pll = PLL_28, 1357 .pll = PLL_28,
1317 .tuner_type = TUNER_TEMIC_4036FY5_NTSC, 1358 .tuner_type = TUNER_TEMIC_4036FY5_NTSC,
@@ -1327,7 +1368,8 @@ struct tvcard bttv_tvcards[] = {
1327 .svhs = 2, 1368 .svhs = 2,
1328 .gpiomask = 0x03000F, 1369 .gpiomask = 0x03000F,
1329 .muxsel = { 2, 3, 1, 0 }, 1370 .muxsel = { 2, 3, 1, 0 },
1330 .audiomux = { 2, 0, 0, 0, 1 }, 1371 .gpiomux = { 2, 0, 0, 0 },
1372 .gpiomute = 1,
1331 .pll = PLL_28, 1373 .pll = PLL_28,
1332 .tuner_type = 0, 1374 .tuner_type = 0,
1333 .tuner_addr = ADDR_UNSET, 1375 .tuner_addr = ADDR_UNSET,
@@ -1344,7 +1386,8 @@ struct tvcard bttv_tvcards[] = {
1344 .svhs = -1, 1386 .svhs = -1,
1345 .gpiomask = 11, 1387 .gpiomask = 11,
1346 .muxsel = { 2, 3, 1, 1 }, 1388 .muxsel = { 2, 3, 1, 1 },
1347 .audiomux = { 2, 0, 0, 1, 8 }, 1389 .gpiomux = { 2, 0, 0, 1 },
1390 .gpiomute = 8,
1348 .pll = PLL_35, 1391 .pll = PLL_35,
1349 .tuner_type = TUNER_TEMIC_PAL, 1392 .tuner_type = TUNER_TEMIC_PAL,
1350 .tuner_addr = ADDR_UNSET, 1393 .tuner_addr = ADDR_UNSET,
@@ -1359,7 +1402,7 @@ struct tvcard bttv_tvcards[] = {
1359 .svhs = 1, 1402 .svhs = 1,
1360 .gpiomask = 0xF, 1403 .gpiomask = 0xF,
1361 .muxsel = { 2, 2 }, 1404 .muxsel = { 2, 2 },
1362 .audiomux = { }, 1405 .gpiomux = { },
1363 .no_msp34xx = 1, 1406 .no_msp34xx = 1,
1364 .needs_tvaudio = 0, 1407 .needs_tvaudio = 0,
1365 .pll = PLL_28, 1408 .pll = PLL_28,
@@ -1378,7 +1421,8 @@ struct tvcard bttv_tvcards[] = {
1378 .svhs = 2, 1421 .svhs = 2,
1379 .gpiomask = 0xFF, 1422 .gpiomask = 0xFF,
1380 .muxsel = { 2, 3, 1, 0 }, 1423 .muxsel = { 2, 3, 1, 0 },
1381 .audiomux = { 1, 0, 4, 4, 9 }, 1424 .gpiomux = { 1, 0, 4, 4 },
1425 .gpiomute = 9,
1382 .needs_tvaudio = 0, 1426 .needs_tvaudio = 0,
1383 .pll = PLL_28, 1427 .pll = PLL_28,
1384 .tuner_type = TUNER_PHILIPS_PAL, 1428 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1394,7 +1438,8 @@ struct tvcard bttv_tvcards[] = {
1394 .svhs = 2, 1438 .svhs = 2,
1395 .gpiomask = 0xf03f, 1439 .gpiomask = 0xf03f,
1396 .muxsel = { 2, 3, 1, 0 }, 1440 .muxsel = { 2, 3, 1, 0 },
1397 .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe }, 1441 .gpiomux = { 0xbffe, 0, 0xbfff, 0 },
1442 .gpiomute = 0xbffe,
1398 .pll = PLL_28, 1443 .pll = PLL_28,
1399 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, 1444 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
1400 .tuner_addr = ADDR_UNSET, 1445 .tuner_addr = ADDR_UNSET,
@@ -1411,7 +1456,7 @@ struct tvcard bttv_tvcards[] = {
1411 .svhs = -1, 1456 .svhs = -1,
1412 .gpiomask = 1, 1457 .gpiomask = 1,
1413 .muxsel = { 2, 3, 0, 1 }, 1458 .muxsel = { 2, 3, 0, 1 },
1414 .audiomux = { 0, 0, 1, 0, 0 }, 1459 .gpiomux = { 0, 0, 1, 0 },
1415 .no_msp34xx = 1, 1460 .no_msp34xx = 1,
1416 .pll = PLL_28, 1461 .pll = PLL_28,
1417 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, 1462 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
@@ -1430,7 +1475,8 @@ struct tvcard bttv_tvcards[] = {
1430 /* Radio changed from 1e80 to 0x800 to make 1475 /* Radio changed from 1e80 to 0x800 to make
1431 FlyVideo2000S in .hu happy (gm)*/ 1476 FlyVideo2000S in .hu happy (gm)*/
1432 /* -dk-???: set mute=0x1800 for tda9874h daughterboard */ 1477 /* -dk-???: set mute=0x1800 for tda9874h daughterboard */
1433 .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x1800, 0x1080 }, 1478 .gpiomux = { 0x0000,0x0800,0x1000,0x1000 },
1479 .gpiomute = 0x1800,
1434 .audio_hook = fv2000s_audio, 1480 .audio_hook = fv2000s_audio,
1435 .no_msp34xx = 1, 1481 .no_msp34xx = 1,
1436 .no_tda9875 = 1, 1482 .no_tda9875 = 1,
@@ -1448,7 +1494,8 @@ struct tvcard bttv_tvcards[] = {
1448 .svhs = 2, 1494 .svhs = 2,
1449 .gpiomask = 0xffff00, 1495 .gpiomask = 0xffff00,
1450 .muxsel = { 2, 3, 1, 1 }, 1496 .muxsel = { 2, 3, 1, 1 },
1451 .audiomux = { 0x500, 0x500, 0x300, 0x900, 0x900 }, 1497 .gpiomux = { 0x500, 0x500, 0x300, 0x900 },
1498 .gpiomute = 0x900,
1452 .needs_tvaudio = 1, 1499 .needs_tvaudio = 1,
1453 .pll = PLL_28, 1500 .pll = PLL_28,
1454 .tuner_type = TUNER_PHILIPS_PAL, 1501 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1465,7 +1512,7 @@ struct tvcard bttv_tvcards[] = {
1465 .svhs = 2, 1512 .svhs = 2,
1466 .gpiomask = 0x010f00, 1513 .gpiomask = 0x010f00,
1467 .muxsel = {2, 3, 0, 0 }, 1514 .muxsel = {2, 3, 0, 0 },
1468 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0 }, 1515 .gpiomux = {0x10000, 0, 0x10000, 0 },
1469 .no_msp34xx = 1, 1516 .no_msp34xx = 1,
1470 .pll = PLL_28, 1517 .pll = PLL_28,
1471 .tuner_type = TUNER_SHARP_2U5JF5540_NTSC, 1518 .tuner_type = TUNER_SHARP_2U5JF5540_NTSC,
@@ -1486,7 +1533,8 @@ struct tvcard bttv_tvcards[] = {
1486 .gpiomask = 0x4f8a00, 1533 .gpiomask = 0x4f8a00,
1487 /* 0x100000: 1=MSP enabled (0=disable again) 1534 /* 0x100000: 1=MSP enabled (0=disable again)
1488 * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */ 1535 * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */
1489 .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, 1536 .gpiomux = {0x947fff, 0x987fff,0x947fff,0x947fff },
1537 .gpiomute = 0x947fff,
1490 /* tvtuner, radio, external,internal, mute, stereo 1538 /* tvtuner, radio, external,internal, mute, stereo
1491 * tuner, Composit, SVid, Composit-on-Svid-adapter */ 1539 * tuner, Composit, SVid, Composit-on-Svid-adapter */
1492 .muxsel = { 2, 3 ,0 ,1 }, 1540 .muxsel = { 2, 3 ,0 ,1 },
@@ -1518,7 +1566,8 @@ struct tvcard bttv_tvcards[] = {
1518 .svhs = 2, 1566 .svhs = 2,
1519 .gpiomask = 15, 1567 .gpiomask = 15,
1520 .muxsel = { 2, 3, 1, 1 }, 1568 .muxsel = { 2, 3, 1, 1 },
1521 .audiomux = { 0, 0, 11, 7, 13, 0 }, /* TV and Radio with same GPIO ! */ 1569 .gpiomux = { 0, 0, 11, 7 }, /* TV and Radio with same GPIO ! */
1570 .gpiomute = 13,
1522 .needs_tvaudio = 1, 1571 .needs_tvaudio = 1,
1523 .pll = PLL_28, 1572 .pll = PLL_28,
1524 .tuner_type = 25, 1573 .tuner_type = 25,
@@ -1557,7 +1606,8 @@ struct tvcard bttv_tvcards[] = {
1557 .svhs = 2, 1606 .svhs = 2,
1558 .gpiomask = 0x3f, 1607 .gpiomask = 0x3f,
1559 .muxsel = { 2, 3, 1, 1 }, 1608 .muxsel = { 2, 3, 1, 1 },
1560 .audiomux = { 0x01, 0x00, 0x03, 0x03, 0x09, 0x02 }, 1609 .gpiomux = { 0x01, 0x00, 0x03, 0x03 },
1610 .gpiomute = 0x09,
1561 .needs_tvaudio = 1, 1611 .needs_tvaudio = 1,
1562 .no_msp34xx = 1, 1612 .no_msp34xx = 1,
1563 .no_tda9875 = 1, 1613 .no_tda9875 = 1,
@@ -1586,7 +1636,7 @@ struct tvcard bttv_tvcards[] = {
1586 .svhs = 4, 1636 .svhs = 4,
1587 .gpiomask = 0, 1637 .gpiomask = 0,
1588 .muxsel = { 2, 3, 1, 0, 0 }, 1638 .muxsel = { 2, 3, 1, 0, 0 },
1589 .audiomux = { 0 }, 1639 .gpiomux = { 0 },
1590 .needs_tvaudio = 0, 1640 .needs_tvaudio = 0,
1591 .tuner_type = -1, 1641 .tuner_type = -1,
1592 .tuner_addr = ADDR_UNSET, 1642 .tuner_addr = ADDR_UNSET,
@@ -1618,7 +1668,8 @@ struct tvcard bttv_tvcards[] = {
1618 .svhs = 2, 1668 .svhs = 2,
1619 .gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */ 1669 .gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */
1620 .muxsel = { 2, 1, 1, }, 1670 .muxsel = { 2, 1, 1, },
1621 .audiomux = { 0, 1, 2, 2, 4 }, 1671 .gpiomux = { 0, 1, 2, 2 },
1672 .gpiomute = 4,
1622 .needs_tvaudio = 0, 1673 .needs_tvaudio = 0,
1623 .tuner_type = TUNER_PHILIPS_PAL, 1674 .tuner_type = TUNER_PHILIPS_PAL,
1624 .tuner_addr = ADDR_UNSET, 1675 .tuner_addr = ADDR_UNSET,
@@ -1637,7 +1688,8 @@ struct tvcard bttv_tvcards[] = {
1637 .svhs = 2, 1688 .svhs = 2,
1638 .gpiomask = 0x140007, 1689 .gpiomask = 0x140007,
1639 .muxsel = { 2, 3, 1, 1 }, 1690 .muxsel = { 2, 3, 1, 1 },
1640 .audiomux = { 0, 1, 2, 3, 4, 0 }, 1691 .gpiomux = { 0, 1, 2, 3 },
1692 .gpiomute = 4,
1641 .tuner_type = TUNER_PHILIPS_NTSC, 1693 .tuner_type = TUNER_PHILIPS_NTSC,
1642 .tuner_addr = ADDR_UNSET, 1694 .tuner_addr = ADDR_UNSET,
1643 .radio_addr = ADDR_UNSET, 1695 .radio_addr = ADDR_UNSET,
@@ -1651,7 +1703,7 @@ struct tvcard bttv_tvcards[] = {
1651 .svhs = -1, 1703 .svhs = -1,
1652 .gpiomask = 0, 1704 .gpiomask = 0,
1653 .muxsel = { 2, 3, 1, 0 }, 1705 .muxsel = { 2, 3, 1, 0 },
1654 .audiomux = { 0 }, 1706 .gpiomux = { 0 },
1655 .needs_tvaudio = 0, 1707 .needs_tvaudio = 0,
1656 .no_msp34xx = 1, 1708 .no_msp34xx = 1,
1657 .pll = PLL_28, 1709 .pll = PLL_28,
@@ -1667,13 +1719,14 @@ struct tvcard bttv_tvcards[] = {
1667 .svhs = 2, 1719 .svhs = 2,
1668 .gpiomask = 7, 1720 .gpiomask = 7,
1669 .muxsel = { 2, 3, 1, 1 }, /* Tuner, SVid, SVHS, SVid to SVHS connector */ 1721 .muxsel = { 2, 3, 1, 1 }, /* Tuner, SVid, SVHS, SVid to SVHS connector */
1670 .audiomux = { 0 ,0 ,4, 4,4,4},/* Yes, this tuner uses the same audio output for TV and FM radio! 1722 .gpiomux = { 0, 0, 4, 4 },/* Yes, this tuner uses the same audio output for TV and FM radio!
1671 * This card lacks external Audio In, so we mute it on Ext. & Int. 1723 * This card lacks external Audio In, so we mute it on Ext. & Int.
1672 * The PCB can take a sbx1637/sbx1673, wiring unknown. 1724 * The PCB can take a sbx1637/sbx1673, wiring unknown.
1673 * This card lacks PCI subsystem ID, sigh. 1725 * This card lacks PCI subsystem ID, sigh.
1674 * audiomux=1: lower volume, 2+3: mute 1726 * gpiomux =1: lower volume, 2+3: mute
1675 * btwincap uses 0x80000/0x80003 1727 * btwincap uses 0x80000/0x80003
1676 */ 1728 */
1729 .gpiomute = 4,
1677 .needs_tvaudio = 0, 1730 .needs_tvaudio = 0,
1678 .no_msp34xx = 1, 1731 .no_msp34xx = 1,
1679 .pll = PLL_28, 1732 .pll = PLL_28,
@@ -1720,7 +1773,7 @@ struct tvcard bttv_tvcards[] = {
1720 .radio_addr = ADDR_UNSET, 1773 .radio_addr = ADDR_UNSET,
1721 1774
1722 .gpiomask = 7, 1775 .gpiomask = 7,
1723 .audiomux = {7}, 1776 .gpiomux = {7},
1724 }, 1777 },
1725 [BTTV_BOARD_GVBCTV5PCI] = { 1778 [BTTV_BOARD_GVBCTV5PCI] = {
1726 .name = "IODATA GV-BCTV5/PCI", 1779 .name = "IODATA GV-BCTV5/PCI",
@@ -1730,7 +1783,8 @@ struct tvcard bttv_tvcards[] = {
1730 .svhs = 2, 1783 .svhs = 2,
1731 .gpiomask = 0x0f0f80, 1784 .gpiomask = 0x0f0f80,
1732 .muxsel = {2, 3, 1, 0 }, 1785 .muxsel = {2, 3, 1, 0 },
1733 .audiomux = {0x030000, 0x010000, 0, 0, 0x020000, 0}, 1786 .gpiomux = {0x030000, 0x010000, 0, 0 },
1787 .gpiomute = 0x020000,
1734 .no_msp34xx = 1, 1788 .no_msp34xx = 1,
1735 .pll = PLL_28, 1789 .pll = PLL_28,
1736 .tuner_type = TUNER_PHILIPS_NTSC_M, 1790 .tuner_type = TUNER_PHILIPS_NTSC_M,
@@ -1960,7 +2014,7 @@ struct tvcard bttv_tvcards[] = {
1960 .gpiomask = 2, 2014 .gpiomask = 2,
1961 /* TV, Comp1, Composite over SVID con, SVID */ 2015 /* TV, Comp1, Composite over SVID con, SVID */
1962 .muxsel = { 2, 3, 1, 1 }, 2016 .muxsel = { 2, 3, 1, 1 },
1963 .audiomux = { 2, 2, 0, 0, 0 }, 2017 .gpiomux = { 2, 2, 0, 0 },
1964 .pll = PLL_28, 2018 .pll = PLL_28,
1965 .has_radio = 1, 2019 .has_radio = 1,
1966 .tuner_type = TUNER_PHILIPS_PAL, 2020 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1984,7 +2038,8 @@ struct tvcard bttv_tvcards[] = {
1984 .svhs = -1, 2038 .svhs = -1,
1985 .gpiomask = 7, 2039 .gpiomask = 7,
1986 .muxsel = { 2, 3, 1, 1}, 2040 .muxsel = { 2, 3, 1, 1},
1987 .audiomux = { 0, 1, 2, 3, 4}, 2041 .gpiomux = { 0, 1, 2, 3},
2042 .gpiomute = 4,
1988 .needs_tvaudio = 1, 2043 .needs_tvaudio = 1,
1989 .tuner_type = 5, 2044 .tuner_type = 5,
1990 .tuner_addr = ADDR_UNSET, 2045 .tuner_addr = ADDR_UNSET,
@@ -2016,7 +2071,7 @@ struct tvcard bttv_tvcards[] = {
2016 .svhs = -1, 2071 .svhs = -1,
2017 .gpiomask = 0, 2072 .gpiomask = 0,
2018 .muxsel = { 2, 3 }, 2073 .muxsel = { 2, 3 },
2019 .audiomux = { 0 }, 2074 .gpiomux = { 0 },
2020 .needs_tvaudio = 0, 2075 .needs_tvaudio = 0,
2021 .no_msp34xx = 1, 2076 .no_msp34xx = 1,
2022 .pll = PLL_28, 2077 .pll = PLL_28,
@@ -2035,7 +2090,8 @@ struct tvcard bttv_tvcards[] = {
2035 .gpiomask = 0x001e8007, 2090 .gpiomask = 0x001e8007,
2036 .muxsel = { 2, 3, 1, 0 }, 2091 .muxsel = { 2, 3, 1, 0 },
2037 /* Tuner, Radio, external, internal, off, on */ 2092 /* Tuner, Radio, external, internal, off, on */
2038 .audiomux = { 0x08, 0x0f, 0x0a, 0x08, 0x0f, 0x08 }, 2093 .gpiomux = { 0x08, 0x0f, 0x0a, 0x08 },
2094 .gpiomute = 0x0f,
2039 .needs_tvaudio = 0, 2095 .needs_tvaudio = 0,
2040 .no_msp34xx = 1, 2096 .no_msp34xx = 1,
2041 .pll = PLL_28, 2097 .pll = PLL_28,
@@ -2152,7 +2208,7 @@ struct tvcard bttv_tvcards[] = {
2152 .svhs = -1, 2208 .svhs = -1,
2153 .gpiomask = 0, 2209 .gpiomask = 0,
2154 .muxsel = { 2, 3, 1, 0 }, 2210 .muxsel = { 2, 3, 1, 0 },
2155 .audiomux = { 0 }, 2211 .gpiomux = { 0 },
2156 .needs_tvaudio = 0, 2212 .needs_tvaudio = 0,
2157 .no_msp34xx = 1, 2213 .no_msp34xx = 1,
2158 .pll = PLL_28, 2214 .pll = PLL_28,
@@ -2169,7 +2225,7 @@ struct tvcard bttv_tvcards[] = {
2169 .svhs = 3, 2225 .svhs = 3,
2170 .gpiomask = 0x00, 2226 .gpiomask = 0x00,
2171 .muxsel = { 2, 3, 1, 0 }, 2227 .muxsel = { 2, 3, 1, 0 },
2172 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2228 .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
2173 .needs_tvaudio = 1, 2229 .needs_tvaudio = 1,
2174 .pll = PLL_28, 2230 .pll = PLL_28,
2175 .tuner_type = -1, 2231 .tuner_type = -1,
@@ -2184,7 +2240,7 @@ struct tvcard bttv_tvcards[] = {
2184 .svhs = 3, 2240 .svhs = 3,
2185 .gpiomask = 0x00, 2241 .gpiomask = 0x00,
2186 .muxsel = { 2, 3, 1, 1 }, 2242 .muxsel = { 2, 3, 1, 1 },
2187 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2243 .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
2188 .needs_tvaudio = 1, 2244 .needs_tvaudio = 1,
2189 .pll = PLL_28, 2245 .pll = PLL_28,
2190 .tuner_type = -1, 2246 .tuner_type = -1,
@@ -2204,7 +2260,7 @@ struct tvcard bttv_tvcards[] = {
2204 via the upper nibble of muxsel. here: used for 2260 via the upper nibble of muxsel. here: used for
2205 xternal video-mux */ 2261 xternal video-mux */
2206 .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 }, 2262 .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 },
2207 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2263 .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
2208 .needs_tvaudio = 1, 2264 .needs_tvaudio = 1,
2209 .pll = PLL_28, 2265 .pll = PLL_28,
2210 .tuner_type = -1, 2266 .tuner_type = -1,
@@ -2222,7 +2278,7 @@ struct tvcard bttv_tvcards[] = {
2222 via the upper nibble of muxsel. here: used for 2278 via the upper nibble of muxsel. here: used for
2223 xternal video-mux */ 2279 xternal video-mux */
2224 .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 }, 2280 .muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 },
2225 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2281 .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
2226 .needs_tvaudio = 1, 2282 .needs_tvaudio = 1,
2227 .pll = PLL_28, 2283 .pll = PLL_28,
2228 .tuner_type = -1, 2284 .tuner_type = -1,
@@ -2310,7 +2366,7 @@ struct tvcard bttv_tvcards[] = {
2310 .svhs = 2, 2366 .svhs = 2,
2311 .gpiomask = 3, 2367 .gpiomask = 3,
2312 .muxsel = { 2, 3, 1, 1 }, 2368 .muxsel = { 2, 3, 1, 1 },
2313 .audiomux = { 1, 1, 1, 1, 0 }, 2369 .gpiomux = { 1, 1, 1, 1 },
2314 .needs_tvaudio = 1, 2370 .needs_tvaudio = 1,
2315 .tuner_type = TUNER_PHILIPS_PAL, 2371 .tuner_type = TUNER_PHILIPS_PAL,
2316 .tuner_addr = ADDR_UNSET, 2372 .tuner_addr = ADDR_UNSET,
@@ -2341,7 +2397,8 @@ struct tvcard bttv_tvcards[] = {
2341 .svhs = 2, 2397 .svhs = 2,
2342 .gpiomask = 0x008007, 2398 .gpiomask = 0x008007,
2343 .muxsel = { 2, 3, 0, 0 }, 2399 .muxsel = { 2, 3, 0, 0 },
2344 .audiomux = { 0, 0, 0, 0, 0x000003, 0 }, 2400 .gpiomux = { 0, 0, 0, 0 },
2401 .gpiomute = 0x000003,
2345 .pll = PLL_28, 2402 .pll = PLL_28,
2346 .tuner_type = TUNER_PHILIPS_PAL, 2403 .tuner_type = TUNER_PHILIPS_PAL,
2347 .tuner_addr = ADDR_UNSET, 2404 .tuner_addr = ADDR_UNSET,
@@ -2377,7 +2434,7 @@ struct tvcard bttv_tvcards[] = {
2377 .needs_tvaudio = 0, 2434 .needs_tvaudio = 0,
2378 .gpiomask = 0x68, 2435 .gpiomask = 0x68,
2379 .muxsel = { 2, 3, 1 }, 2436 .muxsel = { 2, 3, 1 },
2380 .audiomux = { 0x68, 0x68, 0x61, 0x61, 0x00 }, 2437 .gpiomux = { 0x68, 0x68, 0x61, 0x61 },
2381 .pll = PLL_28, 2438 .pll = PLL_28,
2382 }, 2439 },
2383 2440
@@ -2392,7 +2449,8 @@ struct tvcard bttv_tvcards[] = {
2392 .svhs = 2, 2449 .svhs = 2,
2393 .gpiomask = 0x008007, 2450 .gpiomask = 0x008007,
2394 .muxsel = { 2, 3, 1, 1 }, 2451 .muxsel = { 2, 3, 1, 1 },
2395 .audiomux = { 0, 1, 2, 2, 3 }, 2452 .gpiomux = { 0, 1, 2, 2 },
2453 .gpiomute = 3,
2396 .needs_tvaudio = 0, 2454 .needs_tvaudio = 0,
2397 .pll = PLL_28, 2455 .pll = PLL_28,
2398 .tuner_type = TUNER_PHILIPS_PAL, 2456 .tuner_type = TUNER_PHILIPS_PAL,
@@ -2417,7 +2475,7 @@ struct tvcard bttv_tvcards[] = {
2417 .no_tda9875 = 1, 2475 .no_tda9875 = 1,
2418 .no_tda7432 = 1, 2476 .no_tda7432 = 1,
2419 .muxsel = {2,2,2,2},/*878A input is always MUX0, see above.*/ 2477 .muxsel = {2,2,2,2},/*878A input is always MUX0, see above.*/
2420 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2478 .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
2421 .pll = PLL_28, 2479 .pll = PLL_28,
2422 .needs_tvaudio = 0, 2480 .needs_tvaudio = 0,
2423 .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/ 2481 .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/
@@ -2435,7 +2493,7 @@ struct tvcard bttv_tvcards[] = {
2435 .svhs = 2, 2493 .svhs = 2,
2436 .gpiomask = 0x0000000f, 2494 .gpiomask = 0x0000000f,
2437 .muxsel = { 2, 1, 1 }, 2495 .muxsel = { 2, 1, 1 },
2438 .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00 }, 2496 .gpiomux = { 0x02, 0x00, 0x00, 0x00 },
2439 .tuner_type = TUNER_TEMIC_PAL, 2497 .tuner_type = TUNER_TEMIC_PAL,
2440 .tuner_addr = ADDR_UNSET, 2498 .tuner_addr = ADDR_UNSET,
2441 .radio_addr = ADDR_UNSET, 2499 .radio_addr = ADDR_UNSET,
@@ -2491,7 +2549,7 @@ struct tvcard bttv_tvcards[] = {
2491 .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, 2549 .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2,
2492 3, 3, 3, 3, 3, 3, 3, 3 }, 2550 3, 3, 3, 3, 3, 3, 3, 3 },
2493 .muxsel_hook = sigmaSQ_muxsel, 2551 .muxsel_hook = sigmaSQ_muxsel,
2494 .audiomux = { 0 }, 2552 .gpiomux = { 0 },
2495 .no_msp34xx = 1, 2553 .no_msp34xx = 1,
2496 .pll = PLL_28, 2554 .pll = PLL_28,
2497 .tuner_type = -1, 2555 .tuner_type = -1,
@@ -2508,7 +2566,7 @@ struct tvcard bttv_tvcards[] = {
2508 .gpiomask = 0x0, 2566 .gpiomask = 0x0,
2509 .muxsel = { 2, 2, 2, 2 }, 2567 .muxsel = { 2, 2, 2, 2 },
2510 .muxsel_hook = sigmaSLC_muxsel, 2568 .muxsel_hook = sigmaSLC_muxsel,
2511 .audiomux = { 0 }, 2569 .gpiomux = { 0 },
2512 .no_msp34xx = 1, 2570 .no_msp34xx = 1,
2513 .pll = PLL_28, 2571 .pll = PLL_28,
2514 .tuner_type = -1, 2572 .tuner_type = -1,
@@ -2526,7 +2584,8 @@ struct tvcard bttv_tvcards[] = {
2526 .svhs = -1, 2584 .svhs = -1,
2527 .gpiomask = 0xFF, 2585 .gpiomask = 0xFF,
2528 .muxsel = { 2, 3, 1, 1 }, 2586 .muxsel = { 2, 3, 1, 1 },
2529 .audiomux = { 2, 0, 0, 0, 10 }, 2587 .gpiomux = { 2, 0, 0, 0 },
2588 .gpiomute = 10,
2530 .needs_tvaudio = 0, 2589 .needs_tvaudio = 0,
2531 .pll = PLL_28, 2590 .pll = PLL_28,
2532 .tuner_type = TUNER_PHILIPS_PAL, 2591 .tuner_type = TUNER_PHILIPS_PAL,
@@ -2560,7 +2619,8 @@ struct tvcard bttv_tvcards[] = {
2560 .svhs = 2, 2619 .svhs = 2,
2561 .gpiomask = 0x3f, 2620 .gpiomask = 0x3f,
2562 .muxsel = {2, 3, 1, 0 }, 2621 .muxsel = {2, 3, 1, 0 },
2563 .audiomux = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31 }, 2622 .gpiomux = {0x31, 0x31, 0x31, 0x31 },
2623 .gpiomute = 0x31,
2564 .no_msp34xx = 1, 2624 .no_msp34xx = 1,
2565 .pll = PLL_28, 2625 .pll = PLL_28,
2566 .tuner_type = TUNER_PHILIPS_NTSC_M, 2626 .tuner_type = TUNER_PHILIPS_NTSC_M,
@@ -2583,7 +2643,7 @@ struct tvcard bttv_tvcards[] = {
2583 .tuner_addr = ADDR_UNSET, 2643 .tuner_addr = ADDR_UNSET,
2584 .radio_addr = ADDR_UNSET, 2644 .radio_addr = ADDR_UNSET,
2585 .gpiomask = 0x008007, 2645 .gpiomask = 0x008007,
2586 .audiomux = { 0, 0x000001,0,0, 0 }, 2646 .gpiomux = { 0, 0x000001,0,0 },
2587 .needs_tvaudio = 1, 2647 .needs_tvaudio = 1,
2588 .has_radio = 1, 2648 .has_radio = 1,
2589 }, 2649 },
@@ -2693,7 +2753,8 @@ struct tvcard bttv_tvcards[] = {
2693 .svhs = 2, 2753 .svhs = 2,
2694 .muxsel = { 2, 3, 1 }, 2754 .muxsel = { 2, 3, 1 },
2695 .gpiomask = 0x00e00007, 2755 .gpiomask = 0x00e00007,
2696 .audiomux = { 0x00400005, 0, 0x00000001, 0, 0x00c00007, 0 }, 2756 .gpiomux = { 0x00400005, 0, 0x00000001, 0 },
2757 .gpiomute = 0x00c00007,
2697 .no_msp34xx = 1, 2758 .no_msp34xx = 1,
2698 .no_tda9875 = 1, 2759 .no_tda9875 = 1,
2699 .no_tda7432 = 1, 2760 .no_tda7432 = 1,
@@ -2709,7 +2770,8 @@ struct tvcard bttv_tvcards[] = {
2709 .svhs = 2, 2770 .svhs = 2,
2710 .gpiomask = 0x01fe00, 2771 .gpiomask = 0x01fe00,
2711 .muxsel = { 2, 3, 1, 1 }, 2772 .muxsel = { 2, 3, 1, 1 },
2712 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, 2773 .gpiomux = { 0x001e00, 0, 0x018000, 0x014000 },
2774 .gpiomute = 0x002000,
2713 .needs_tvaudio = 1, 2775 .needs_tvaudio = 1,
2714 .pll = PLL_28, 2776 .pll = PLL_28,
2715 .tuner_type = TUNER_YMEC_TVF66T5_B_DFF, 2777 .tuner_type = TUNER_YMEC_TVF66T5_B_DFF,
@@ -2726,7 +2788,8 @@ struct tvcard bttv_tvcards[] = {
2726 .svhs = 2, 2788 .svhs = 2,
2727 .gpiomask = 0x001c0007, 2789 .gpiomask = 0x001c0007,
2728 .muxsel = { 2, 3, 1, 1 }, 2790 .muxsel = { 2, 3, 1, 1 },
2729 .audiomux = { 0, 1, 2, 2, 3 }, 2791 .gpiomux = { 0, 1, 2, 2 },
2792 .gpiomute = 3,
2730 .needs_tvaudio = 0, 2793 .needs_tvaudio = 0,
2731 .pll = PLL_28, 2794 .pll = PLL_28,
2732 .tuner_type = TUNER_TENA_9533_DI, 2795 .tuner_type = TUNER_TENA_9533_DI,
@@ -2745,7 +2808,8 @@ struct tvcard bttv_tvcards[] = {
2745 .gpiomask = 0x01fe00, 2808 .gpiomask = 0x01fe00,
2746 .muxsel = { 2,3,1,1,-1 }, 2809 .muxsel = { 2,3,1,1,-1 },
2747 .digital_mode = DIGITAL_MODE_CAMERA, 2810 .digital_mode = DIGITAL_MODE_CAMERA,
2748 .audiomux = { 0x00400, 0x10400, 0x04400, 0x80000, 0x12400, 0x46000 }, 2811 .gpiomux = { 0x00400, 0x10400, 0x04400, 0x80000 },
2812 .gpiomute = 0x12400,
2749 .no_msp34xx = 1, 2813 .no_msp34xx = 1,
2750 .pll = PLL_28, 2814 .pll = PLL_28,
2751 .tuner_type = TUNER_LG_PAL_FM, 2815 .tuner_type = TUNER_LG_PAL_FM,
@@ -2763,7 +2827,8 @@ struct tvcard bttv_tvcards[] = {
2763 .svhs = 2, 2827 .svhs = 2,
2764 .gpiomask = 0x3f, 2828 .gpiomask = 0x3f,
2765 .muxsel = { 2, 3, 1, 1 }, 2829 .muxsel = { 2, 3, 1, 1 },
2766 .audiomux = { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 }, 2830 .gpiomux = { 0x21, 0x20, 0x24, 0x2c },
2831 .gpiomute = 0x29,
2767 .no_msp34xx = 1, 2832 .no_msp34xx = 1,
2768 .pll = PLL_28, 2833 .pll = PLL_28,
2769 .tuner_type = TUNER_YMEC_TVF_5533MF, 2834 .tuner_type = TUNER_YMEC_TVF_5533MF,
@@ -2797,7 +2862,8 @@ struct tvcard bttv_tvcards[] = {
2797 .svhs = 2, 2862 .svhs = 2,
2798 .gpiomask = 15, 2863 .gpiomask = 15,
2799 .muxsel = { 2, 3, 1, 1 }, 2864 .muxsel = { 2, 3, 1, 1 },
2800 .audiomux = { 2, 0, 0, 0, 1 }, 2865 .gpiomux = { 2, 0, 0, 0 },
2866 .gpiomute = 1,
2801 .needs_tvaudio = 1, 2867 .needs_tvaudio = 1,
2802 .pll = PLL_28, 2868 .pll = PLL_28,
2803 .tuner_type = 2, 2869 .tuner_type = 2,
@@ -2813,7 +2879,7 @@ struct tvcard bttv_tvcards[] = {
2813 .svhs = 2, 2879 .svhs = 2,
2814 .gpiomask = 0x108007, 2880 .gpiomask = 0x108007,
2815 .muxsel = { 2, 3, 1, 1 }, 2881 .muxsel = { 2, 3, 1, 1 },
2816 .audiomux = { 100000, 100002, 100002, 100000 }, 2882 .gpiomux = { 100000, 100002, 100002, 100000 },
2817 .no_msp34xx = 1, 2883 .no_msp34xx = 1,
2818 .no_tda9875 = 1, 2884 .no_tda9875 = 1,
2819 .no_tda7432 = 1, 2885 .no_tda7432 = 1,
@@ -2853,7 +2919,8 @@ struct tvcard bttv_tvcards[] = {
2853 .svhs = 2, 2919 .svhs = 2,
2854 .gpiomask = 7, 2920 .gpiomask = 7,
2855 .muxsel = { 2, 3, 1, 1 }, 2921 .muxsel = { 2, 3, 1, 1 },
2856 .audiomux = { 0, 1, 2, 3, 4 }, 2922 .gpiomux = { 0, 1, 2, 3 },
2923 .gpiomute = 4,
2857 .tuner_type = TUNER_TEMIC_4009FR5_PAL, 2924 .tuner_type = TUNER_TEMIC_4009FR5_PAL,
2858 .tuner_addr = ADDR_UNSET, 2925 .tuner_addr = ADDR_UNSET,
2859 .radio_addr = ADDR_UNSET, 2926 .radio_addr = ADDR_UNSET,
@@ -2925,20 +2992,20 @@ void __devinit bttv_idcard(struct bttv *btv)
2925 if (UNSET != audiomux[0]) { 2992 if (UNSET != audiomux[0]) {
2926 gpiobits = 0; 2993 gpiobits = 0;
2927 for (i = 0; i < 5; i++) { 2994 for (i = 0; i < 5; i++) {
2928 bttv_tvcards[btv->c.type].audiomux[i] = audiomux[i]; 2995 bttv_tvcards[btv->c.type].gpiomux[i] = audiomux[i];
2929 gpiobits |= audiomux[i]; 2996 gpiobits |= audiomux[i];
2930 } 2997 }
2931 } else { 2998 } else {
2932 gpiobits = audioall; 2999 gpiobits = audioall;
2933 for (i = 0; i < 5; i++) { 3000 for (i = 0; i < 5; i++) {
2934 bttv_tvcards[btv->c.type].audiomux[i] = audioall; 3001 bttv_tvcards[btv->c.type].gpiomux[i] = audioall;
2935 } 3002 }
2936 } 3003 }
2937 bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits; 3004 bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
2938 printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=", 3005 printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
2939 btv->c.nr,bttv_tvcards[btv->c.type].gpiomask); 3006 btv->c.nr,bttv_tvcards[btv->c.type].gpiomask);
2940 for (i = 0; i < 5; i++) { 3007 for (i = 0; i < 5; i++) {
2941 printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].audiomux[i]); 3008 printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].gpiomux[i]);
2942 } 3009 }
2943 printk("\n"); 3010 printk("\n");
2944} 3011}
@@ -3046,7 +3113,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
3046 gpio_inout(0xffffff, 0); 3113 gpio_inout(0xffffff, 0);
3047 gpio = gpio_read(); 3114 gpio = gpio_read();
3048 id = ((gpio>>10) & 63) -1; 3115 id = ((gpio>>10) & 63) -1;
3049 msp = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx"); 3116 msp = bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx");
3050 if (id < 32) { 3117 if (id < 32) {
3051 btv->tuner_type = miro_tunermap[id]; 3118 btv->tuner_type = miro_tunermap[id];
3052 if (0 == (gpio & 0x20)) { 3119 if (0 == (gpio & 0x20)) {
@@ -3442,8 +3509,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
3442 3509
3443 if (bttv_tvcards[btv->c.type].digital_mode == DIGITAL_MODE_CAMERA) { 3510 if (bttv_tvcards[btv->c.type].digital_mode == DIGITAL_MODE_CAMERA) {
3444 /* detect Bt832 chip for quartzsight digital camera */ 3511 /* detect Bt832 chip for quartzsight digital camera */
3445 if ((bttv_I2CRead(btv, I2C_BT832_ALT1, "Bt832") >=0) || 3512 if ((bttv_I2CRead(btv, I2C_ADDR_BT832_ALT1, "Bt832") >=0) ||
3446 (bttv_I2CRead(btv, I2C_BT832_ALT2, "Bt832") >=0)) 3513 (bttv_I2CRead(btv, I2C_ADDR_BT832_ALT2, "Bt832") >=0))
3447 boot_bt832(btv); 3514 boot_bt832(btv);
3448 } 3515 }
3449 3516
@@ -3452,19 +3519,19 @@ void __devinit bttv_init_card2(struct bttv *btv)
3452 3519
3453 /* try to detect audio/fader chips */ 3520 /* try to detect audio/fader chips */
3454 if (!bttv_tvcards[btv->c.type].no_msp34xx && 3521 if (!bttv_tvcards[btv->c.type].no_msp34xx &&
3455 bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0) 3522 bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx") >=0)
3456 request_module("msp3400"); 3523 request_module("msp3400");
3457 3524
3458 if (bttv_tvcards[btv->c.type].msp34xx_alt && 3525 if (bttv_tvcards[btv->c.type].msp34xx_alt &&
3459 bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0) 3526 bttv_I2CRead(btv, I2C_ADDR_MSP3400_ALT, "MSP34xx (alternate address)") >=0)
3460 request_module("msp3400"); 3527 request_module("msp3400");
3461 3528
3462 if (!bttv_tvcards[btv->c.type].no_tda9875 && 3529 if (!bttv_tvcards[btv->c.type].no_tda9875 &&
3463 bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0) 3530 bttv_I2CRead(btv, I2C_ADDR_TDA9875, "TDA9875") >=0)
3464 request_module("tda9875"); 3531 request_module("tda9875");
3465 3532
3466 if (!bttv_tvcards[btv->c.type].no_tda7432 && 3533 if (!bttv_tvcards[btv->c.type].no_tda7432 &&
3467 bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0) 3534 bttv_I2CRead(btv, I2C_ADDR_TDA7432, "TDA7432") >=0)
3468 request_module("tda7432"); 3535 request_module("tda7432");
3469 3536
3470 if (bttv_tvcards[btv->c.type].needs_tvaudio) 3537 if (bttv_tvcards[btv->c.type].needs_tvaudio)
@@ -3475,7 +3542,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3475 if (btv->tda9887_conf) 3542 if (btv->tda9887_conf)
3476 tda9887 = 1; 3543 tda9887 = 1;
3477 if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb && 3544 if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb &&
3478 bttv_I2CRead(btv, I2C_TDA9887, "TDA9887") >=0) 3545 bttv_I2CRead(btv, I2C_ADDR_TDA9887, "TDA9887") >=0)
3479 tda9887 = 1; 3546 tda9887 = 1;
3480 /* Hybrid DVB card, DOES have a tda9887 */ 3547 /* Hybrid DVB card, DOES have a tda9887 */
3481 if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE) 3548 if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE)
@@ -3796,18 +3863,18 @@ void bttv_tda9880_setnorm(struct bttv *btv, int norm)
3796{ 3863{
3797 /* fix up our card entry */ 3864 /* fix up our card entry */
3798 if(norm==VIDEO_MODE_NTSC) { 3865 if(norm==VIDEO_MODE_NTSC) {
3799 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[0]=0x957fff; 3866 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomux[TVAUDIO_INPUT_TUNER]=0x957fff;
3800 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[4]=0x957fff; 3867 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomute=0x957fff;
3801 dprintk("bttv_tda9880_setnorm to NTSC\n"); 3868 dprintk("bttv_tda9880_setnorm to NTSC\n");
3802 } 3869 }
3803 else { 3870 else {
3804 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[0]=0x947fff; 3871 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomux[TVAUDIO_INPUT_TUNER]=0x947fff;
3805 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[4]=0x947fff; 3872 bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomute=0x947fff;
3806 dprintk("bttv_tda9880_setnorm to PAL\n"); 3873 dprintk("bttv_tda9880_setnorm to PAL\n");
3807 } 3874 }
3808 /* set GPIO according */ 3875 /* set GPIO according */
3809 gpio_bits(bttv_tvcards[btv->c.type].gpiomask, 3876 gpio_bits(bttv_tvcards[btv->c.type].gpiomask,
3810 bttv_tvcards[btv->c.type].audiomux[btv->audio]); 3877 bttv_tvcards[btv->c.type].gpiomux[btv->audio]);
3811} 3878}
3812 3879
3813 3880
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index c0415d6e7fee..74def9c23952 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -36,13 +36,15 @@
36#include <linux/kdev_t.h> 36#include <linux/kdev_t.h>
37#include "bttvp.h" 37#include "bttvp.h"
38#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
39#include <media/tvaudio.h>
40#include <media/msp3400.h>
39 41
40#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
41 43
42#include <asm/io.h> 44#include <asm/io.h>
43#include <asm/byteorder.h> 45#include <asm/byteorder.h>
44 46
45#include "rds.h" 47#include <media/rds.h>
46 48
47 49
48unsigned int bttv_num; /* number of Bt848s in use */ 50unsigned int bttv_num; /* number of Bt848s in use */
@@ -926,45 +928,98 @@ video_mux(struct bttv *btv, unsigned int input)
926 928
927static char *audio_modes[] = { 929static char *audio_modes[] = {
928 "audio: tuner", "audio: radio", "audio: extern", 930 "audio: tuner", "audio: radio", "audio: extern",
929 "audio: intern", "audio: off" 931 "audio: intern", "audio: mute"
930}; 932};
931 933
932static int 934static int
933audio_mux(struct bttv *btv, int mode) 935audio_mux(struct bttv *btv, int input, int mute)
934{ 936{
935 int val,mux,i2c_mux,signal; 937 int gpio_val, signal;
938 struct v4l2_control ctrl;
939 struct i2c_client *c;
936 940
937 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, 941 gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
938 bttv_tvcards[btv->c.type].gpiomask); 942 bttv_tvcards[btv->c.type].gpiomask);
939 signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC; 943 signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
940 944
941 switch (mode) { 945 btv->mute = mute;
942 case AUDIO_MUTE: 946 btv->audio = input;
943 btv->audio |= AUDIO_MUTE; 947
944 break; 948 /* automute */
945 case AUDIO_UNMUTE: 949 mute = mute || (btv->opt_automute && !signal && !btv->radio_user);
946 btv->audio &= ~AUDIO_MUTE; 950
947 break; 951 if (mute)
948 case AUDIO_TUNER: 952 gpio_val = bttv_tvcards[btv->c.type].gpiomute;
949 case AUDIO_RADIO: 953 else
950 case AUDIO_EXTERN: 954 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input];
951 case AUDIO_INTERN: 955
952 btv->audio &= AUDIO_MUTE; 956 gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val);
953 btv->audio |= mode;
954 }
955 i2c_mux = mux = (btv->audio & AUDIO_MUTE) ? AUDIO_OFF : btv->audio;
956 if (btv->opt_automute && !signal && !btv->radio_user)
957 mux = AUDIO_OFF;
958
959 val = bttv_tvcards[btv->c.type].audiomux[mux];
960 gpio_bits(bttv_tvcards[btv->c.type].gpiomask,val);
961 if (bttv_gpio) 957 if (bttv_gpio)
962 bttv_gpio_tracking(btv,audio_modes[mux]); 958 bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]);
963 if (!in_interrupt()) 959 if (in_interrupt())
964 bttv_call_i2c_clients(btv,AUDC_SET_INPUT,&(i2c_mux)); 960 return 0;
961
962 ctrl.id = V4L2_CID_AUDIO_MUTE;
963 ctrl.value = btv->mute;
964 bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, &ctrl);
965 c = btv->i2c_msp34xx_client;
966 if (c) {
967 struct v4l2_routing route;
968
969 /* Note: the inputs tuner/radio/extern/intern are translated
970 to msp routings. This assumes common behavior for all msp3400
971 based TV cards. When this assumption fails, then the
972 specific MSP routing must be added to the card table.
973 For now this is sufficient. */
974 switch (input) {
975 case TVAUDIO_INPUT_RADIO:
976 route.input = MSP_INPUT(MSP_IN_SCART_2, MSP_IN_TUNER_1,
977 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART);
978 break;
979 case TVAUDIO_INPUT_EXTERN:
980 route.input = MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1,
981 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART);
982 break;
983 case TVAUDIO_INPUT_INTERN:
984 /* Yes, this is the same input as for RADIO. I doubt
985 if this is ever used. The only board with an INTERN
986 input is the BTTV_BOARD_AVERMEDIA98. I wonder how
987 that was tested. My guess is that the whole INTERN
988 input does not work. */
989 route.input = MSP_INPUT(MSP_IN_SCART_2, MSP_IN_TUNER_1,
990 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART);
991 break;
992 case TVAUDIO_INPUT_TUNER:
993 default:
994 route.input = MSP_INPUT_DEFAULT;
995 break;
996 }
997 route.output = MSP_OUTPUT_DEFAULT;
998 c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route);
999 }
1000 c = btv->i2c_tvaudio_client;
1001 if (c) {
1002 struct v4l2_routing route;
1003
1004 route.input = input;
1005 route.output = 0;
1006 c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route);
1007 }
965 return 0; 1008 return 0;
966} 1009}
967 1010
1011static inline int
1012audio_mute(struct bttv *btv, int mute)
1013{
1014 return audio_mux(btv, btv->audio, mute);
1015}
1016
1017static inline int
1018audio_input(struct bttv *btv, int input)
1019{
1020 return audio_mux(btv, input, btv->mute);
1021}
1022
968static void 1023static void
969i2c_vidiocschan(struct bttv *btv) 1024i2c_vidiocschan(struct bttv *btv)
970{ 1025{
@@ -1023,8 +1078,8 @@ set_input(struct bttv *btv, unsigned int input)
1023 } else { 1078 } else {
1024 video_mux(btv,input); 1079 video_mux(btv,input);
1025 } 1080 }
1026 audio_mux(btv,(input == bttv_tvcards[btv->c.type].tuner ? 1081 audio_input(btv,(input == bttv_tvcards[btv->c.type].tuner ?
1027 AUDIO_TUNER : AUDIO_EXTERN)); 1082 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN));
1028 set_tvnorm(btv,btv->tvnorm); 1083 set_tvnorm(btv,btv->tvnorm);
1029 i2c_vidiocschan(btv); 1084 i2c_vidiocschan(btv);
1030} 1085}
@@ -1236,10 +1291,10 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
1236 case V4L2_CID_AUDIO_MUTE: 1291 case V4L2_CID_AUDIO_MUTE:
1237 if (c->value) { 1292 if (c->value) {
1238 va.flags |= VIDEO_AUDIO_MUTE; 1293 va.flags |= VIDEO_AUDIO_MUTE;
1239 audio_mux(btv, AUDIO_MUTE); 1294 audio_mute(btv, 1);
1240 } else { 1295 } else {
1241 va.flags &= ~VIDEO_AUDIO_MUTE; 1296 va.flags &= ~VIDEO_AUDIO_MUTE;
1242 audio_mux(btv, AUDIO_UNMUTE); 1297 audio_mute(btv, 0);
1243 } 1298 }
1244 break; 1299 break;
1245 1300
@@ -1397,7 +1452,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
1397 free_btres(btv,fh,RESOURCE_OVERLAY); 1452 free_btres(btv,fh,RESOURCE_OVERLAY);
1398 if (NULL != old) { 1453 if (NULL != old) {
1399 dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state); 1454 dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state);
1400 bttv_dma_free(btv, old); 1455 bttv_dma_free(&fh->cap,btv, old);
1401 kfree(old); 1456 kfree(old);
1402 } 1457 }
1403 dprintk("switch_overlay: done\n"); 1458 dprintk("switch_overlay: done\n");
@@ -1407,7 +1462,8 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
1407/* ----------------------------------------------------------------------- */ 1462/* ----------------------------------------------------------------------- */
1408/* video4linux (1) interface */ 1463/* video4linux (1) interface */
1409 1464
1410static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf, 1465static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
1466 struct bttv_buffer *buf,
1411 const struct bttv_format *fmt, 1467 const struct bttv_format *fmt,
1412 unsigned int width, unsigned int height, 1468 unsigned int width, unsigned int height,
1413 enum v4l2_field field) 1469 enum v4l2_field field)
@@ -1450,7 +1506,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
1450 /* alloc risc memory */ 1506 /* alloc risc memory */
1451 if (STATE_NEEDS_INIT == buf->vb.state) { 1507 if (STATE_NEEDS_INIT == buf->vb.state) {
1452 redo_dma_risc = 1; 1508 redo_dma_risc = 1;
1453 if (0 != (rc = videobuf_iolock(btv->c.pci,&buf->vb,&btv->fbuf))) 1509 if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf)))
1454 goto fail; 1510 goto fail;
1455 } 1511 }
1456 1512
@@ -1462,7 +1518,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
1462 return 0; 1518 return 0;
1463 1519
1464 fail: 1520 fail:
1465 bttv_dma_free(btv,buf); 1521 bttv_dma_free(q,btv,buf);
1466 return rc; 1522 return rc;
1467} 1523}
1468 1524
@@ -1486,7 +1542,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
1486 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); 1542 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
1487 struct bttv_fh *fh = q->priv_data; 1543 struct bttv_fh *fh = q->priv_data;
1488 1544
1489 return bttv_prepare_buffer(fh->btv, buf, fh->fmt, 1545 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt,
1490 fh->width, fh->height, field); 1546 fh->width, fh->height, field);
1491} 1547}
1492 1548
@@ -1510,7 +1566,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1510 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); 1566 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
1511 struct bttv_fh *fh = q->priv_data; 1567 struct bttv_fh *fh = q->priv_data;
1512 1568
1513 bttv_dma_free(fh->btv,buf); 1569 bttv_dma_free(&fh->cap,fh->btv,buf);
1514} 1570}
1515 1571
1516static struct videobuf_queue_ops bttv_video_qops = { 1572static struct videobuf_queue_ops bttv_video_qops = {
@@ -1653,7 +1709,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1653 return -EINVAL; 1709 return -EINVAL;
1654 1710
1655 mutex_lock(&btv->lock); 1711 mutex_lock(&btv->lock);
1656 audio_mux(btv, (v->flags&VIDEO_AUDIO_MUTE) ? AUDIO_MUTE : AUDIO_UNMUTE); 1712 audio_mute(btv, (v->flags&VIDEO_AUDIO_MUTE) ? 1 : 0);
1657 bttv_call_i2c_clients(btv,cmd,v); 1713 bttv_call_i2c_clients(btv,cmd,v);
1658 1714
1659 /* card specific hooks */ 1715 /* card specific hooks */
@@ -1822,7 +1878,8 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1822 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va); 1878 bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
1823 if (t->audmode == V4L2_TUNER_MODE_MONO) 1879 if (t->audmode == V4L2_TUNER_MODE_MONO)
1824 va.mode = VIDEO_SOUND_MONO; 1880 va.mode = VIDEO_SOUND_MONO;
1825 else if (t->audmode == V4L2_TUNER_MODE_STEREO) 1881 else if (t->audmode == V4L2_TUNER_MODE_STEREO ||
1882 t->audmode == V4L2_TUNER_MODE_LANG1_LANG2)
1826 va.mode = VIDEO_SOUND_STEREO; 1883 va.mode = VIDEO_SOUND_STEREO;
1827 else if (t->audmode == V4L2_TUNER_MODE_LANG1) 1884 else if (t->audmode == V4L2_TUNER_MODE_LANG1)
1828 va.mode = VIDEO_SOUND_LANG1; 1885 va.mode = VIDEO_SOUND_LANG1;
@@ -2496,7 +2553,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2496 field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2) 2553 field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2)
2497 ? V4L2_FIELD_INTERLACED 2554 ? V4L2_FIELD_INTERLACED
2498 : V4L2_FIELD_BOTTOM; 2555 : V4L2_FIELD_BOTTOM;
2499 retval = bttv_prepare_buffer(btv,buf, 2556 retval = bttv_prepare_buffer(&fh->cap,btv,buf,
2500 format_by_palette(vm->format), 2557 format_by_palette(vm->format),
2501 vm->width,vm->height,field); 2558 vm->width,vm->height,field);
2502 if (0 != retval) 2559 if (0 != retval)
@@ -2528,8 +2585,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2528 retval = -EIO; 2585 retval = -EIO;
2529 /* fall through */ 2586 /* fall through */
2530 case STATE_DONE: 2587 case STATE_DONE:
2531 videobuf_dma_pci_sync(btv->c.pci,&buf->vb.dma); 2588 videobuf_dma_sync(&fh->cap,&buf->vb.dma);
2532 bttv_dma_free(btv,buf); 2589 bttv_dma_free(&fh->cap,btv,buf);
2533 break; 2590 break;
2534 default: 2591 default:
2535 retval = -EINVAL; 2592 retval = -EINVAL;
@@ -3162,8 +3219,8 @@ static int radio_open(struct inode *inode, struct file *file)
3162 3219
3163 file->private_data = btv; 3220 file->private_data = btv;
3164 3221
3165 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); 3222 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL);
3166 audio_mux(btv,AUDIO_RADIO); 3223 audio_input(btv,TVAUDIO_INPUT_RADIO);
3167 3224
3168 mutex_unlock(&btv->lock); 3225 mutex_unlock(&btv->lock);
3169 return 0; 3226 return 0;
@@ -3749,7 +3806,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
3749 bttv_irq_switch_video(btv); 3806 bttv_irq_switch_video(btv);
3750 3807
3751 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) 3808 if ((astat & BT848_INT_HLOCK) && btv->opt_automute)
3752 audio_mux(btv, -1); 3809 audio_mute(btv, btv->mute); /* trigger automute */
3753 3810
3754 if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) { 3811 if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
3755 printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->c.nr, 3812 printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->c.nr,
@@ -4050,7 +4107,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4050 bt848_contrast(btv,32768); 4107 bt848_contrast(btv,32768);
4051 bt848_hue(btv,32768); 4108 bt848_hue(btv,32768);
4052 bt848_sat(btv,32768); 4109 bt848_sat(btv,32768);
4053 audio_mux(btv,AUDIO_MUTE); 4110 audio_mute(btv, 1);
4054 set_input(btv,0); 4111 set_input(btv,0);
4055 } 4112 }
4056 4113
diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bt8xx/bttv-gpio.c
index c4d5e2b70c28..c4d5e2b70c28 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 614c12018557..4b562b386fcf 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)
302 if (!client->driver->command) 302 if (!client->driver->command)
303 return 0; 303 return 0;
304 304
305 if (client->driver->id == I2C_DRIVERID_MSP3400)
306 btv->i2c_msp34xx_client = client;
307 if (client->driver->id == I2C_DRIVERID_TVAUDIO)
308 btv->i2c_tvaudio_client = client;
305 if (btv->tuner_type != UNSET) { 309 if (btv->tuner_type != UNSET) {
306 struct tuner_setup tun_setup; 310 struct tuner_setup tun_setup;
307 311
diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bt8xx/bttv-if.c
index 19b564ab0e92..19b564ab0e92 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 69efa0e5174d..69efa0e5174d 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 344f84e9af04..16323a5d68ac 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,
509} 509}
510 510
511void 511void
512bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf) 512bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
513{ 513{
514 BUG_ON(in_interrupt()); 514 BUG_ON(in_interrupt());
515 videobuf_waiton(&buf->vb,0,0); 515 videobuf_waiton(&buf->vb,0,0);
516 videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma); 516 videobuf_dma_unmap(q, &buf->vb.dma);
517 videobuf_dma_free(&buf->vb.dma); 517 videobuf_dma_free(&buf->vb.dma);
518 btcx_riscmem_free(btv->c.pci,&buf->bottom); 518 btcx_riscmem_free(btv->c.pci,&buf->bottom);
519 btcx_riscmem_free(btv->c.pci,&buf->top); 519 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 72afdd64b882..e20ff238e409 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,
96 return -EINVAL; 96 return -EINVAL;
97 97
98 if (STATE_NEEDS_INIT == buf->vb.state) { 98 if (STATE_NEEDS_INIT == buf->vb.state) {
99 if (0 != (rc = videobuf_iolock(btv->c.pci, &buf->vb, NULL))) 99 if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL)))
100 goto fail; 100 goto fail;
101 if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines))) 101 if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines)))
102 goto fail; 102 goto fail;
@@ -109,7 +109,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
109 return 0; 109 return 0;
110 110
111 fail: 111 fail:
112 bttv_dma_free(btv,buf); 112 bttv_dma_free(q,btv,buf);
113 return rc; 113 return rc;
114} 114}
115 115
@@ -136,7 +136,7 @@ static void vbi_buffer_release(struct videobuf_queue *q, struct videobuf_buffer
136 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); 136 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
137 137
138 dprintk("free %p\n",vb); 138 dprintk("free %p\n",vb);
139 bttv_dma_free(fh->btv,buf); 139 bttv_dma_free(&fh->cap,fh->btv,buf);
140} 140}
141 141
142struct videobuf_queue_ops bttv_vbi_qops = { 142struct videobuf_queue_ops bttv_vbi_qops = {
diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bt8xx/bttv.h
index 9908c8e0c951..3a23265c1538 100644
--- a/drivers/media/video/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -18,6 +18,7 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <media/ir-common.h> 19#include <media/ir-common.h>
20#include <media/ir-kbd-i2c.h> 20#include <media/ir-kbd-i2c.h>
21#include <media/i2c-addr.h>
21 22
22/* ---------------------------------------------------------- */ 23/* ---------------------------------------------------------- */
23/* exported by bttv-cards.c */ 24/* exported by bttv-cards.c */
@@ -168,25 +169,6 @@
168#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f 169#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f
169#define BTTV_BOARD_MACHTV_MAGICTV 0x90 170#define BTTV_BOARD_MACHTV_MAGICTV 0x90
170 171
171/* i2c address list */
172#define I2C_TSA5522 0xc2
173#define I2C_TDA7432 0x8a
174#define I2C_BT832_ALT1 0x88
175#define I2C_BT832_ALT2 0x8a // alternate setting
176#define I2C_TDA8425 0x82
177#define I2C_TDA9840 0x84
178#define I2C_TDA9850 0xb6 /* also used by 9855,9873 */
179#define I2C_TDA9874 0xb0 /* also used by 9875 */
180#define I2C_TDA9875 0xb0
181#define I2C_HAUPEE 0xa0
182#define I2C_STBEE 0xae
183#define I2C_VHX 0xc0
184#define I2C_MSP3400 0x80
185#define I2C_MSP3400_ALT 0x88
186#define I2C_TEA6300 0x80 /* also used by 6320 */
187#define I2C_DPL3518 0x84
188#define I2C_TDA9887 0x86
189
190/* more card-specific defines */ 172/* more card-specific defines */
191#define PT2254_L_CHANNEL 0x10 173#define PT2254_L_CHANNEL 0x10
192#define PT2254_R_CHANNEL 0x08 174#define PT2254_R_CHANNEL 0x08
@@ -252,7 +234,8 @@ struct tvcard
252 unsigned int digital_mode; // DIGITAL_MODE_CAMERA or DIGITAL_MODE_VIDEO 234 unsigned int digital_mode; // DIGITAL_MODE_CAMERA or DIGITAL_MODE_VIDEO
253 u32 gpiomask; 235 u32 gpiomask;
254 u32 muxsel[16]; 236 u32 muxsel[16];
255 u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */ 237 u32 gpiomux[4]; /* Tuner, Radio, external, internal */
238 u32 gpiomute; /* GPIO mute setting */
256 u32 gpiomask2; /* GPIO MUX mask */ 239 u32 gpiomask2; /* GPIO MUX mask */
257 240
258 /* i2c audio flags */ 241 /* i2c audio flags */
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 9cb72f176f7d..ee989d2e15d9 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -41,7 +41,6 @@
41 41
42#include <linux/device.h> 42#include <linux/device.h>
43#include <media/video-buf.h> 43#include <media/video-buf.h>
44#include <media/audiochip.h>
45#include <media/tuner.h> 44#include <media/tuner.h>
46#include <media/tveeprom.h> 45#include <media/tveeprom.h>
47#include <media/ir-common.h> 46#include <media/ir-common.h>
@@ -190,7 +189,8 @@ int bttv_buffer_activate_video(struct bttv *btv,
190 struct bttv_buffer_set *set); 189 struct bttv_buffer_set *set);
191int bttv_buffer_activate_vbi(struct bttv *btv, 190int bttv_buffer_activate_vbi(struct bttv *btv,
192 struct bttv_buffer *vbi); 191 struct bttv_buffer *vbi);
193void bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf); 192void bttv_dma_free(struct videobuf_queue *q, struct bttv *btv,
193 struct bttv_buffer *buf);
194 194
195/* overlay handling */ 195/* overlay handling */
196int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov, 196int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov,
@@ -298,6 +298,8 @@ struct bttv {
298 int i2c_state, i2c_rc; 298 int i2c_state, i2c_rc;
299 int i2c_done; 299 int i2c_done;
300 wait_queue_head_t i2c_queue; 300 wait_queue_head_t i2c_queue;
301 struct i2c_client *i2c_msp34xx_client;
302 struct i2c_client *i2c_tvaudio_client;
301 303
302 /* video4linux (1) */ 304 /* video4linux (1) */
303 struct video_device *video_dev; 305 struct video_device *video_dev;
@@ -320,6 +322,7 @@ struct bttv {
320 /* video state */ 322 /* video state */
321 unsigned int input; 323 unsigned int input;
322 unsigned int audio; 324 unsigned int audio;
325 unsigned int mute;
323 unsigned long freq; 326 unsigned long freq;
324 int tvnorm,hue,contrast,bright,saturation; 327 int tvnorm,hue,contrast,bright,saturation;
325 struct v4l2_framebuffer fbuf; 328 struct v4l2_framebuffer fbuf;
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index d97b7d8ac33d..cf61c590f4ad 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)
150static struct qcam_device *qcam_init(struct parport *port) 150static struct qcam_device *qcam_init(struct parport *port)
151{ 151{
152 struct qcam_device *q; 152 struct qcam_device *q;
153 153
154 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL); 154 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
155 if(q==NULL) 155 if(q==NULL)
156 return NULL; 156 return NULL;
@@ -158,16 +158,16 @@ static struct qcam_device *qcam_init(struct parport *port)
158 q->pport = port; 158 q->pport = port;
159 q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL, 159 q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL,
160 NULL, 0, NULL); 160 NULL, 0, NULL);
161 if (q->pdev == NULL) 161 if (q->pdev == NULL)
162 { 162 {
163 printk(KERN_ERR "bw-qcam: couldn't register for %s.\n", 163 printk(KERN_ERR "bw-qcam: couldn't register for %s.\n",
164 port->name); 164 port->name);
165 kfree(q); 165 kfree(q);
166 return NULL; 166 return NULL;
167 } 167 }
168 168
169 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); 169 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
170 170
171 mutex_init(&q->lock); 171 mutex_init(&q->lock);
172 172
173 q->port_mode = (QC_ANY | QC_NOTSET); 173 q->port_mode = (QC_ANY | QC_NOTSET);
@@ -236,12 +236,12 @@ static int qc_waithand(struct qcam_device *q, int val)
236 while (!((status = read_lpstatus(q)) & 8)) 236 while (!((status = read_lpstatus(q)) & 8))
237 { 237 {
238 /* 1000 is enough spins on the I/O for all normal 238 /* 1000 is enough spins on the I/O for all normal
239 cases, at that point we start to poll slowly 239 cases, at that point we start to poll slowly
240 until the camera wakes up. However, we are 240 until the camera wakes up. However, we are
241 busy blocked until the camera responds, so 241 busy blocked until the camera responds, so
242 setting it lower is much better for interactive 242 setting it lower is much better for interactive
243 response. */ 243 response. */
244 244
245 if(runs++>maxpoll) 245 if(runs++>maxpoll)
246 { 246 {
247 msleep_interruptible(5); 247 msleep_interruptible(5);
@@ -255,12 +255,12 @@ static int qc_waithand(struct qcam_device *q, int val)
255 while (((status = read_lpstatus(q)) & 8)) 255 while (((status = read_lpstatus(q)) & 8))
256 { 256 {
257 /* 1000 is enough spins on the I/O for all normal 257 /* 1000 is enough spins on the I/O for all normal
258 cases, at that point we start to poll slowly 258 cases, at that point we start to poll slowly
259 until the camera wakes up. However, we are 259 until the camera wakes up. However, we are
260 busy blocked until the camera responds, so 260 busy blocked until the camera responds, so
261 setting it lower is much better for interactive 261 setting it lower is much better for interactive
262 response. */ 262 response. */
263 263
264 if(runs++>maxpoll) 264 if(runs++>maxpoll)
265 { 265 {
266 msleep_interruptible(5); 266 msleep_interruptible(5);
@@ -282,17 +282,17 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val)
282{ 282{
283 unsigned int status; 283 unsigned int status;
284 int runs=0; 284 int runs=0;
285 285
286 do 286 do
287 { 287 {
288 status = read_lpdata(q); 288 status = read_lpdata(q);
289 /* 1000 is enough spins on the I/O for all normal 289 /* 1000 is enough spins on the I/O for all normal
290 cases, at that point we start to poll slowly 290 cases, at that point we start to poll slowly
291 until the camera wakes up. However, we are 291 until the camera wakes up. However, we are
292 busy blocked until the camera responds, so 292 busy blocked until the camera responds, so
293 setting it lower is much better for interactive 293 setting it lower is much better for interactive
294 response. */ 294 response. */
295 295
296 if(runs++>maxpoll) 296 if(runs++>maxpoll)
297 { 297 {
298 msleep_interruptible(5); 298 msleep_interruptible(5);
@@ -321,7 +321,7 @@ static int qc_detect(struct qcam_device *q)
321 321
322 lastreg = reg = read_lpstatus(q) & 0xf0; 322 lastreg = reg = read_lpstatus(q) & 0xf0;
323 323
324 for (i = 0; i < 500; i++) 324 for (i = 0; i < 500; i++)
325 { 325 {
326 reg = read_lpstatus(q) & 0xf0; 326 reg = read_lpstatus(q) & 0xf0;
327 if (reg != lastreg) 327 if (reg != lastreg)
@@ -357,7 +357,7 @@ static int qc_detect(struct qcam_device *q)
357 357
358static void qc_reset(struct qcam_device *q) 358static void qc_reset(struct qcam_device *q)
359{ 359{
360 switch (q->port_mode & QC_FORCE_MASK) 360 switch (q->port_mode & QC_FORCE_MASK)
361 { 361 {
362 case QC_FORCE_UNIDIR: 362 case QC_FORCE_UNIDIR:
363 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; 363 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
@@ -370,7 +370,7 @@ static void qc_reset(struct qcam_device *q)
370 case QC_ANY: 370 case QC_ANY:
371 write_lpcontrol(q, 0x20); 371 write_lpcontrol(q, 0x20);
372 write_lpdata(q, 0x75); 372 write_lpdata(q, 0x75);
373 373
374 if (read_lpdata(q) != 0x75) { 374 if (read_lpdata(q) != 0x75) {
375 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; 375 q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
376 } else { 376 } else {
@@ -398,8 +398,8 @@ static void qc_reset(struct qcam_device *q)
398static int qc_setscanmode(struct qcam_device *q) 398static int qc_setscanmode(struct qcam_device *q)
399{ 399{
400 int old_mode = q->mode; 400 int old_mode = q->mode;
401 401
402 switch (q->transfer_scale) 402 switch (q->transfer_scale)
403 { 403 {
404 case 1: 404 case 1:
405 q->mode = 0; 405 q->mode = 0;
@@ -412,7 +412,7 @@ static int qc_setscanmode(struct qcam_device *q)
412 break; 412 break;
413 } 413 }
414 414
415 switch (q->bpp) 415 switch (q->bpp)
416 { 416 {
417 case 4: 417 case 4:
418 break; 418 break;
@@ -421,7 +421,7 @@ static int qc_setscanmode(struct qcam_device *q)
421 break; 421 break;
422 } 422 }
423 423
424 switch (q->port_mode & QC_MODE_MASK) 424 switch (q->port_mode & QC_MODE_MASK)
425 { 425 {
426 case QC_BIDIR: 426 case QC_BIDIR:
427 q->mode += 1; 427 q->mode += 1;
@@ -430,10 +430,10 @@ static int qc_setscanmode(struct qcam_device *q)
430 case QC_UNIDIR: 430 case QC_UNIDIR:
431 break; 431 break;
432 } 432 }
433 433
434 if (q->mode != old_mode) 434 if (q->mode != old_mode)
435 q->status |= QC_PARAM_CHANGE; 435 q->status |= QC_PARAM_CHANGE;
436 436
437 return 0; 437 return 0;
438} 438}
439 439
@@ -451,7 +451,7 @@ static void qc_set(struct qcam_device *q)
451 /* Set the brightness. Yes, this is repetitive, but it works. 451 /* Set the brightness. Yes, this is repetitive, but it works.
452 * Shorter versions seem to fail subtly. Feel free to try :-). */ 452 * Shorter versions seem to fail subtly. Feel free to try :-). */
453 /* I think the problem was in qc_command, not here -- bls */ 453 /* I think the problem was in qc_command, not here -- bls */
454 454
455 qc_command(q, 0xb); 455 qc_command(q, 0xb);
456 qc_command(q, q->brightness); 456 qc_command(q, q->brightness);
457 457
@@ -502,13 +502,13 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
502 unsigned int hi2, lo2; 502 unsigned int hi2, lo2;
503 static int state = 0; 503 static int state = 0;
504 504
505 if (buffer == NULL) 505 if (buffer == NULL)
506 { 506 {
507 state = 0; 507 state = 0;
508 return 0; 508 return 0;
509 } 509 }
510 510
511 switch (q->port_mode & QC_MODE_MASK) 511 switch (q->port_mode & QC_MODE_MASK)
512 { 512 {
513 case QC_BIDIR: /* Bi-directional Port */ 513 case QC_BIDIR: /* Bi-directional Port */
514 write_lpcontrol(q, 0x26); 514 write_lpcontrol(q, 0x26);
@@ -517,7 +517,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
517 write_lpcontrol(q, 0x2e); 517 write_lpcontrol(q, 0x2e);
518 lo2 = (qc_waithand2(q, 0) >> 1); 518 lo2 = (qc_waithand2(q, 0) >> 1);
519 hi2 = (read_lpstatus(q) >> 3) & 0x1f; 519 hi2 = (read_lpstatus(q) >> 3) & 0x1f;
520 switch (q->bpp) 520 switch (q->bpp)
521 { 521 {
522 case 4: 522 case 4:
523 buffer[0] = lo & 0xf; 523 buffer[0] = lo & 0xf;
@@ -544,7 +544,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
544 write_lpcontrol(q, 0xe); 544 write_lpcontrol(q, 0xe);
545 hi = (qc_waithand(q, 0) & 0xf0) >> 4; 545 hi = (qc_waithand(q, 0) & 0xf0) >> 4;
546 546
547 switch (q->bpp) 547 switch (q->bpp)
548 { 548 {
549 case 4: 549 case 4:
550 buffer[0] = lo; 550 buffer[0] = lo;
@@ -552,7 +552,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
552 ret = 2; 552 ret = 2;
553 break; 553 break;
554 case 6: 554 case 6:
555 switch (state) 555 switch (state)
556 { 556 {
557 case 0: 557 case 0:
558 buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); 558 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
604 int shift=8-q->bpp; 604 int shift=8-q->bpp;
605 char invert; 605 char invert;
606 606
607 if (q->mode == -1) 607 if (q->mode == -1)
608 return -ENXIO; 608 return -ENXIO;
609 609
610 qc_command(q, 0x7); 610 qc_command(q, 0x7);
611 qc_command(q, q->mode); 611 qc_command(q, q->mode);
612 612
613 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) 613 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
614 { 614 {
615 write_lpcontrol(q, 0x2e); /* turn port around */ 615 write_lpcontrol(q, 0x2e); /* turn port around */
616 write_lpcontrol(q, 0x26); 616 write_lpcontrol(q, 0x26);
@@ -618,7 +618,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
618 write_lpcontrol(q, 0x2e); 618 write_lpcontrol(q, 0x2e);
619 (void) qc_waithand(q, 0); 619 (void) qc_waithand(q, 0);
620 } 620 }
621 621
622 /* strange -- should be 15:63 below, but 4bpp is odd */ 622 /* strange -- should be 15:63 below, but 4bpp is odd */
623 invert = (q->bpp == 4) ? 16 : 63; 623 invert = (q->bpp == 4) ? 16 : 63;
624 624
@@ -629,15 +629,15 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
629 q->transfer_scale; 629 q->transfer_scale;
630 transperline = (transperline + divisor - 1) / divisor; 630 transperline = (transperline + divisor - 1) / divisor;
631 631
632 for (i = 0, yield = yieldlines; i < linestotrans; i++) 632 for (i = 0, yield = yieldlines; i < linestotrans; i++)
633 { 633 {
634 for (pixels_read = j = 0; j < transperline; j++) 634 for (pixels_read = j = 0; j < transperline; j++)
635 { 635 {
636 bytes = qc_readbytes(q, buffer); 636 bytes = qc_readbytes(q, buffer);
637 for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) 637 for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++)
638 { 638 {
639 int o; 639 int o;
640 if (buffer[k] == 0 && invert == 16) 640 if (buffer[k] == 0 && invert == 16)
641 { 641 {
642 /* 4bpp is odd (again) -- inverter is 16, not 15, but output 642 /* 4bpp is odd (again) -- inverter is 16, not 15, but output
643 must be 0-15 -- bls */ 643 must be 0-15 -- bls */
@@ -653,7 +653,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
653 pixels_read += bytes; 653 pixels_read += bytes;
654 } 654 }
655 (void) qc_readbytes(q, NULL); /* reset state machine */ 655 (void) qc_readbytes(q, NULL); /* reset state machine */
656 656
657 /* Grabbing an entire frame from the quickcam is a lengthy 657 /* Grabbing an entire frame from the quickcam is a lengthy
658 process. We don't (usually) want to busy-block the 658 process. We don't (usually) want to busy-block the
659 processor for the entire frame. yieldlines is a module 659 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
666 } 666 }
667 } 667 }
668 668
669 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) 669 if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
670 { 670 {
671 write_lpcontrol(q, 2); 671 write_lpcontrol(q, 2);
672 write_lpcontrol(q, 6); 672 write_lpcontrol(q, 6);
@@ -687,7 +687,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
687{ 687{
688 struct video_device *dev = video_devdata(file); 688 struct video_device *dev = video_devdata(file);
689 struct qcam_device *qcam=(struct qcam_device *)dev; 689 struct qcam_device *qcam=(struct qcam_device *)dev;
690 690
691 switch(cmd) 691 switch(cmd)
692 { 692 {
693 case VIDIOCGCAP: 693 case VIDIOCGCAP:
@@ -762,7 +762,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
762 return -EINVAL; 762 return -EINVAL;
763 if(p->depth!=4 && p->depth!=6) 763 if(p->depth!=4 && p->depth!=6)
764 return -EINVAL; 764 return -EINVAL;
765 765
766 /* 766 /*
767 * Now load the camera. 767 * Now load the camera.
768 */ 768 */
@@ -790,11 +790,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
790 return -EINVAL; 790 return -EINVAL;
791 if(vw->width<80||vw->width>320) 791 if(vw->width<80||vw->width>320)
792 return -EINVAL; 792 return -EINVAL;
793 793
794 qcam->width = 320; 794 qcam->width = 320;
795 qcam->height = 240; 795 qcam->height = 240;
796 qcam->transfer_scale = 4; 796 qcam->transfer_scale = 4;
797 797
798 if(vw->width>=160 && vw->height>=120) 798 if(vw->width>=160 && vw->height>=120)
799 { 799 {
800 qcam->transfer_scale = 2; 800 qcam->transfer_scale = 2;
@@ -808,11 +808,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
808 mutex_lock(&qcam->lock); 808 mutex_lock(&qcam->lock);
809 qc_setscanmode(qcam); 809 qc_setscanmode(qcam);
810 mutex_unlock(&qcam->lock); 810 mutex_unlock(&qcam->lock);
811 811
812 /* We must update the camera before we grab. We could 812 /* We must update the camera before we grab. We could
813 just have changed the grab size */ 813 just have changed the grab size */
814 qcam->status |= QC_PARAM_CHANGE; 814 qcam->status |= QC_PARAM_CHANGE;
815 815
816 /* Ok we figured out what to use from our wide choice */ 816 /* Ok we figured out what to use from our wide choice */
817 return 0; 817 return 0;
818 } 818 }
@@ -853,9 +853,9 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
853 struct qcam_device *qcam=(struct qcam_device *)v; 853 struct qcam_device *qcam=(struct qcam_device *)v;
854 int len; 854 int len;
855 parport_claim_or_block(qcam->pdev); 855 parport_claim_or_block(qcam->pdev);
856 856
857 mutex_lock(&qcam->lock); 857 mutex_lock(&qcam->lock);
858 858
859 qc_reset(qcam); 859 qc_reset(qcam);
860 860
861 /* Update the camera parameters if we need to */ 861 /* Update the camera parameters if we need to */
@@ -863,13 +863,13 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
863 qc_set(qcam); 863 qc_set(qcam);
864 864
865 len=qc_capture(qcam, buf,count); 865 len=qc_capture(qcam, buf,count);
866 866
867 mutex_unlock(&qcam->lock); 867 mutex_unlock(&qcam->lock);
868 868
869 parport_release(qcam->pdev); 869 parport_release(qcam->pdev);
870 return len; 870 return len;
871} 871}
872 872
873static struct file_operations qcam_fops = { 873static struct file_operations qcam_fops = {
874 .owner = THIS_MODULE, 874 .owner = THIS_MODULE,
875 .open = video_exclusive_open, 875 .open = video_exclusive_open,
@@ -905,11 +905,11 @@ static int init_bwqcam(struct parport *port)
905 qcam=qcam_init(port); 905 qcam=qcam_init(port);
906 if(qcam==NULL) 906 if(qcam==NULL)
907 return -ENODEV; 907 return -ENODEV;
908 908
909 parport_claim_or_block(qcam->pdev); 909 parport_claim_or_block(qcam->pdev);
910 910
911 qc_reset(qcam); 911 qc_reset(qcam);
912 912
913 if(qc_detect(qcam)==0) 913 if(qc_detect(qcam)==0)
914 { 914 {
915 parport_release(qcam->pdev); 915 parport_release(qcam->pdev);
@@ -920,9 +920,9 @@ static int init_bwqcam(struct parport *port)
920 qc_calibrate(qcam); 920 qc_calibrate(qcam);
921 921
922 parport_release(qcam->pdev); 922 parport_release(qcam->pdev);
923 923
924 printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name); 924 printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name);
925 925
926 if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) 926 if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
927 { 927 {
928 parport_unregister_device(qcam->pdev); 928 parport_unregister_device(qcam->pdev);
@@ -1013,7 +1013,7 @@ static int __init init_bw_qcams(void)
1013 printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n"); 1013 printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n");
1014 maxpoll = 5000; 1014 maxpoll = 5000;
1015 } 1015 }
1016 1016
1017 if (yieldlines < 1) { 1017 if (yieldlines < 1) {
1018 printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n"); 1018 printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n");
1019 yieldlines = 1; 1019 yieldlines = 1;
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 8211fd8d7cbf..22a7386bbea6 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -16,7 +16,7 @@
16 * 16 *
17 * The parport parameter controls which parports will be scanned. 17 * The parport parameter controls which parports will be scanned.
18 * Scanning all parports causes some printers to print a garbage page. 18 * Scanning all parports causes some printers to print a garbage page.
19 * -- March 14, 1999 Billy Donahue <billy@escape.com> 19 * -- March 14, 1999 Billy Donahue <billy@escape.com>
20 * 20 *
21 * Fixed data format to BGR, added force_rgb parameter. Added missing 21 * Fixed data format to BGR, added force_rgb parameter. Added missing
22 * parport_unregister_driver() on module removal. 22 * parport_unregister_driver() on module removal.
@@ -88,7 +88,7 @@ static inline unsigned int qcam_ready2(struct qcam_device *qcam)
88 return (parport_read_data(qcam->pport) & 0x1)?1:0; 88 return (parport_read_data(qcam->pport) & 0x1)?1:0;
89} 89}
90 90
91static unsigned int qcam_await_ready1(struct qcam_device *qcam, 91static unsigned int qcam_await_ready1(struct qcam_device *qcam,
92 int value) 92 int value)
93{ 93{
94 unsigned long oldjiffies = jiffies; 94 unsigned long oldjiffies = jiffies;
@@ -98,7 +98,7 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam,
98 if (qcam_ready1(qcam) == value) 98 if (qcam_ready1(qcam) == value)
99 return 0; 99 return 0;
100 100
101 /* If the camera didn't respond within 1/25 second, poll slowly 101 /* If the camera didn't respond within 1/25 second, poll slowly
102 for a while. */ 102 for a while. */
103 for (i = 0; i < 50; i++) 103 for (i = 0; i < 50; i++)
104 { 104 {
@@ -123,7 +123,7 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
123 if (qcam_ready2(qcam) == value) 123 if (qcam_ready2(qcam) == value)
124 return 0; 124 return 0;
125 125
126 /* If the camera didn't respond within 1/25 second, poll slowly 126 /* If the camera didn't respond within 1/25 second, poll slowly
127 for a while. */ 127 for a while. */
128 for (i = 0; i < 50; i++) 128 for (i = 0; i < 50; i++)
129 { 129 {
@@ -157,12 +157,12 @@ static int qcam_write_data(struct qcam_device *qcam, unsigned int data)
157 unsigned int idata; 157 unsigned int idata;
158 parport_write_data(qcam->pport, data); 158 parport_write_data(qcam->pport, data);
159 idata = qcam_read_data(qcam); 159 idata = qcam_read_data(qcam);
160 if (data != idata) 160 if (data != idata)
161 { 161 {
162 printk(KERN_WARNING "cqcam: sent %x but received %x\n", data, 162 printk(KERN_WARNING "cqcam: sent %x but received %x\n", data,
163 idata); 163 idata);
164 return 1; 164 return 1;
165 } 165 }
166 return 0; 166 return 0;
167} 167}
168 168
@@ -193,12 +193,12 @@ static int qc_detect(struct qcam_device *qcam)
193 no device was found". Fix this one day. */ 193 no device was found". Fix this one day. */
194 if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA 194 if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA
195 && qcam->pport->probe_info[0].model 195 && qcam->pport->probe_info[0].model
196 && !strcmp(qcam->pdev->port->probe_info[0].model, 196 && !strcmp(qcam->pdev->port->probe_info[0].model,
197 "Color QuickCam 2.0")) { 197 "Color QuickCam 2.0")) {
198 printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n"); 198 printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n");
199 return 1; 199 return 1;
200 } 200 }
201 201
202 if (probe < 2) 202 if (probe < 2)
203 return 0; 203 return 0;
204 204
@@ -206,11 +206,11 @@ static int qc_detect(struct qcam_device *qcam)
206 206
207 /* look for a heartbeat */ 207 /* look for a heartbeat */
208 ostat = stat = parport_read_status(qcam->pport); 208 ostat = stat = parport_read_status(qcam->pport);
209 for (i=0; i<250; i++) 209 for (i=0; i<250; i++)
210 { 210 {
211 mdelay(1); 211 mdelay(1);
212 stat = parport_read_status(qcam->pport); 212 stat = parport_read_status(qcam->pport);
213 if (ostat != stat) 213 if (ostat != stat)
214 { 214 {
215 if (++count >= 3) return 1; 215 if (++count >= 3) return 1;
216 ostat = stat; 216 ostat = stat;
@@ -226,11 +226,11 @@ static int qc_detect(struct qcam_device *qcam)
226 count = 0; 226 count = 0;
227 227
228 ostat = stat = parport_read_status(qcam->pport); 228 ostat = stat = parport_read_status(qcam->pport);
229 for (i=0; i<250; i++) 229 for (i=0; i<250; i++)
230 { 230 {
231 mdelay(1); 231 mdelay(1);
232 stat = parport_read_status(qcam->pport); 232 stat = parport_read_status(qcam->pport);
233 if (ostat != stat) 233 if (ostat != stat)
234 { 234 {
235 if (++count >= 3) return 1; 235 if (++count >= 3) return 1;
236 ostat = stat; 236 ostat = stat;
@@ -247,7 +247,7 @@ static void qc_reset(struct qcam_device *qcam)
247 parport_write_control(qcam->pport, 0x8); 247 parport_write_control(qcam->pport, 0x8);
248 mdelay(1); 248 mdelay(1);
249 parport_write_control(qcam->pport, 0xc); 249 parport_write_control(qcam->pport, 0xc);
250 mdelay(1); 250 mdelay(1);
251} 251}
252 252
253/* Reset the QuickCam and program for brightness, contrast, 253/* Reset the QuickCam and program for brightness, contrast,
@@ -258,7 +258,7 @@ static void qc_setup(struct qcam_device *q)
258 qc_reset(q); 258 qc_reset(q);
259 259
260 /* Set the brightness. */ 260 /* Set the brightness. */
261 qcam_set(q, 11, q->brightness); 261 qcam_set(q, 11, q->brightness);
262 262
263 /* Set the height and width. These refer to the actual 263 /* Set the height and width. These refer to the actual
264 CCD area *before* applying the selected decimation. */ 264 CCD area *before* applying the selected decimation. */
@@ -272,12 +272,12 @@ static void qc_setup(struct qcam_device *q)
272 /* Set contrast and white balance. */ 272 /* Set contrast and white balance. */
273 qcam_set(q, 0x19, q->contrast); 273 qcam_set(q, 0x19, q->contrast);
274 qcam_set(q, 0x1f, q->whitebal); 274 qcam_set(q, 0x1f, q->whitebal);
275 275
276 /* Set the speed. */ 276 /* Set the speed. */
277 qcam_set(q, 45, 2); 277 qcam_set(q, 45, 2);
278} 278}
279 279
280/* Read some bytes from the camera and put them in the buffer. 280/* Read some bytes from the camera and put them in the buffer.
281 nbytes should be a multiple of 3, because bidirectional mode gives 281 nbytes should be a multiple of 3, because bidirectional mode gives
282 us three bytes at a time. */ 282 us three bytes at a time. */
283 283
@@ -383,7 +383,7 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
383 383
384 if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1)) 384 if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1))
385 return -EIO; 385 return -EIO;
386 386
387 lines = q->height; 387 lines = q->height;
388 pixelsperline = q->width; 388 pixelsperline = q->width;
389 bitsperxfer = (is_bi_dir) ? 24 : 8; 389 bitsperxfer = (is_bi_dir) ? 24 : 8;
@@ -499,7 +499,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
499{ 499{
500 struct video_device *dev = video_devdata(file); 500 struct video_device *dev = video_devdata(file);
501 struct qcam_device *qcam=(struct qcam_device *)dev; 501 struct qcam_device *qcam=(struct qcam_device *)dev;
502 502
503 switch(cmd) 503 switch(cmd)
504 { 504 {
505 case VIDIOCGCAP: 505 case VIDIOCGCAP:
@@ -574,7 +574,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
574 */ 574 */
575 if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24) 575 if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
576 return -EINVAL; 576 return -EINVAL;
577 577
578 /* 578 /*
579 * Now load the camera. 579 * Now load the camera.
580 */ 580 */
@@ -584,7 +584,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
584 584
585 mutex_lock(&qcam->lock); 585 mutex_lock(&qcam->lock);
586 parport_claim_or_block(qcam->pdev); 586 parport_claim_or_block(qcam->pdev);
587 qc_setup(qcam); 587 qc_setup(qcam);
588 parport_release(qcam->pdev); 588 parport_release(qcam->pdev);
589 mutex_unlock(&qcam->lock); 589 mutex_unlock(&qcam->lock);
590 return 0; 590 return 0;
@@ -601,11 +601,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
601 return -EINVAL; 601 return -EINVAL;
602 if(vw->width<80||vw->width>320) 602 if(vw->width<80||vw->width>320)
603 return -EINVAL; 603 return -EINVAL;
604 604
605 qcam->width = 80; 605 qcam->width = 80;
606 qcam->height = 60; 606 qcam->height = 60;
607 qcam->mode = QC_DECIMATION_4; 607 qcam->mode = QC_DECIMATION_4;
608 608
609 if(vw->width>=160 && vw->height>=120) 609 if(vw->width>=160 && vw->height>=120)
610 { 610 {
611 qcam->width = 160; 611 qcam->width = 160;
@@ -627,7 +627,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
627 qcam->mode = QC_BILLIONS | QC_DECIMATION_1; 627 qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
628 } 628 }
629#endif 629#endif
630 /* Ok we figured out what to use from our 630 /* Ok we figured out what to use from our
631 wide choice */ 631 wide choice */
632 mutex_lock(&qcam->lock); 632 mutex_lock(&qcam->lock);
633 parport_claim_or_block(qcam->pdev); 633 parport_claim_or_block(qcam->pdev);
@@ -676,7 +676,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
676 mutex_lock(&qcam->lock); 676 mutex_lock(&qcam->lock);
677 parport_claim_or_block(qcam->pdev); 677 parport_claim_or_block(qcam->pdev);
678 /* Probably should have a semaphore against multiple users */ 678 /* Probably should have a semaphore against multiple users */
679 len = qc_capture(qcam, buf,count); 679 len = qc_capture(qcam, buf,count);
680 parport_release(qcam->pdev); 680 parport_release(qcam->pdev);
681 mutex_unlock(&qcam->lock); 681 mutex_unlock(&qcam->lock);
682 return len; 682 return len;
@@ -707,7 +707,7 @@ static struct video_device qcam_template=
707static struct qcam_device *qcam_init(struct parport *port) 707static struct qcam_device *qcam_init(struct parport *port)
708{ 708{
709 struct qcam_device *q; 709 struct qcam_device *q;
710 710
711 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL); 711 q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
712 if(q==NULL) 712 if(q==NULL)
713 return NULL; 713 return NULL;
@@ -718,14 +718,14 @@ static struct qcam_device *qcam_init(struct parport *port)
718 718
719 q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0; 719 q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0;
720 720
721 if (q->pdev == NULL) 721 if (q->pdev == NULL)
722 { 722 {
723 printk(KERN_ERR "c-qcam: couldn't register for %s.\n", 723 printk(KERN_ERR "c-qcam: couldn't register for %s.\n",
724 port->name); 724 port->name);
725 kfree(q); 725 kfree(q);
726 return NULL; 726 return NULL;
727 } 727 }
728 728
729 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); 729 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
730 730
731 mutex_init(&q->lock); 731 mutex_init(&q->lock);
@@ -766,11 +766,11 @@ static int init_cqcam(struct parport *port)
766 qcam = qcam_init(port); 766 qcam = qcam_init(port);
767 if (qcam==NULL) 767 if (qcam==NULL)
768 return -ENODEV; 768 return -ENODEV;
769 769
770 parport_claim_or_block(qcam->pdev); 770 parport_claim_or_block(qcam->pdev);
771 771
772 qc_reset(qcam); 772 qc_reset(qcam);
773 773
774 if (probe && qc_detect(qcam)==0) 774 if (probe && qc_detect(qcam)==0)
775 { 775 {
776 parport_release(qcam->pdev); 776 parport_release(qcam->pdev);
@@ -782,7 +782,7 @@ static int init_cqcam(struct parport *port)
782 qc_setup(qcam); 782 qc_setup(qcam);
783 783
784 parport_release(qcam->pdev); 784 parport_release(qcam->pdev);
785 785
786 if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) 786 if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
787 { 787 {
788 printk(KERN_ERR "Unable to register Colour QuickCam on %s\n", 788 printk(KERN_ERR "Unable to register Colour QuickCam on %s\n",
@@ -792,9 +792,9 @@ static int init_cqcam(struct parport *port)
792 return -ENODEV; 792 return -ENODEV;
793 } 793 }
794 794
795 printk(KERN_INFO "video%d: Colour QuickCam found on %s\n", 795 printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
796 qcam->vdev.minor, qcam->pport->name); 796 qcam->vdev.minor, qcam->pport->name);
797 797
798 qcams[num_cams++] = qcam; 798 qcams[num_cams++] = qcam;
799 799
800 return 0; 800 return 0;
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 3cebfa91ca14..2227c5640c12 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 26/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
27/* #define _CPIA_DEBUG_ 1 */ 27/* #define _CPIA_DEBUG_ 1 */
28 28
29#include <linux/config.h> 29#include <linux/config.h>
30 30
@@ -67,11 +67,11 @@ MODULE_SUPPORTED_DEVICE("video");
67static unsigned short colorspace_conv = 0; 67static unsigned short colorspace_conv = 0;
68module_param(colorspace_conv, ushort, 0444); 68module_param(colorspace_conv, ushort, 0444);
69MODULE_PARM_DESC(colorspace_conv, 69MODULE_PARM_DESC(colorspace_conv,
70 "\n<n> Colorspace conversion:" 70 "\n<n> Colorspace conversion:"
71 "\n0 = disable" 71 "\n0 = disable"
72 "\n1 = enable" 72 "\n1 = enable"
73 "\nDefault value is 0" 73 "\nDefault value is 0"
74 "\n"); 74 "\n");
75 75
76#define ABOUT "V4L-Driver for Vision CPiA based cameras" 76#define ABOUT "V4L-Driver for Vision CPiA based cameras"
77 77
@@ -189,8 +189,8 @@ enum {
189#define TC 94 189#define TC 94
190#define EXP_ACC_DARK 50 190#define EXP_ACC_DARK 50
191#define EXP_ACC_LIGHT 90 191#define EXP_ACC_LIGHT 90
192#define HIGH_COMP_102 160 192#define HIGH_COMP_102 160
193#define MAX_COMP 239 193#define MAX_COMP 239
194#define DARK_TIME 3 194#define DARK_TIME 3
195#define LIGHT_TIME 3 195#define LIGHT_TIME 3
196 196
@@ -208,7 +208,7 @@ static u8 flicker_jumps[2][2][4] =
208static void reset_camera_struct(struct cam_data *cam); 208static void reset_camera_struct(struct cam_data *cam);
209static int find_over_exposure(int brightness); 209static int find_over_exposure(int brightness);
210static void set_flicker(struct cam_params *params, volatile u32 *command_flags, 210static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
211 int on); 211 int on);
212 212
213 213
214/********************************************************************** 214/**********************************************************************
@@ -262,7 +262,7 @@ static void rvfree(void *mem, unsigned long size)
262static struct proc_dir_entry *cpia_proc_root=NULL; 262static struct proc_dir_entry *cpia_proc_root=NULL;
263 263
264static int cpia_read_proc(char *page, char **start, off_t off, 264static int cpia_read_proc(char *page, char **start, off_t off,
265 int count, int *eof, void *data) 265 int count, int *eof, void *data)
266{ 266{
267 char *out = page; 267 char *out = page;
268 int len, tmp; 268 int len, tmp;
@@ -276,58 +276,58 @@ static int cpia_read_proc(char *page, char **start, off_t off,
276 out += sprintf(out, "V4L Driver version: %d.%d.%d\n", 276 out += sprintf(out, "V4L Driver version: %d.%d.%d\n",
277 CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER); 277 CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER);
278 out += sprintf(out, "CPIA Version: %d.%02d (%d.%d)\n", 278 out += sprintf(out, "CPIA Version: %d.%02d (%d.%d)\n",
279 cam->params.version.firmwareVersion, 279 cam->params.version.firmwareVersion,
280 cam->params.version.firmwareRevision, 280 cam->params.version.firmwareRevision,
281 cam->params.version.vcVersion, 281 cam->params.version.vcVersion,
282 cam->params.version.vcRevision); 282 cam->params.version.vcRevision);
283 out += sprintf(out, "CPIA PnP-ID: %04x:%04x:%04x\n", 283 out += sprintf(out, "CPIA PnP-ID: %04x:%04x:%04x\n",
284 cam->params.pnpID.vendor, cam->params.pnpID.product, 284 cam->params.pnpID.vendor, cam->params.pnpID.product,
285 cam->params.pnpID.deviceRevision); 285 cam->params.pnpID.deviceRevision);
286 out += sprintf(out, "VP-Version: %d.%d %04x\n", 286 out += sprintf(out, "VP-Version: %d.%d %04x\n",
287 cam->params.vpVersion.vpVersion, 287 cam->params.vpVersion.vpVersion,
288 cam->params.vpVersion.vpRevision, 288 cam->params.vpVersion.vpRevision,
289 cam->params.vpVersion.cameraHeadID); 289 cam->params.vpVersion.cameraHeadID);
290 290
291 out += sprintf(out, "system_state: %#04x\n", 291 out += sprintf(out, "system_state: %#04x\n",
292 cam->params.status.systemState); 292 cam->params.status.systemState);
293 out += sprintf(out, "grab_state: %#04x\n", 293 out += sprintf(out, "grab_state: %#04x\n",
294 cam->params.status.grabState); 294 cam->params.status.grabState);
295 out += sprintf(out, "stream_state: %#04x\n", 295 out += sprintf(out, "stream_state: %#04x\n",
296 cam->params.status.streamState); 296 cam->params.status.streamState);
297 out += sprintf(out, "fatal_error: %#04x\n", 297 out += sprintf(out, "fatal_error: %#04x\n",
298 cam->params.status.fatalError); 298 cam->params.status.fatalError);
299 out += sprintf(out, "cmd_error: %#04x\n", 299 out += sprintf(out, "cmd_error: %#04x\n",
300 cam->params.status.cmdError); 300 cam->params.status.cmdError);
301 out += sprintf(out, "debug_flags: %#04x\n", 301 out += sprintf(out, "debug_flags: %#04x\n",
302 cam->params.status.debugFlags); 302 cam->params.status.debugFlags);
303 out += sprintf(out, "vp_status: %#04x\n", 303 out += sprintf(out, "vp_status: %#04x\n",
304 cam->params.status.vpStatus); 304 cam->params.status.vpStatus);
305 out += sprintf(out, "error_code: %#04x\n", 305 out += sprintf(out, "error_code: %#04x\n",
306 cam->params.status.errorCode); 306 cam->params.status.errorCode);
307 /* QX3 specific entries */ 307 /* QX3 specific entries */
308 if (cam->params.qx3.qx3_detected) { 308 if (cam->params.qx3.qx3_detected) {
309 out += sprintf(out, "button: %4d\n", 309 out += sprintf(out, "button: %4d\n",
310 cam->params.qx3.button); 310 cam->params.qx3.button);
311 out += sprintf(out, "cradled: %4d\n", 311 out += sprintf(out, "cradled: %4d\n",
312 cam->params.qx3.cradled); 312 cam->params.qx3.cradled);
313 } 313 }
314 out += sprintf(out, "video_size: %s\n", 314 out += sprintf(out, "video_size: %s\n",
315 cam->params.format.videoSize == VIDEOSIZE_CIF ? 315 cam->params.format.videoSize == VIDEOSIZE_CIF ?
316 "CIF " : "QCIF"); 316 "CIF " : "QCIF");
317 out += sprintf(out, "roi: (%3d, %3d) to (%3d, %3d)\n", 317 out += sprintf(out, "roi: (%3d, %3d) to (%3d, %3d)\n",
318 cam->params.roi.colStart*8, 318 cam->params.roi.colStart*8,
319 cam->params.roi.rowStart*4, 319 cam->params.roi.rowStart*4,
320 cam->params.roi.colEnd*8, 320 cam->params.roi.colEnd*8,
321 cam->params.roi.rowEnd*4); 321 cam->params.roi.rowEnd*4);
322 out += sprintf(out, "actual_fps: %3d\n", cam->fps); 322 out += sprintf(out, "actual_fps: %3d\n", cam->fps);
323 out += sprintf(out, "transfer_rate: %4dkB/s\n", 323 out += sprintf(out, "transfer_rate: %4dkB/s\n",
324 cam->transfer_rate); 324 cam->transfer_rate);
325 325
326 out += sprintf(out, "\nread-write\n"); 326 out += sprintf(out, "\nread-write\n");
327 out += sprintf(out, "----------------------- current min" 327 out += sprintf(out, "----------------------- current min"
328 " max default comment\n"); 328 " max default comment\n");
329 out += sprintf(out, "brightness: %8d %8d %8d %8d\n", 329 out += sprintf(out, "brightness: %8d %8d %8d %8d\n",
330 cam->params.colourParams.brightness, 0, 100, 50); 330 cam->params.colourParams.brightness, 0, 100, 50);
331 if (cam->params.version.firmwareVersion == 1 && 331 if (cam->params.version.firmwareVersion == 1 &&
332 cam->params.version.firmwareRevision == 2) 332 cam->params.version.firmwareRevision == 2)
333 /* 1-02 firmware limits contrast to 80 */ 333 /* 1-02 firmware limits contrast to 80 */
@@ -336,26 +336,26 @@ static int cpia_read_proc(char *page, char **start, off_t off,
336 tmp = 96; 336 tmp = 96;
337 337
338 out += sprintf(out, "contrast: %8d %8d %8d %8d" 338 out += sprintf(out, "contrast: %8d %8d %8d %8d"
339 " steps of 8\n", 339 " steps of 8\n",
340 cam->params.colourParams.contrast, 0, tmp, 48); 340 cam->params.colourParams.contrast, 0, tmp, 48);
341 out += sprintf(out, "saturation: %8d %8d %8d %8d\n", 341 out += sprintf(out, "saturation: %8d %8d %8d %8d\n",
342 cam->params.colourParams.saturation, 0, 100, 50); 342 cam->params.colourParams.saturation, 0, 100, 50);
343 tmp = (25000+5000*cam->params.sensorFps.baserate)/ 343 tmp = (25000+5000*cam->params.sensorFps.baserate)/
344 (1<<cam->params.sensorFps.divisor); 344 (1<<cam->params.sensorFps.divisor);
345 out += sprintf(out, "sensor_fps: %4d.%03d %8d %8d %8d\n", 345 out += sprintf(out, "sensor_fps: %4d.%03d %8d %8d %8d\n",
346 tmp/1000, tmp%1000, 3, 30, 15); 346 tmp/1000, tmp%1000, 3, 30, 15);
347 out += sprintf(out, "stream_start_line: %8d %8d %8d %8d\n", 347 out += sprintf(out, "stream_start_line: %8d %8d %8d %8d\n",
348 2*cam->params.streamStartLine, 0, 348 2*cam->params.streamStartLine, 0,
349 cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144, 349 cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144,
350 cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120); 350 cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120);
351 out += sprintf(out, "sub_sample: %8s %8s %8s %8s\n", 351 out += sprintf(out, "sub_sample: %8s %8s %8s %8s\n",
352 cam->params.format.subSample == SUBSAMPLE_420 ? 352 cam->params.format.subSample == SUBSAMPLE_420 ?
353 "420" : "422", "420", "422", "422"); 353 "420" : "422", "420", "422", "422");
354 out += sprintf(out, "yuv_order: %8s %8s %8s %8s\n", 354 out += sprintf(out, "yuv_order: %8s %8s %8s %8s\n",
355 cam->params.format.yuvOrder == YUVORDER_YUYV ? 355 cam->params.format.yuvOrder == YUVORDER_YUYV ?
356 "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV"); 356 "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV");
357 out += sprintf(out, "ecp_timing: %8s %8s %8s %8s\n", 357 out += sprintf(out, "ecp_timing: %8s %8s %8s %8s\n",
358 cam->params.ecpTiming ? "slow" : "normal", "slow", 358 cam->params.ecpTiming ? "slow" : "normal", "slow",
359 "normal", "normal"); 359 "normal", "normal");
360 360
361 if (cam->params.colourBalance.balanceMode == 2) { 361 if (cam->params.colourBalance.balanceMode == 2) {
@@ -366,11 +366,11 @@ static int cpia_read_proc(char *page, char **start, off_t off,
366 out += sprintf(out, "color_balance_mode: %8s %8s %8s" 366 out += sprintf(out, "color_balance_mode: %8s %8s %8s"
367 " %8s\n", tmpstr, "manual", "auto", "auto"); 367 " %8s\n", tmpstr, "manual", "auto", "auto");
368 out += sprintf(out, "red_gain: %8d %8d %8d %8d\n", 368 out += sprintf(out, "red_gain: %8d %8d %8d %8d\n",
369 cam->params.colourBalance.redGain, 0, 212, 32); 369 cam->params.colourBalance.redGain, 0, 212, 32);
370 out += sprintf(out, "green_gain: %8d %8d %8d %8d\n", 370 out += sprintf(out, "green_gain: %8d %8d %8d %8d\n",
371 cam->params.colourBalance.greenGain, 0, 212, 6); 371 cam->params.colourBalance.greenGain, 0, 212, 6);
372 out += sprintf(out, "blue_gain: %8d %8d %8d %8d\n", 372 out += sprintf(out, "blue_gain: %8d %8d %8d %8d\n",
373 cam->params.colourBalance.blueGain, 0, 212, 92); 373 cam->params.colourBalance.blueGain, 0, 212, 92);
374 374
375 if (cam->params.version.firmwareVersion == 1 && 375 if (cam->params.version.firmwareVersion == 1 &&
376 cam->params.version.firmwareRevision == 2) 376 cam->params.version.firmwareRevision == 2)
@@ -381,11 +381,11 @@ static int cpia_read_proc(char *page, char **start, off_t off,
381 381
382 if (cam->params.exposure.gainMode == 0) 382 if (cam->params.exposure.gainMode == 0)
383 out += sprintf(out, "max_gain: unknown %28s" 383 out += sprintf(out, "max_gain: unknown %28s"
384 " powers of 2\n", tmpstr); 384 " powers of 2\n", tmpstr);
385 else 385 else
386 out += sprintf(out, "max_gain: %8d %28s" 386 out += sprintf(out, "max_gain: %8d %28s"
387 " 1,2,4 or 8 \n", 387 " 1,2,4 or 8 \n",
388 1<<(cam->params.exposure.gainMode-1), tmpstr); 388 1<<(cam->params.exposure.gainMode-1), tmpstr);
389 389
390 switch(cam->params.exposure.expMode) { 390 switch(cam->params.exposure.expMode) {
391 case 1: 391 case 1:
@@ -402,10 +402,10 @@ static int cpia_read_proc(char *page, char **start, off_t off,
402 out += sprintf(out, "exposure_mode: %8s %8s %8s" 402 out += sprintf(out, "exposure_mode: %8s %8s %8s"
403 " %8s\n", tmpstr, "manual", "auto", "auto"); 403 " %8s\n", tmpstr, "manual", "auto", "auto");
404 out += sprintf(out, "centre_weight: %8s %8s %8s %8s\n", 404 out += sprintf(out, "centre_weight: %8s %8s %8s %8s\n",
405 (2-cam->params.exposure.centreWeight) ? "on" : "off", 405 (2-cam->params.exposure.centreWeight) ? "on" : "off",
406 "off", "on", "on"); 406 "off", "on", "on");
407 out += sprintf(out, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n", 407 out += sprintf(out, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n",
408 1<<cam->params.exposure.gain, 1, 1); 408 1<<cam->params.exposure.gain, 1, 1);
409 if (cam->params.version.firmwareVersion == 1 && 409 if (cam->params.version.firmwareVersion == 1 &&
410 cam->params.version.firmwareRevision == 2) 410 cam->params.version.firmwareRevision == 2)
411 /* 1-02 firmware limits fineExp/2 to 127 */ 411 /* 1-02 firmware limits fineExp/2 to 127 */
@@ -414,7 +414,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
414 tmp = 510; 414 tmp = 510;
415 415
416 out += sprintf(out, "fine_exp: %8d %8d %8d %8d\n", 416 out += sprintf(out, "fine_exp: %8d %8d %8d %8d\n",
417 cam->params.exposure.fineExp*2, 0, tmp, 0); 417 cam->params.exposure.fineExp*2, 0, tmp, 0);
418 if (cam->params.version.firmwareVersion == 1 && 418 if (cam->params.version.firmwareVersion == 1 &&
419 cam->params.version.firmwareRevision == 2) 419 cam->params.version.firmwareRevision == 2)
420 /* 1-02 firmware limits coarseExpHi to 0 */ 420 /* 1-02 firmware limits coarseExpHi to 0 */
@@ -426,46 +426,46 @@ static int cpia_read_proc(char *page, char **start, off_t off,
426 " %8d\n", cam->params.exposure.coarseExpLo+ 426 " %8d\n", cam->params.exposure.coarseExpLo+
427 256*cam->params.exposure.coarseExpHi, 0, tmp, 185); 427 256*cam->params.exposure.coarseExpHi, 0, tmp, 185);
428 out += sprintf(out, "red_comp: %8d %8d %8d %8d\n", 428 out += sprintf(out, "red_comp: %8d %8d %8d %8d\n",
429 cam->params.exposure.redComp, COMP_RED, 255, COMP_RED); 429 cam->params.exposure.redComp, COMP_RED, 255, COMP_RED);
430 out += sprintf(out, "green1_comp: %8d %8d %8d %8d\n", 430 out += sprintf(out, "green1_comp: %8d %8d %8d %8d\n",
431 cam->params.exposure.green1Comp, COMP_GREEN1, 255, 431 cam->params.exposure.green1Comp, COMP_GREEN1, 255,
432 COMP_GREEN1); 432 COMP_GREEN1);
433 out += sprintf(out, "green2_comp: %8d %8d %8d %8d\n", 433 out += sprintf(out, "green2_comp: %8d %8d %8d %8d\n",
434 cam->params.exposure.green2Comp, COMP_GREEN2, 255, 434 cam->params.exposure.green2Comp, COMP_GREEN2, 255,
435 COMP_GREEN2); 435 COMP_GREEN2);
436 out += sprintf(out, "blue_comp: %8d %8d %8d %8d\n", 436 out += sprintf(out, "blue_comp: %8d %8d %8d %8d\n",
437 cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE); 437 cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE);
438 438
439 out += sprintf(out, "apcor_gain1: %#8x %#8x %#8x %#8x\n", 439 out += sprintf(out, "apcor_gain1: %#8x %#8x %#8x %#8x\n",
440 cam->params.apcor.gain1, 0, 0xff, 0x1c); 440 cam->params.apcor.gain1, 0, 0xff, 0x1c);
441 out += sprintf(out, "apcor_gain2: %#8x %#8x %#8x %#8x\n", 441 out += sprintf(out, "apcor_gain2: %#8x %#8x %#8x %#8x\n",
442 cam->params.apcor.gain2, 0, 0xff, 0x1a); 442 cam->params.apcor.gain2, 0, 0xff, 0x1a);
443 out += sprintf(out, "apcor_gain4: %#8x %#8x %#8x %#8x\n", 443 out += sprintf(out, "apcor_gain4: %#8x %#8x %#8x %#8x\n",
444 cam->params.apcor.gain4, 0, 0xff, 0x2d); 444 cam->params.apcor.gain4, 0, 0xff, 0x2d);
445 out += sprintf(out, "apcor_gain8: %#8x %#8x %#8x %#8x\n", 445 out += sprintf(out, "apcor_gain8: %#8x %#8x %#8x %#8x\n",
446 cam->params.apcor.gain8, 0, 0xff, 0x2a); 446 cam->params.apcor.gain8, 0, 0xff, 0x2a);
447 out += sprintf(out, "vl_offset_gain1: %8d %8d %8d %8d\n", 447 out += sprintf(out, "vl_offset_gain1: %8d %8d %8d %8d\n",
448 cam->params.vlOffset.gain1, 0, 255, 24); 448 cam->params.vlOffset.gain1, 0, 255, 24);
449 out += sprintf(out, "vl_offset_gain2: %8d %8d %8d %8d\n", 449 out += sprintf(out, "vl_offset_gain2: %8d %8d %8d %8d\n",
450 cam->params.vlOffset.gain2, 0, 255, 28); 450 cam->params.vlOffset.gain2, 0, 255, 28);
451 out += sprintf(out, "vl_offset_gain4: %8d %8d %8d %8d\n", 451 out += sprintf(out, "vl_offset_gain4: %8d %8d %8d %8d\n",
452 cam->params.vlOffset.gain4, 0, 255, 30); 452 cam->params.vlOffset.gain4, 0, 255, 30);
453 out += sprintf(out, "vl_offset_gain8: %8d %8d %8d %8d\n", 453 out += sprintf(out, "vl_offset_gain8: %8d %8d %8d %8d\n",
454 cam->params.vlOffset.gain8, 0, 255, 30); 454 cam->params.vlOffset.gain8, 0, 255, 30);
455 out += sprintf(out, "flicker_control: %8s %8s %8s %8s\n", 455 out += sprintf(out, "flicker_control: %8s %8s %8s %8s\n",
456 cam->params.flickerControl.flickerMode ? "on" : "off", 456 cam->params.flickerControl.flickerMode ? "on" : "off",
457 "off", "on", "off"); 457 "off", "on", "off");
458 out += sprintf(out, "mains_frequency: %8d %8d %8d %8d" 458 out += sprintf(out, "mains_frequency: %8d %8d %8d %8d"
459 " only 50/60\n", 459 " only 50/60\n",
460 cam->mainsFreq ? 60 : 50, 50, 60, 50); 460 cam->mainsFreq ? 60 : 50, 50, 60, 50);
461 if(cam->params.flickerControl.allowableOverExposure < 0) 461 if(cam->params.flickerControl.allowableOverExposure < 0)
462 out += sprintf(out, "allowable_overexposure: %4dauto auto %8d auto\n", 462 out += sprintf(out, "allowable_overexposure: %4dauto auto %8d auto\n",
463 -cam->params.flickerControl.allowableOverExposure, 463 -cam->params.flickerControl.allowableOverExposure,
464 255); 464 255);
465 else 465 else
466 out += sprintf(out, "allowable_overexposure: %8d auto %8d auto\n", 466 out += sprintf(out, "allowable_overexposure: %8d auto %8d auto\n",
467 cam->params.flickerControl.allowableOverExposure, 467 cam->params.flickerControl.allowableOverExposure,
468 255); 468 255);
469 out += sprintf(out, "compression_mode: "); 469 out += sprintf(out, "compression_mode: ");
470 switch(cam->params.compression.mode) { 470 switch(cam->params.compression.mode) {
471 case CPIA_COMPRESSION_NONE: 471 case CPIA_COMPRESSION_NONE:
@@ -483,52 +483,52 @@ static int cpia_read_proc(char *page, char **start, off_t off,
483 } 483 }
484 out += sprintf(out, " none,auto,manual auto\n"); 484 out += sprintf(out, " none,auto,manual auto\n");
485 out += sprintf(out, "decimation_enable: %8s %8s %8s %8s\n", 485 out += sprintf(out, "decimation_enable: %8s %8s %8s %8s\n",
486 cam->params.compression.decimation == 486 cam->params.compression.decimation ==
487 DECIMATION_ENAB ? "on":"off", "off", "on", 487 DECIMATION_ENAB ? "on":"off", "off", "on",
488 "off"); 488 "off");
489 out += sprintf(out, "compression_target: %9s %9s %9s %9s\n", 489 out += sprintf(out, "compression_target: %9s %9s %9s %9s\n",
490 cam->params.compressionTarget.frTargeting == 490 cam->params.compressionTarget.frTargeting ==
491 CPIA_COMPRESSION_TARGET_FRAMERATE ? 491 CPIA_COMPRESSION_TARGET_FRAMERATE ?
492 "framerate":"quality", 492 "framerate":"quality",
493 "framerate", "quality", "quality"); 493 "framerate", "quality", "quality");
494 out += sprintf(out, "target_framerate: %8d %8d %8d %8d\n", 494 out += sprintf(out, "target_framerate: %8d %8d %8d %8d\n",
495 cam->params.compressionTarget.targetFR, 1, 30, 15); 495 cam->params.compressionTarget.targetFR, 1, 30, 15);
496 out += sprintf(out, "target_quality: %8d %8d %8d %8d\n", 496 out += sprintf(out, "target_quality: %8d %8d %8d %8d\n",
497 cam->params.compressionTarget.targetQ, 1, 64, 5); 497 cam->params.compressionTarget.targetQ, 1, 64, 5);
498 out += sprintf(out, "y_threshold: %8d %8d %8d %8d\n", 498 out += sprintf(out, "y_threshold: %8d %8d %8d %8d\n",
499 cam->params.yuvThreshold.yThreshold, 0, 31, 6); 499 cam->params.yuvThreshold.yThreshold, 0, 31, 6);
500 out += sprintf(out, "uv_threshold: %8d %8d %8d %8d\n", 500 out += sprintf(out, "uv_threshold: %8d %8d %8d %8d\n",
501 cam->params.yuvThreshold.uvThreshold, 0, 31, 6); 501 cam->params.yuvThreshold.uvThreshold, 0, 31, 6);
502 out += sprintf(out, "hysteresis: %8d %8d %8d %8d\n", 502 out += sprintf(out, "hysteresis: %8d %8d %8d %8d\n",
503 cam->params.compressionParams.hysteresis, 0, 255, 3); 503 cam->params.compressionParams.hysteresis, 0, 255, 3);
504 out += sprintf(out, "threshold_max: %8d %8d %8d %8d\n", 504 out += sprintf(out, "threshold_max: %8d %8d %8d %8d\n",
505 cam->params.compressionParams.threshMax, 0, 255, 11); 505 cam->params.compressionParams.threshMax, 0, 255, 11);
506 out += sprintf(out, "small_step: %8d %8d %8d %8d\n", 506 out += sprintf(out, "small_step: %8d %8d %8d %8d\n",
507 cam->params.compressionParams.smallStep, 0, 255, 1); 507 cam->params.compressionParams.smallStep, 0, 255, 1);
508 out += sprintf(out, "large_step: %8d %8d %8d %8d\n", 508 out += sprintf(out, "large_step: %8d %8d %8d %8d\n",
509 cam->params.compressionParams.largeStep, 0, 255, 3); 509 cam->params.compressionParams.largeStep, 0, 255, 3);
510 out += sprintf(out, "decimation_hysteresis: %8d %8d %8d %8d\n", 510 out += sprintf(out, "decimation_hysteresis: %8d %8d %8d %8d\n",
511 cam->params.compressionParams.decimationHysteresis, 511 cam->params.compressionParams.decimationHysteresis,
512 0, 255, 2); 512 0, 255, 2);
513 out += sprintf(out, "fr_diff_step_thresh: %8d %8d %8d %8d\n", 513 out += sprintf(out, "fr_diff_step_thresh: %8d %8d %8d %8d\n",
514 cam->params.compressionParams.frDiffStepThresh, 514 cam->params.compressionParams.frDiffStepThresh,
515 0, 255, 5); 515 0, 255, 5);
516 out += sprintf(out, "q_diff_step_thresh: %8d %8d %8d %8d\n", 516 out += sprintf(out, "q_diff_step_thresh: %8d %8d %8d %8d\n",
517 cam->params.compressionParams.qDiffStepThresh, 517 cam->params.compressionParams.qDiffStepThresh,
518 0, 255, 3); 518 0, 255, 3);
519 out += sprintf(out, "decimation_thresh_mod: %8d %8d %8d %8d\n", 519 out += sprintf(out, "decimation_thresh_mod: %8d %8d %8d %8d\n",
520 cam->params.compressionParams.decimationThreshMod, 520 cam->params.compressionParams.decimationThreshMod,
521 0, 255, 2); 521 0, 255, 2);
522 /* QX3 specific entries */ 522 /* QX3 specific entries */
523 if (cam->params.qx3.qx3_detected) { 523 if (cam->params.qx3.qx3_detected) {
524 out += sprintf(out, "toplight: %8s %8s %8s %8s\n", 524 out += sprintf(out, "toplight: %8s %8s %8s %8s\n",
525 cam->params.qx3.toplight ? "on" : "off", 525 cam->params.qx3.toplight ? "on" : "off",
526 "off", "on", "off"); 526 "off", "on", "off");
527 out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n", 527 out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n",
528 cam->params.qx3.bottomlight ? "on" : "off", 528 cam->params.qx3.bottomlight ? "on" : "off",
529 "off", "on", "off"); 529 "off", "on", "off");
530 } 530 }
531 531
532 len = out - page; 532 len = out - page;
533 len -= off; 533 len -= off;
534 if (len < count) { 534 if (len < count) {
@@ -543,7 +543,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
543 543
544 544
545static int match(char *checkstr, char **buffer, unsigned long *count, 545static int match(char *checkstr, char **buffer, unsigned long *count,
546 int *find_colon, int *err) 546 int *find_colon, int *err)
547{ 547{
548 int ret, colon_found = 1; 548 int ret, colon_found = 1;
549 int len = strlen(checkstr); 549 int len = strlen(checkstr);
@@ -583,7 +583,7 @@ static unsigned long int value(char **buffer, unsigned long *count, int *err)
583} 583}
584 584
585static int cpia_write_proc(struct file *file, const char __user *buf, 585static int cpia_write_proc(struct file *file, const char __user *buf,
586 unsigned long count, void *data) 586 unsigned long count, void *data)
587{ 587{
588 struct cam_data *cam = data; 588 struct cam_data *cam = data;
589 struct cam_params new_params; 589 struct cam_params new_params;
@@ -619,12 +619,12 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
619 retval = -EINVAL; 619 retval = -EINVAL;
620 goto out; 620 goto out;
621 } 621 }
622 622
623 buffer = page; 623 buffer = page;
624 624
625 if (mutex_lock_interruptible(&cam->param_lock)) 625 if (mutex_lock_interruptible(&cam->param_lock))
626 return -ERESTARTSYS; 626 return -ERESTARTSYS;
627 627
628 /* 628 /*
629 * Skip over leading whitespace 629 * Skip over leading whitespace
630 */ 630 */
@@ -632,15 +632,15 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
632 --count; 632 --count;
633 ++buffer; 633 ++buffer;
634 } 634 }
635 635
636 memcpy(&new_params, &cam->params, sizeof(struct cam_params)); 636 memcpy(&new_params, &cam->params, sizeof(struct cam_params));
637 new_mains = cam->mainsFreq; 637 new_mains = cam->mainsFreq;
638 638
639#define MATCH(x) (match(x, &buffer, &count, &find_colon, &retval)) 639#define MATCH(x) (match(x, &buffer, &count, &find_colon, &retval))
640#define VALUE (value(&buffer,&count, &retval)) 640#define VALUE (value(&buffer,&count, &retval))
641#define FIRMWARE_VERSION(x,y) (new_params.version.firmwareVersion == (x) && \ 641#define FIRMWARE_VERSION(x,y) (new_params.version.firmwareVersion == (x) && \
642 new_params.version.firmwareRevision == (y)) 642 new_params.version.firmwareRevision == (y))
643 643
644 retval = 0; 644 retval = 0;
645 while (count && !retval) { 645 while (count && !retval) {
646 find_colon = 1; 646 find_colon = 1;
@@ -656,7 +656,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
656 } 656 }
657 command_flags |= COMMAND_SETCOLOURPARAMS; 657 command_flags |= COMMAND_SETCOLOURPARAMS;
658 if(new_params.flickerControl.allowableOverExposure < 0) 658 if(new_params.flickerControl.allowableOverExposure < 0)
659 new_params.flickerControl.allowableOverExposure = 659 new_params.flickerControl.allowableOverExposure =
660 -find_over_exposure(new_params.colourParams.brightness); 660 -find_over_exposure(new_params.colourParams.brightness);
661 if(new_params.flickerControl.flickerMode != 0) 661 if(new_params.flickerControl.flickerMode != 0)
662 command_flags |= COMMAND_SETFLICKERCTRL; 662 command_flags |= COMMAND_SETFLICKERCTRL;
@@ -721,7 +721,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
721 /* Either base rate would work here */ 721 /* Either base rate would work here */
722 new_params.sensorFps.baserate = 1; 722 new_params.sensorFps.baserate = 1;
723 } 723 }
724 new_params.flickerControl.coarseJump = 724 new_params.flickerControl.coarseJump =
725 flicker_jumps[new_mains] 725 flicker_jumps[new_mains]
726 [new_params.sensorFps.baserate] 726 [new_params.sensorFps.baserate]
727 [new_params.sensorFps.divisor]; 727 [new_params.sensorFps.divisor];
@@ -1085,7 +1085,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1085 } else if (MATCH("mains_frequency")) { 1085 } else if (MATCH("mains_frequency")) {
1086 if (!retval && MATCH("50")) { 1086 if (!retval && MATCH("50")) {
1087 new_mains = 0; 1087 new_mains = 0;
1088 new_params.flickerControl.coarseJump = 1088 new_params.flickerControl.coarseJump =
1089 flicker_jumps[new_mains] 1089 flicker_jumps[new_mains]
1090 [new_params.sensorFps.baserate] 1090 [new_params.sensorFps.baserate]
1091 [new_params.sensorFps.divisor]; 1091 [new_params.sensorFps.divisor];
@@ -1093,7 +1093,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1093 command_flags |= COMMAND_SETFLICKERCTRL; 1093 command_flags |= COMMAND_SETFLICKERCTRL;
1094 } else if (!retval && MATCH("60")) { 1094 } else if (!retval && MATCH("60")) {
1095 new_mains = 1; 1095 new_mains = 1;
1096 new_params.flickerControl.coarseJump = 1096 new_params.flickerControl.coarseJump =
1097 flicker_jumps[new_mains] 1097 flicker_jumps[new_mains]
1098 [new_params.sensorFps.baserate] 1098 [new_params.sensorFps.baserate]
1099 [new_params.sensorFps.divisor]; 1099 [new_params.sensorFps.divisor];
@@ -1103,7 +1103,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1103 retval = -EINVAL; 1103 retval = -EINVAL;
1104 } else if (MATCH("allowable_overexposure")) { 1104 } else if (MATCH("allowable_overexposure")) {
1105 if (!retval && MATCH("auto")) { 1105 if (!retval && MATCH("auto")) {
1106 new_params.flickerControl.allowableOverExposure = 1106 new_params.flickerControl.allowableOverExposure =
1107 -find_over_exposure(new_params.colourParams.brightness); 1107 -find_over_exposure(new_params.colourParams.brightness);
1108 if(new_params.flickerControl.flickerMode != 0) 1108 if(new_params.flickerControl.flickerMode != 0)
1109 command_flags |= COMMAND_SETFLICKERCTRL; 1109 command_flags |= COMMAND_SETFLICKERCTRL;
@@ -1146,10 +1146,10 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1146 command_flags |= COMMAND_SETCOMPRESSION; 1146 command_flags |= COMMAND_SETCOMPRESSION;
1147 } else if (MATCH("compression_target")) { 1147 } else if (MATCH("compression_target")) {
1148 if (!retval && MATCH("quality")) 1148 if (!retval && MATCH("quality"))
1149 new_params.compressionTarget.frTargeting = 1149 new_params.compressionTarget.frTargeting =
1150 CPIA_COMPRESSION_TARGET_QUALITY; 1150 CPIA_COMPRESSION_TARGET_QUALITY;
1151 else if (!retval && MATCH("framerate")) 1151 else if (!retval && MATCH("framerate"))
1152 new_params.compressionTarget.frTargeting = 1152 new_params.compressionTarget.frTargeting =
1153 CPIA_COMPRESSION_TARGET_FRAMERATE; 1153 CPIA_COMPRESSION_TARGET_FRAMERATE;
1154 else 1154 else
1155 retval = -EINVAL; 1155 retval = -EINVAL;
@@ -1173,7 +1173,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1173 if (!retval) { 1173 if (!retval) {
1174 if(val > 0 && val <= 64) 1174 if(val > 0 && val <= 64)
1175 new_params.compressionTarget.targetQ = val; 1175 new_params.compressionTarget.targetQ = val;
1176 else 1176 else
1177 retval = -EINVAL; 1177 retval = -EINVAL;
1178 } 1178 }
1179 command_flags |= COMMAND_SETCOMPRESSIONTARGET; 1179 command_flags |= COMMAND_SETCOMPRESSIONTARGET;
@@ -1288,19 +1288,19 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1288 } 1288 }
1289 command_flags |= COMMAND_SETCOMPRESSIONPARAMS; 1289 command_flags |= COMMAND_SETCOMPRESSIONPARAMS;
1290 } else if (MATCH("toplight")) { 1290 } else if (MATCH("toplight")) {
1291 if (!retval && MATCH("on")) 1291 if (!retval && MATCH("on"))
1292 new_params.qx3.toplight = 1; 1292 new_params.qx3.toplight = 1;
1293 else if (!retval && MATCH("off")) 1293 else if (!retval && MATCH("off"))
1294 new_params.qx3.toplight = 0; 1294 new_params.qx3.toplight = 0;
1295 else 1295 else
1296 retval = -EINVAL; 1296 retval = -EINVAL;
1297 command_flags |= COMMAND_SETLIGHTS; 1297 command_flags |= COMMAND_SETLIGHTS;
1298 } else if (MATCH("bottomlight")) { 1298 } else if (MATCH("bottomlight")) {
1299 if (!retval && MATCH("on")) 1299 if (!retval && MATCH("on"))
1300 new_params.qx3.bottomlight = 1; 1300 new_params.qx3.bottomlight = 1;
1301 else if (!retval && MATCH("off")) 1301 else if (!retval && MATCH("off"))
1302 new_params.qx3.bottomlight = 0; 1302 new_params.qx3.bottomlight = 0;
1303 else 1303 else
1304 retval = -EINVAL; 1304 retval = -EINVAL;
1305 command_flags |= COMMAND_SETLIGHTS; 1305 command_flags |= COMMAND_SETLIGHTS;
1306 } else { 1306 } else {
@@ -1326,7 +1326,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1326 } 1326 }
1327 } 1327 }
1328 } 1328 }
1329#undef MATCH 1329#undef MATCH
1330#undef VALUE 1330#undef VALUE
1331#undef FIRMWARE_VERSION 1331#undef FIRMWARE_VERSION
1332 if (!retval) { 1332 if (!retval) {
@@ -1349,24 +1349,24 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1349 retval = size; 1349 retval = size;
1350 } else 1350 } else
1351 DBG("error: %d\n", retval); 1351 DBG("error: %d\n", retval);
1352 1352
1353 mutex_unlock(&cam->param_lock); 1353 mutex_unlock(&cam->param_lock);
1354 1354
1355out: 1355out:
1356 free_page((unsigned long)page); 1356 free_page((unsigned long)page);
1357 return retval; 1357 return retval;
1358} 1358}
1359 1359
1360static void create_proc_cpia_cam(struct cam_data *cam) 1360static void create_proc_cpia_cam(struct cam_data *cam)
1361{ 1361{
1362 char name[7]; 1362 char name[7];
1363 struct proc_dir_entry *ent; 1363 struct proc_dir_entry *ent;
1364 1364
1365 if (!cpia_proc_root || !cam) 1365 if (!cpia_proc_root || !cam)
1366 return; 1366 return;
1367 1367
1368 sprintf(name, "video%d", cam->vdev.minor); 1368 sprintf(name, "video%d", cam->vdev.minor);
1369 1369
1370 ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root); 1370 ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root);
1371 if (!ent) 1371 if (!ent)
1372 return; 1372 return;
@@ -1374,9 +1374,9 @@ static void create_proc_cpia_cam(struct cam_data *cam)
1374 ent->data = cam; 1374 ent->data = cam;
1375 ent->read_proc = cpia_read_proc; 1375 ent->read_proc = cpia_read_proc;
1376 ent->write_proc = cpia_write_proc; 1376 ent->write_proc = cpia_write_proc;
1377 /* 1377 /*
1378 size of the proc entry is 3736 bytes for the standard webcam; 1378 size of the proc entry is 3736 bytes for the standard webcam;
1379 the extra features of the QX3 microscope add 189 bytes. 1379 the extra features of the QX3 microscope add 189 bytes.
1380 (we have not yet probed the camera to see which type it is). 1380 (we have not yet probed the camera to see which type it is).
1381 */ 1381 */
1382 ent->size = 3736 + 189; 1382 ent->size = 3736 + 189;
@@ -1386,10 +1386,10 @@ static void create_proc_cpia_cam(struct cam_data *cam)
1386static void destroy_proc_cpia_cam(struct cam_data *cam) 1386static void destroy_proc_cpia_cam(struct cam_data *cam)
1387{ 1387{
1388 char name[7]; 1388 char name[7];
1389 1389
1390 if (!cam || !cam->proc_entry) 1390 if (!cam || !cam->proc_entry)
1391 return; 1391 return;
1392 1392
1393 sprintf(name, "video%d", cam->vdev.minor); 1393 sprintf(name, "video%d", cam->vdev.minor);
1394 remove_proc_entry(name, cpia_proc_root); 1394 remove_proc_entry(name, cpia_proc_root);
1395 cam->proc_entry = NULL; 1395 cam->proc_entry = NULL;
@@ -1596,13 +1596,13 @@ static void set_vw_size(struct cam_data *cam)
1596 cam->vc.width = cam->vw.width; 1596 cam->vc.width = cam->vw.width;
1597 if(cam->vc.height == 0) 1597 if(cam->vc.height == 0)
1598 cam->vc.height = cam->vw.height; 1598 cam->vc.height = cam->vw.height;
1599 1599
1600 cam->params.roi.colStart += cam->vc.x >> 3; 1600 cam->params.roi.colStart += cam->vc.x >> 3;
1601 cam->params.roi.colEnd = cam->params.roi.colStart + 1601 cam->params.roi.colEnd = cam->params.roi.colStart +
1602 (cam->vc.width >> 3); 1602 (cam->vc.width >> 3);
1603 cam->params.roi.rowStart += cam->vc.y >> 2; 1603 cam->params.roi.rowStart += cam->vc.y >> 2;
1604 cam->params.roi.rowEnd = cam->params.roi.rowStart + 1604 cam->params.roi.rowEnd = cam->params.roi.rowStart +
1605 (cam->vc.height >> 2); 1605 (cam->vc.height >> 2);
1606 1606
1607 return; 1607 return;
1608} 1608}
@@ -1624,7 +1624,7 @@ static int allocate_frame_buf(struct cam_data *cam)
1624static int free_frame_buf(struct cam_data *cam) 1624static int free_frame_buf(struct cam_data *cam)
1625{ 1625{
1626 int i; 1626 int i;
1627 1627
1628 rvfree(cam->frame_buf, FRAME_NUM*CPIA_MAX_FRAME_SIZE); 1628 rvfree(cam->frame_buf, FRAME_NUM*CPIA_MAX_FRAME_SIZE);
1629 cam->frame_buf = NULL; 1629 cam->frame_buf = NULL;
1630 for (i=0; i < FRAME_NUM; i++) 1630 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)
1667 mutex_lock(&cam->param_lock); 1667 mutex_lock(&cam->param_lock);
1668 datasize=8; 1668 datasize=8;
1669 break; 1669 break;
1670 case CPIA_COMMAND_ReadMCPorts: 1670 case CPIA_COMMAND_ReadMCPorts:
1671 case CPIA_COMMAND_ReadVCRegs: 1671 case CPIA_COMMAND_ReadVCRegs:
1672 datasize = 4; 1672 datasize = 4;
1673 break; 1673 break;
@@ -1746,10 +1746,10 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1746 mutex_unlock(&cam->param_lock); 1746 mutex_unlock(&cam->param_lock);
1747 break; 1747 break;
1748 1748
1749 case CPIA_COMMAND_ReadMCPorts: 1749 case CPIA_COMMAND_ReadMCPorts:
1750 if (!cam->params.qx3.qx3_detected) 1750 if (!cam->params.qx3.qx3_detected)
1751 break; 1751 break;
1752 /* test button press */ 1752 /* test button press */
1753 cam->params.qx3.button = ((data[1] & 0x02) == 0); 1753 cam->params.qx3.button = ((data[1] & 0x02) == 0);
1754 if (cam->params.qx3.button) { 1754 if (cam->params.qx3.button) {
1755 /* button pressed - unlock the latch */ 1755 /* 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)
1770 1770
1771/* send a command to the camera with an additional data transaction */ 1771/* send a command to the camera with an additional data transaction */
1772static int do_command_extended(struct cam_data *cam, u16 command, 1772static int do_command_extended(struct cam_data *cam, u16 command,
1773 u8 a, u8 b, u8 c, u8 d, 1773 u8 a, u8 b, u8 c, u8 d,
1774 u8 e, u8 f, u8 g, u8 h, 1774 u8 e, u8 f, u8 g, u8 h,
1775 u8 i, u8 j, u8 k, u8 l) 1775 u8 i, u8 j, u8 k, u8 l)
1776{ 1776{
1777 int retval; 1777 int retval;
1778 u8 cmd[8], data[8]; 1778 u8 cmd[8], data[8];
@@ -1809,10 +1809,10 @@ static int do_command_extended(struct cam_data *cam, u16 command,
1809#define LIMIT(x) ((((x)>0xffffff)?0xff0000:(((x)<=0xffff)?0:(x)&0xff0000))>>16) 1809#define LIMIT(x) ((((x)>0xffffff)?0xff0000:(((x)<=0xffff)?0:(x)&0xff0000))>>16)
1810 1810
1811static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt, 1811static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt,
1812 int linesize, int mmap_kludge) 1812 int linesize, int mmap_kludge)
1813{ 1813{
1814 int y, u, v, r, g, b, y1; 1814 int y, u, v, r, g, b, y1;
1815 1815
1816 /* Odd lines use the same u and v as the previous line. 1816 /* Odd lines use the same u and v as the previous line.
1817 * Because of compression, it is necessary to get this 1817 * Because of compression, it is necessary to get this
1818 * information from the decoded image. */ 1818 * information from the decoded image. */
@@ -1925,7 +1925,7 @@ static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt,
1925 1925
1926 1926
1927static int yuvconvert(unsigned char *yuv, unsigned char *rgb, int out_fmt, 1927static int yuvconvert(unsigned char *yuv, unsigned char *rgb, int out_fmt,
1928 int in_uyvy, int mmap_kludge) 1928 int in_uyvy, int mmap_kludge)
1929{ 1929{
1930 int y, u, v, r, g, b, y1; 1930 int y, u, v, r, g, b, y1;
1931 1931
@@ -2078,21 +2078,21 @@ static int parse_picture(struct cam_data *cam, int size)
2078 mutex_unlock(&cam->param_lock); 2078 mutex_unlock(&cam->param_lock);
2079 return -1; 2079 return -1;
2080 } 2080 }
2081 2081
2082 if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) { 2082 if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) {
2083 LOG("illegal subtype %d\n",ibuf[17]); 2083 LOG("illegal subtype %d\n",ibuf[17]);
2084 mutex_unlock(&cam->param_lock); 2084 mutex_unlock(&cam->param_lock);
2085 return -1; 2085 return -1;
2086 } 2086 }
2087 subsample_422 = ibuf[17] == SUBSAMPLE_422; 2087 subsample_422 = ibuf[17] == SUBSAMPLE_422;
2088 2088
2089 if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) { 2089 if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) {
2090 LOG("illegal yuvorder %d\n",ibuf[18]); 2090 LOG("illegal yuvorder %d\n",ibuf[18]);
2091 mutex_unlock(&cam->param_lock); 2091 mutex_unlock(&cam->param_lock);
2092 return -1; 2092 return -1;
2093 } 2093 }
2094 in_uyvy = ibuf[18] == YUVORDER_UYVY; 2094 in_uyvy = ibuf[18] == YUVORDER_UYVY;
2095 2095
2096 if ((ibuf[24] != cam->params.roi.colStart) || 2096 if ((ibuf[24] != cam->params.roi.colStart) ||
2097 (ibuf[25] != cam->params.roi.colEnd) || 2097 (ibuf[25] != cam->params.roi.colEnd) ||
2098 (ibuf[26] != cam->params.roi.rowStart) || 2098 (ibuf[26] != cam->params.roi.rowStart) ||
@@ -2104,20 +2104,20 @@ static int parse_picture(struct cam_data *cam, int size)
2104 cols = 8*(ibuf[25] - ibuf[24]); 2104 cols = 8*(ibuf[25] - ibuf[24]);
2105 rows = 4*(ibuf[27] - ibuf[26]); 2105 rows = 4*(ibuf[27] - ibuf[26]);
2106 2106
2107 2107
2108 if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) { 2108 if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) {
2109 LOG("illegal compression %d\n",ibuf[28]); 2109 LOG("illegal compression %d\n",ibuf[28]);
2110 mutex_unlock(&cam->param_lock); 2110 mutex_unlock(&cam->param_lock);
2111 return -1; 2111 return -1;
2112 } 2112 }
2113 compressed = (ibuf[28] == COMPRESSED); 2113 compressed = (ibuf[28] == COMPRESSED);
2114 2114
2115 if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) { 2115 if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) {
2116 LOG("illegal decimation %d\n",ibuf[29]); 2116 LOG("illegal decimation %d\n",ibuf[29]);
2117 mutex_unlock(&cam->param_lock); 2117 mutex_unlock(&cam->param_lock);
2118 return -1; 2118 return -1;
2119 } 2119 }
2120 decimation = (ibuf[29] == DECIMATION_ENAB); 2120 decimation = (ibuf[29] == DECIMATION_ENAB);
2121 2121
2122 cam->params.yuvThreshold.yThreshold = ibuf[30]; 2122 cam->params.yuvThreshold.yThreshold = ibuf[30];
2123 cam->params.yuvThreshold.uvThreshold = ibuf[31]; 2123 cam->params.yuvThreshold.uvThreshold = ibuf[31];
@@ -2131,7 +2131,7 @@ static int parse_picture(struct cam_data *cam, int size)
2131 cam->params.status.errorCode = ibuf[39]; 2131 cam->params.status.errorCode = ibuf[39];
2132 cam->fps = ibuf[41]; 2132 cam->fps = ibuf[41];
2133 mutex_unlock(&cam->param_lock); 2133 mutex_unlock(&cam->param_lock);
2134 2134
2135 linesize = skipcount(cols, out_fmt); 2135 linesize = skipcount(cols, out_fmt);
2136 ibuf += FRAME_HEADER_SIZE; 2136 ibuf += FRAME_HEADER_SIZE;
2137 size -= FRAME_HEADER_SIZE; 2137 size -= FRAME_HEADER_SIZE;
@@ -2150,14 +2150,14 @@ static int parse_picture(struct cam_data *cam, int size)
2150 if (!compressed || (compressed && !(*ibuf & 1))) { 2150 if (!compressed || (compressed && !(*ibuf & 1))) {
2151 if(subsample_422 || even_line) { 2151 if(subsample_422 || even_line) {
2152 obuf += yuvconvert(ibuf, obuf, out_fmt, 2152 obuf += yuvconvert(ibuf, obuf, out_fmt,
2153 in_uyvy, cam->mmap_kludge); 2153 in_uyvy, cam->mmap_kludge);
2154 ibuf += 4; 2154 ibuf += 4;
2155 ll -= 4; 2155 ll -= 4;
2156 } else { 2156 } else {
2157 /* SUBSAMPLE_420 on an odd line */ 2157 /* SUBSAMPLE_420 on an odd line */
2158 obuf += convert420(ibuf, obuf, 2158 obuf += convert420(ibuf, obuf,
2159 out_fmt, linesize, 2159 out_fmt, linesize,
2160 cam->mmap_kludge); 2160 cam->mmap_kludge);
2161 ibuf += 2; 2161 ibuf += 2;
2162 ll -= 2; 2162 ll -= 2;
2163 } 2163 }
@@ -2183,7 +2183,7 @@ static int parse_picture(struct cam_data *cam, int size)
2183 2183
2184 if ((size > 3) && (ibuf[0] == EOI) && (ibuf[1] == EOI) && 2184 if ((size > 3) && (ibuf[0] == EOI) && (ibuf[1] == EOI) &&
2185 (ibuf[2] == EOI) && (ibuf[3] == EOI)) { 2185 (ibuf[2] == EOI) && (ibuf[3] == EOI)) {
2186 size -= 4; 2186 size -= 4;
2187 break; 2187 break;
2188 } 2188 }
2189 2189
@@ -2204,7 +2204,7 @@ static int parse_picture(struct cam_data *cam, int size)
2204 return -1; 2204 return -1;
2205 } 2205 }
2206 } 2206 }
2207 2207
2208 if(decimation) { 2208 if(decimation) {
2209 /* interpolate odd rows */ 2209 /* interpolate odd rows */
2210 int i, j; 2210 int i, j;
@@ -2233,7 +2233,7 @@ static int parse_picture(struct cam_data *cam, int size)
2233static inline int init_stream_cap(struct cam_data *cam) 2233static inline int init_stream_cap(struct cam_data *cam)
2234{ 2234{
2235 return do_command(cam, CPIA_COMMAND_InitStreamCap, 2235 return do_command(cam, CPIA_COMMAND_InitStreamCap,
2236 0, cam->params.streamStartLine, 0, 0); 2236 0, cam->params.streamStartLine, 0, 0);
2237} 2237}
2238 2238
2239 2239
@@ -2254,7 +2254,7 @@ static int find_over_exposure(int brightness)
2254 int MaxAllowableOverExposure, OverExposure; 2254 int MaxAllowableOverExposure, OverExposure;
2255 2255
2256 MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness - 2256 MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness -
2257 FLICKER_BRIGHTNESS_CONSTANT; 2257 FLICKER_BRIGHTNESS_CONSTANT;
2258 2258
2259 if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE) { 2259 if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE) {
2260 OverExposure = MaxAllowableOverExposure; 2260 OverExposure = MaxAllowableOverExposure;
@@ -2280,62 +2280,62 @@ static void dispatch_commands(struct cam_data *cam)
2280 DEB_BYTE(cam->cmd_queue>>8); 2280 DEB_BYTE(cam->cmd_queue>>8);
2281 if (cam->cmd_queue & COMMAND_SETFORMAT) { 2281 if (cam->cmd_queue & COMMAND_SETFORMAT) {
2282 do_command(cam, CPIA_COMMAND_SetFormat, 2282 do_command(cam, CPIA_COMMAND_SetFormat,
2283 cam->params.format.videoSize, 2283 cam->params.format.videoSize,
2284 cam->params.format.subSample, 2284 cam->params.format.subSample,
2285 cam->params.format.yuvOrder, 0); 2285 cam->params.format.yuvOrder, 0);
2286 do_command(cam, CPIA_COMMAND_SetROI, 2286 do_command(cam, CPIA_COMMAND_SetROI,
2287 cam->params.roi.colStart, cam->params.roi.colEnd, 2287 cam->params.roi.colStart, cam->params.roi.colEnd,
2288 cam->params.roi.rowStart, cam->params.roi.rowEnd); 2288 cam->params.roi.rowStart, cam->params.roi.rowEnd);
2289 cam->first_frame = 1; 2289 cam->first_frame = 1;
2290 } 2290 }
2291 2291
2292 if (cam->cmd_queue & COMMAND_SETCOLOURPARAMS) 2292 if (cam->cmd_queue & COMMAND_SETCOLOURPARAMS)
2293 do_command(cam, CPIA_COMMAND_SetColourParams, 2293 do_command(cam, CPIA_COMMAND_SetColourParams,
2294 cam->params.colourParams.brightness, 2294 cam->params.colourParams.brightness,
2295 cam->params.colourParams.contrast, 2295 cam->params.colourParams.contrast,
2296 cam->params.colourParams.saturation, 0); 2296 cam->params.colourParams.saturation, 0);
2297 2297
2298 if (cam->cmd_queue & COMMAND_SETAPCOR) 2298 if (cam->cmd_queue & COMMAND_SETAPCOR)
2299 do_command(cam, CPIA_COMMAND_SetApcor, 2299 do_command(cam, CPIA_COMMAND_SetApcor,
2300 cam->params.apcor.gain1, 2300 cam->params.apcor.gain1,
2301 cam->params.apcor.gain2, 2301 cam->params.apcor.gain2,
2302 cam->params.apcor.gain4, 2302 cam->params.apcor.gain4,
2303 cam->params.apcor.gain8); 2303 cam->params.apcor.gain8);
2304 2304
2305 if (cam->cmd_queue & COMMAND_SETVLOFFSET) 2305 if (cam->cmd_queue & COMMAND_SETVLOFFSET)
2306 do_command(cam, CPIA_COMMAND_SetVLOffset, 2306 do_command(cam, CPIA_COMMAND_SetVLOffset,
2307 cam->params.vlOffset.gain1, 2307 cam->params.vlOffset.gain1,
2308 cam->params.vlOffset.gain2, 2308 cam->params.vlOffset.gain2,
2309 cam->params.vlOffset.gain4, 2309 cam->params.vlOffset.gain4,
2310 cam->params.vlOffset.gain8); 2310 cam->params.vlOffset.gain8);
2311 2311
2312 if (cam->cmd_queue & COMMAND_SETEXPOSURE) { 2312 if (cam->cmd_queue & COMMAND_SETEXPOSURE) {
2313 do_command_extended(cam, CPIA_COMMAND_SetExposure, 2313 do_command_extended(cam, CPIA_COMMAND_SetExposure,
2314 cam->params.exposure.gainMode, 2314 cam->params.exposure.gainMode,
2315 1, 2315 1,
2316 cam->params.exposure.compMode, 2316 cam->params.exposure.compMode,
2317 cam->params.exposure.centreWeight, 2317 cam->params.exposure.centreWeight,
2318 cam->params.exposure.gain, 2318 cam->params.exposure.gain,
2319 cam->params.exposure.fineExp, 2319 cam->params.exposure.fineExp,
2320 cam->params.exposure.coarseExpLo, 2320 cam->params.exposure.coarseExpLo,
2321 cam->params.exposure.coarseExpHi, 2321 cam->params.exposure.coarseExpHi,
2322 cam->params.exposure.redComp, 2322 cam->params.exposure.redComp,
2323 cam->params.exposure.green1Comp, 2323 cam->params.exposure.green1Comp,
2324 cam->params.exposure.green2Comp, 2324 cam->params.exposure.green2Comp,
2325 cam->params.exposure.blueComp); 2325 cam->params.exposure.blueComp);
2326 if(cam->params.exposure.expMode != 1) { 2326 if(cam->params.exposure.expMode != 1) {
2327 do_command_extended(cam, CPIA_COMMAND_SetExposure, 2327 do_command_extended(cam, CPIA_COMMAND_SetExposure,
2328 0, 2328 0,
2329 cam->params.exposure.expMode, 2329 cam->params.exposure.expMode,
2330 0, 0, 2330 0, 0,
2331 cam->params.exposure.gain, 2331 cam->params.exposure.gain,
2332 cam->params.exposure.fineExp, 2332 cam->params.exposure.fineExp,
2333 cam->params.exposure.coarseExpLo, 2333 cam->params.exposure.coarseExpLo,
2334 cam->params.exposure.coarseExpHi, 2334 cam->params.exposure.coarseExpHi,
2335 0, 0, 0, 0); 2335 0, 0, 0, 0);
2336 } 2336 }
2337 } 2337 }
2338 2338
2339 if (cam->cmd_queue & COMMAND_SETCOLOURBALANCE) { 2339 if (cam->cmd_queue & COMMAND_SETCOLOURBALANCE) {
2340 if (cam->params.colourBalance.balanceMode == 1) { 2340 if (cam->params.colourBalance.balanceMode == 1) {
2341 do_command(cam, CPIA_COMMAND_SetColourBalance, 2341 do_command(cam, CPIA_COMMAND_SetColourBalance,
@@ -2358,47 +2358,47 @@ static void dispatch_commands(struct cam_data *cam)
2358 2358
2359 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONTARGET) 2359 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONTARGET)
2360 do_command(cam, CPIA_COMMAND_SetCompressionTarget, 2360 do_command(cam, CPIA_COMMAND_SetCompressionTarget,
2361 cam->params.compressionTarget.frTargeting, 2361 cam->params.compressionTarget.frTargeting,
2362 cam->params.compressionTarget.targetFR, 2362 cam->params.compressionTarget.targetFR,
2363 cam->params.compressionTarget.targetQ, 0); 2363 cam->params.compressionTarget.targetQ, 0);
2364 2364
2365 if (cam->cmd_queue & COMMAND_SETYUVTHRESH) 2365 if (cam->cmd_queue & COMMAND_SETYUVTHRESH)
2366 do_command(cam, CPIA_COMMAND_SetYUVThresh, 2366 do_command(cam, CPIA_COMMAND_SetYUVThresh,
2367 cam->params.yuvThreshold.yThreshold, 2367 cam->params.yuvThreshold.yThreshold,
2368 cam->params.yuvThreshold.uvThreshold, 0, 0); 2368 cam->params.yuvThreshold.uvThreshold, 0, 0);
2369 2369
2370 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONPARAMS) 2370 if (cam->cmd_queue & COMMAND_SETCOMPRESSIONPARAMS)
2371 do_command_extended(cam, CPIA_COMMAND_SetCompressionParams, 2371 do_command_extended(cam, CPIA_COMMAND_SetCompressionParams,
2372 0, 0, 0, 0, 2372 0, 0, 0, 0,
2373 cam->params.compressionParams.hysteresis, 2373 cam->params.compressionParams.hysteresis,
2374 cam->params.compressionParams.threshMax, 2374 cam->params.compressionParams.threshMax,
2375 cam->params.compressionParams.smallStep, 2375 cam->params.compressionParams.smallStep,
2376 cam->params.compressionParams.largeStep, 2376 cam->params.compressionParams.largeStep,
2377 cam->params.compressionParams.decimationHysteresis, 2377 cam->params.compressionParams.decimationHysteresis,
2378 cam->params.compressionParams.frDiffStepThresh, 2378 cam->params.compressionParams.frDiffStepThresh,
2379 cam->params.compressionParams.qDiffStepThresh, 2379 cam->params.compressionParams.qDiffStepThresh,
2380 cam->params.compressionParams.decimationThreshMod); 2380 cam->params.compressionParams.decimationThreshMod);
2381 2381
2382 if (cam->cmd_queue & COMMAND_SETCOMPRESSION) 2382 if (cam->cmd_queue & COMMAND_SETCOMPRESSION)
2383 do_command(cam, CPIA_COMMAND_SetCompression, 2383 do_command(cam, CPIA_COMMAND_SetCompression,
2384 cam->params.compression.mode, 2384 cam->params.compression.mode,
2385 cam->params.compression.decimation, 0, 0); 2385 cam->params.compression.decimation, 0, 0);
2386 2386
2387 if (cam->cmd_queue & COMMAND_SETSENSORFPS) 2387 if (cam->cmd_queue & COMMAND_SETSENSORFPS)
2388 do_command(cam, CPIA_COMMAND_SetSensorFPS, 2388 do_command(cam, CPIA_COMMAND_SetSensorFPS,
2389 cam->params.sensorFps.divisor, 2389 cam->params.sensorFps.divisor,
2390 cam->params.sensorFps.baserate, 0, 0); 2390 cam->params.sensorFps.baserate, 0, 0);
2391 2391
2392 if (cam->cmd_queue & COMMAND_SETFLICKERCTRL) 2392 if (cam->cmd_queue & COMMAND_SETFLICKERCTRL)
2393 do_command(cam, CPIA_COMMAND_SetFlickerCtrl, 2393 do_command(cam, CPIA_COMMAND_SetFlickerCtrl,
2394 cam->params.flickerControl.flickerMode, 2394 cam->params.flickerControl.flickerMode,
2395 cam->params.flickerControl.coarseJump, 2395 cam->params.flickerControl.coarseJump,
2396 abs(cam->params.flickerControl.allowableOverExposure), 2396 abs(cam->params.flickerControl.allowableOverExposure),
2397 0); 2397 0);
2398 2398
2399 if (cam->cmd_queue & COMMAND_SETECPTIMING) 2399 if (cam->cmd_queue & COMMAND_SETECPTIMING)
2400 do_command(cam, CPIA_COMMAND_SetECPTiming, 2400 do_command(cam, CPIA_COMMAND_SetECPTiming,
2401 cam->params.ecpTiming, 0, 0, 0); 2401 cam->params.ecpTiming, 0, 0, 0);
2402 2402
2403 if (cam->cmd_queue & COMMAND_PAUSE) 2403 if (cam->cmd_queue & COMMAND_PAUSE)
2404 do_command(cam, CPIA_COMMAND_EndStreamCap, 0, 0, 0, 0); 2404 do_command(cam, CPIA_COMMAND_EndStreamCap, 0, 0, 0, 0);
@@ -2409,9 +2409,9 @@ static void dispatch_commands(struct cam_data *cam)
2409 if (cam->cmd_queue & COMMAND_SETLIGHTS && cam->params.qx3.qx3_detected) 2409 if (cam->cmd_queue & COMMAND_SETLIGHTS && cam->params.qx3.qx3_detected)
2410 { 2410 {
2411 int p1 = (cam->params.qx3.bottomlight == 0) << 1; 2411 int p1 = (cam->params.qx3.bottomlight == 0) << 1;
2412 int p2 = (cam->params.qx3.toplight == 0) << 3; 2412 int p2 = (cam->params.qx3.toplight == 0) << 3;
2413 do_command(cam, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0); 2413 do_command(cam, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0);
2414 do_command(cam, CPIA_COMMAND_WriteMCPort, 2, 0, (p1|p2|0xE0), 0); 2414 do_command(cam, CPIA_COMMAND_WriteMCPort, 2, 0, (p1|p2|0xE0), 0);
2415 } 2415 }
2416 2416
2417 cam->cmd_queue = COMMAND_NONE; 2417 cam->cmd_queue = COMMAND_NONE;
@@ -2422,11 +2422,11 @@ static void dispatch_commands(struct cam_data *cam)
2422 2422
2423 2423
2424static void set_flicker(struct cam_params *params, volatile u32 *command_flags, 2424static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2425 int on) 2425 int on)
2426{ 2426{
2427 /* Everything in here is from the Windows driver */ 2427 /* Everything in here is from the Windows driver */
2428#define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \ 2428#define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \
2429 params->version.firmwareRevision == (y)) 2429 params->version.firmwareRevision == (y))
2430/* define for compgain calculation */ 2430/* define for compgain calculation */
2431#if 0 2431#if 0
2432#define COMPGAIN(base, curexp, newexp) \ 2432#define COMPGAIN(base, curexp, newexp) \
@@ -2441,7 +2441,7 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2441 (u16)(((u32)(curexp * (u8)(curcomp + 128)) / (u8)(basecomp - 128))) 2441 (u16)(((u32)(curexp * (u8)(curcomp + 128)) / (u8)(basecomp - 128)))
2442#endif 2442#endif
2443 2443
2444 2444
2445 int currentexp = params->exposure.coarseExpLo + 2445 int currentexp = params->exposure.coarseExpLo +
2446 params->exposure.coarseExpHi*256; 2446 params->exposure.coarseExpHi*256;
2447 int startexp; 2447 int startexp;
@@ -2482,7 +2482,7 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2482 } 2482 }
2483 if(FIRMWARE_VERSION(1,2)) 2483 if(FIRMWARE_VERSION(1,2))
2484 params->exposure.compMode = 0; 2484 params->exposure.compMode = 0;
2485 else 2485 else
2486 params->exposure.compMode = 1; 2486 params->exposure.compMode = 1;
2487 2487
2488 params->apcor.gain1 = 0x18; 2488 params->apcor.gain1 = 0x18;
@@ -2533,14 +2533,14 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
2533} 2533}
2534 2534
2535#define FIRMWARE_VERSION(x,y) (cam->params.version.firmwareVersion == (x) && \ 2535#define FIRMWARE_VERSION(x,y) (cam->params.version.firmwareVersion == (x) && \
2536 cam->params.version.firmwareRevision == (y)) 2536 cam->params.version.firmwareRevision == (y))
2537/* monitor the exposure and adjust the sensor frame rate if needed */ 2537/* monitor the exposure and adjust the sensor frame rate if needed */
2538static void monitor_exposure(struct cam_data *cam) 2538static void monitor_exposure(struct cam_data *cam)
2539{ 2539{
2540 u8 exp_acc, bcomp, gain, coarseL, cmd[8], data[8]; 2540 u8 exp_acc, bcomp, gain, coarseL, cmd[8], data[8];
2541 int retval, light_exp, dark_exp, very_dark_exp; 2541 int retval, light_exp, dark_exp, very_dark_exp;
2542 int old_exposure, new_exposure, framerate; 2542 int old_exposure, new_exposure, framerate;
2543 2543
2544 /* get necessary stats and register settings from camera */ 2544 /* get necessary stats and register settings from camera */
2545 /* do_command can't handle this, so do it ourselves */ 2545 /* do_command can't handle this, so do it ourselves */
2546 cmd[0] = CPIA_COMMAND_ReadVPRegs>>8; 2546 cmd[0] = CPIA_COMMAND_ReadVPRegs>>8;
@@ -2564,17 +2564,17 @@ static void monitor_exposure(struct cam_data *cam)
2564 2564
2565 mutex_lock(&cam->param_lock); 2565 mutex_lock(&cam->param_lock);
2566 light_exp = cam->params.colourParams.brightness + 2566 light_exp = cam->params.colourParams.brightness +
2567 TC - 50 + EXP_ACC_LIGHT; 2567 TC - 50 + EXP_ACC_LIGHT;
2568 if(light_exp > 255) 2568 if(light_exp > 255)
2569 light_exp = 255; 2569 light_exp = 255;
2570 dark_exp = cam->params.colourParams.brightness + 2570 dark_exp = cam->params.colourParams.brightness +
2571 TC - 50 - EXP_ACC_DARK; 2571 TC - 50 - EXP_ACC_DARK;
2572 if(dark_exp < 0) 2572 if(dark_exp < 0)
2573 dark_exp = 0; 2573 dark_exp = 0;
2574 very_dark_exp = dark_exp/2; 2574 very_dark_exp = dark_exp/2;
2575 2575
2576 old_exposure = cam->params.exposure.coarseExpHi * 256 + 2576 old_exposure = cam->params.exposure.coarseExpHi * 256 +
2577 cam->params.exposure.coarseExpLo; 2577 cam->params.exposure.coarseExpLo;
2578 2578
2579 if(!cam->params.flickerControl.disabled) { 2579 if(!cam->params.flickerControl.disabled) {
2580 /* Flicker control on */ 2580 /* Flicker control on */
@@ -2667,11 +2667,11 @@ static void monitor_exposure(struct cam_data *cam)
2667 cam->exposure_status = EXPOSURE_NORMAL; 2667 cam->exposure_status = EXPOSURE_NORMAL;
2668 } 2668 }
2669 } 2669 }
2670 2670
2671 framerate = cam->fps; 2671 framerate = cam->fps;
2672 if(framerate > 30 || framerate < 1) 2672 if(framerate > 30 || framerate < 1)
2673 framerate = 1; 2673 framerate = 1;
2674 2674
2675 if(!cam->params.flickerControl.disabled) { 2675 if(!cam->params.flickerControl.disabled) {
2676 /* Flicker control on */ 2676 /* Flicker control on */
2677 if((cam->exposure_status == EXPOSURE_VERY_DARK || 2677 if((cam->exposure_status == EXPOSURE_VERY_DARK ||
@@ -2683,10 +2683,10 @@ static void monitor_exposure(struct cam_data *cam)
2683 ++cam->params.sensorFps.divisor; 2683 ++cam->params.sensorFps.divisor;
2684 cam->cmd_queue |= COMMAND_SETSENSORFPS; 2684 cam->cmd_queue |= COMMAND_SETSENSORFPS;
2685 2685
2686 cam->params.flickerControl.coarseJump = 2686 cam->params.flickerControl.coarseJump =
2687 flicker_jumps[cam->mainsFreq] 2687 flicker_jumps[cam->mainsFreq]
2688 [cam->params.sensorFps.baserate] 2688 [cam->params.sensorFps.baserate]
2689 [cam->params.sensorFps.divisor]; 2689 [cam->params.sensorFps.divisor];
2690 cam->cmd_queue |= COMMAND_SETFLICKERCTRL; 2690 cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
2691 2691
2692 new_exposure = cam->params.flickerControl.coarseJump-1; 2692 new_exposure = cam->params.flickerControl.coarseJump-1;
@@ -2704,15 +2704,15 @@ static void monitor_exposure(struct cam_data *cam)
2704 cam->params.sensorFps.divisor > 0) { 2704 cam->params.sensorFps.divisor > 0) {
2705 2705
2706 /* light for too long */ 2706 /* light for too long */
2707 int max_exp = FIRMWARE_VERSION(1,2) ? MAX_EXP_102 : MAX_EXP ; 2707 int max_exp = FIRMWARE_VERSION(1,2) ? MAX_EXP_102 : MAX_EXP ;
2708 2708
2709 --cam->params.sensorFps.divisor; 2709 --cam->params.sensorFps.divisor;
2710 cam->cmd_queue |= COMMAND_SETSENSORFPS; 2710 cam->cmd_queue |= COMMAND_SETSENSORFPS;
2711 2711
2712 cam->params.flickerControl.coarseJump = 2712 cam->params.flickerControl.coarseJump =
2713 flicker_jumps[cam->mainsFreq] 2713 flicker_jumps[cam->mainsFreq]
2714 [cam->params.sensorFps.baserate] 2714 [cam->params.sensorFps.baserate]
2715 [cam->params.sensorFps.divisor]; 2715 [cam->params.sensorFps.divisor];
2716 cam->cmd_queue |= COMMAND_SETFLICKERCTRL; 2716 cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
2717 2717
2718 new_exposure = cam->params.flickerControl.coarseJump-1; 2718 new_exposure = cam->params.flickerControl.coarseJump-1;
@@ -2772,7 +2772,7 @@ static void monitor_exposure(struct cam_data *cam)
2772 2772
2773 It also adjust the colour balance when an exposure step is detected - as 2773 It also adjust the colour balance when an exposure step is detected - as
2774 long as flicker is running 2774 long as flicker is running
2775*/ 2775*/
2776static void restart_flicker(struct cam_data *cam) 2776static void restart_flicker(struct cam_data *cam)
2777{ 2777{
2778 int cam_exposure, old_exp; 2778 int cam_exposure, old_exp;
@@ -2786,22 +2786,22 @@ static void restart_flicker(struct cam_data *cam)
2786 } 2786 }
2787 cam_exposure = cam->raw_image[39]*2; 2787 cam_exposure = cam->raw_image[39]*2;
2788 old_exp = cam->params.exposure.coarseExpLo + 2788 old_exp = cam->params.exposure.coarseExpLo +
2789 cam->params.exposure.coarseExpHi*256; 2789 cam->params.exposure.coarseExpHi*256;
2790 /* 2790 /*
2791 see how far away camera exposure is from a valid 2791 see how far away camera exposure is from a valid
2792 flicker exposure value 2792 flicker exposure value
2793 */ 2793 */
2794 cam_exposure %= cam->params.flickerControl.coarseJump; 2794 cam_exposure %= cam->params.flickerControl.coarseJump;
2795 if(!cam->params.flickerControl.disabled && 2795 if(!cam->params.flickerControl.disabled &&
2796 cam_exposure <= cam->params.flickerControl.coarseJump - 3) { 2796 cam_exposure <= cam->params.flickerControl.coarseJump - 3) {
2797 /* Flicker control auto-disabled */ 2797 /* Flicker control auto-disabled */
2798 cam->params.flickerControl.disabled = 1; 2798 cam->params.flickerControl.disabled = 1;
2799 } 2799 }
2800 2800
2801 if(cam->params.flickerControl.disabled && 2801 if(cam->params.flickerControl.disabled &&
2802 cam->params.flickerControl.flickerMode && 2802 cam->params.flickerControl.flickerMode &&
2803 old_exp > cam->params.flickerControl.coarseJump + 2803 old_exp > cam->params.flickerControl.coarseJump +
2804 ROUND_UP_EXP_FOR_FLICKER) { 2804 ROUND_UP_EXP_FOR_FLICKER) {
2805 /* exposure is now high enough to switch 2805 /* exposure is now high enough to switch
2806 flicker control back on */ 2806 flicker control back on */
2807 set_flicker(&cam->params, &cam->cmd_queue, 1); 2807 set_flicker(&cam->params, &cam->cmd_queue, 1);
@@ -2818,7 +2818,7 @@ static int clear_stall(struct cam_data *cam)
2818{ 2818{
2819 /* FIXME: Does this actually work? */ 2819 /* FIXME: Does this actually work? */
2820 LOG("Clearing stall\n"); 2820 LOG("Clearing stall\n");
2821 2821
2822 cam->ops->streamRead(cam->lowlevel_data, cam->raw_image, 0); 2822 cam->ops->streamRead(cam->lowlevel_data, cam->raw_image, 0);
2823 do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0); 2823 do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0);
2824 return cam->params.status.streamState != STREAM_PAUSED; 2824 return cam->params.status.streamState != STREAM_PAUSED;
@@ -2878,7 +2878,7 @@ static int fetch_frame(void *data)
2878 return -EINTR; 2878 return -EINTR;
2879 2879
2880 do_command(cam, CPIA_COMMAND_GetCameraStatus, 2880 do_command(cam, CPIA_COMMAND_GetCameraStatus,
2881 0, 0, 0, 0); 2881 0, 0, 0, 0);
2882 } 2882 }
2883 if(cam->params.status.streamState != STREAM_READY) { 2883 if(cam->params.status.streamState != STREAM_READY) {
2884 continue; 2884 continue;
@@ -2903,18 +2903,18 @@ static int fetch_frame(void *data)
2903 2903
2904 /* Switch flicker control back on if it got turned off */ 2904 /* Switch flicker control back on if it got turned off */
2905 restart_flicker(cam); 2905 restart_flicker(cam);
2906 2906
2907 /* If AEC is enabled, monitor the exposure and 2907 /* If AEC is enabled, monitor the exposure and
2908 adjust the sensor frame rate if needed */ 2908 adjust the sensor frame rate if needed */
2909 if(cam->params.exposure.expMode == 2) 2909 if(cam->params.exposure.expMode == 2)
2910 monitor_exposure(cam); 2910 monitor_exposure(cam);
2911 2911
2912 /* camera idle now so dispatch queued commands */ 2912 /* camera idle now so dispatch queued commands */
2913 dispatch_commands(cam); 2913 dispatch_commands(cam);
2914 2914
2915 /* Update our knowledge of the camera state */ 2915 /* Update our knowledge of the camera state */
2916 do_command(cam, CPIA_COMMAND_GetColourBalance, 0, 0, 0, 0); 2916 do_command(cam, CPIA_COMMAND_GetColourBalance, 0, 0, 0, 0);
2917 do_command(cam, CPIA_COMMAND_GetExposure, 0, 0, 0, 0); 2917 do_command(cam, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
2918 do_command(cam, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0); 2918 do_command(cam, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
2919 2919
2920 /* decompress and convert image to by copying it from 2920 /* decompress and convert image to by copying it from
@@ -2933,7 +2933,7 @@ static int fetch_frame(void *data)
2933 uncompressed. */ 2933 uncompressed. */
2934 cam->first_frame = 1; 2934 cam->first_frame = 1;
2935 do_command(cam, CPIA_COMMAND_SetGrabMode, 2935 do_command(cam, CPIA_COMMAND_SetGrabMode,
2936 CPIA_GRAB_SINGLE, 0, 0, 0); 2936 CPIA_GRAB_SINGLE, 0, 0, 0);
2937 /* FIXME: Trial & error - need up to 70ms for 2937 /* FIXME: Trial & error - need up to 70ms for
2938 the grab mode change to complete ? */ 2938 the grab mode change to complete ? */
2939 msleep_interruptible(70); 2939 msleep_interruptible(70);
@@ -2957,12 +2957,12 @@ static int fetch_frame(void *data)
2957 if (cam->first_frame) { 2957 if (cam->first_frame) {
2958 cam->first_frame = 0; 2958 cam->first_frame = 0;
2959 do_command(cam, CPIA_COMMAND_SetCompression, 2959 do_command(cam, CPIA_COMMAND_SetCompression,
2960 cam->params.compression.mode, 2960 cam->params.compression.mode,
2961 cam->params.compression.decimation, 0, 0); 2961 cam->params.compression.decimation, 0, 0);
2962 2962
2963 /* Switch from single-grab to continuous grab */ 2963 /* Switch from single-grab to continuous grab */
2964 do_command(cam, CPIA_COMMAND_SetGrabMode, 2964 do_command(cam, CPIA_COMMAND_SetGrabMode,
2965 CPIA_GRAB_CONTINUOUS, 0, 0, 0); 2965 CPIA_GRAB_CONTINUOUS, 0, 0, 0);
2966 } 2966 }
2967 return 0; 2967 return 0;
2968 } 2968 }
@@ -2977,12 +2977,12 @@ static int capture_frame(struct cam_data *cam, struct video_mmap *vm)
2977 if ((err = allocate_frame_buf(cam))) 2977 if ((err = allocate_frame_buf(cam)))
2978 return err; 2978 return err;
2979 } 2979 }
2980 2980
2981 cam->curframe = vm->frame; 2981 cam->curframe = vm->frame;
2982 cam->frame[cam->curframe].state = FRAME_READY; 2982 cam->frame[cam->curframe].state = FRAME_READY;
2983 return fetch_frame(cam); 2983 return fetch_frame(cam);
2984} 2984}
2985 2985
2986static int goto_high_power(struct cam_data *cam) 2986static int goto_high_power(struct cam_data *cam)
2987{ 2987{
2988 if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0)) 2988 if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0))
@@ -3039,22 +3039,22 @@ static void save_camera_state(struct cam_data *cam)
3039static int set_camera_state(struct cam_data *cam) 3039static int set_camera_state(struct cam_data *cam)
3040{ 3040{
3041 cam->cmd_queue = COMMAND_SETCOMPRESSION | 3041 cam->cmd_queue = COMMAND_SETCOMPRESSION |
3042 COMMAND_SETCOMPRESSIONTARGET | 3042 COMMAND_SETCOMPRESSIONTARGET |
3043 COMMAND_SETCOLOURPARAMS | 3043 COMMAND_SETCOLOURPARAMS |
3044 COMMAND_SETFORMAT | 3044 COMMAND_SETFORMAT |
3045 COMMAND_SETYUVTHRESH | 3045 COMMAND_SETYUVTHRESH |
3046 COMMAND_SETECPTIMING | 3046 COMMAND_SETECPTIMING |
3047 COMMAND_SETCOMPRESSIONPARAMS | 3047 COMMAND_SETCOMPRESSIONPARAMS |
3048 COMMAND_SETEXPOSURE | 3048 COMMAND_SETEXPOSURE |
3049 COMMAND_SETCOLOURBALANCE | 3049 COMMAND_SETCOLOURBALANCE |
3050 COMMAND_SETSENSORFPS | 3050 COMMAND_SETSENSORFPS |
3051 COMMAND_SETAPCOR | 3051 COMMAND_SETAPCOR |
3052 COMMAND_SETFLICKERCTRL | 3052 COMMAND_SETFLICKERCTRL |
3053 COMMAND_SETVLOFFSET; 3053 COMMAND_SETVLOFFSET;
3054 3054
3055 do_command(cam, CPIA_COMMAND_SetGrabMode, CPIA_GRAB_SINGLE,0,0,0); 3055 do_command(cam, CPIA_COMMAND_SetGrabMode, CPIA_GRAB_SINGLE,0,0,0);
3056 dispatch_commands(cam); 3056 dispatch_commands(cam);
3057 3057
3058 /* Wait 6 frames for the sensor to get all settings and 3058 /* Wait 6 frames for the sensor to get all settings and
3059 AEC/ACB to settle */ 3059 AEC/ACB to settle */
3060 msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) * 3060 msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) *
@@ -3062,7 +3062,7 @@ static int set_camera_state(struct cam_data *cam)
3062 3062
3063 if(signal_pending(current)) 3063 if(signal_pending(current))
3064 return -EINTR; 3064 return -EINTR;
3065 3065
3066 save_camera_state(cam); 3066 save_camera_state(cam);
3067 3067
3068 return 0; 3068 return 0;
@@ -3094,9 +3094,9 @@ static int reset_camera(struct cam_data *cam)
3094 if (goto_low_power(cam)) 3094 if (goto_low_power(cam))
3095 return -ENODEV; 3095 return -ENODEV;
3096 } 3096 }
3097 3097
3098 /* procedure described in developer's guide p3-28 */ 3098 /* procedure described in developer's guide p3-28 */
3099 3099
3100 /* Check the firmware version. */ 3100 /* Check the firmware version. */
3101 cam->params.version.firmwareVersion = 0; 3101 cam->params.version.firmwareVersion = 0;
3102 get_version_information(cam); 3102 get_version_information(cam);
@@ -3113,14 +3113,14 @@ static int reset_camera(struct cam_data *cam)
3113 cam->params.qx3.qx3_detected = (cam->params.pnpID.vendor == 0x0813 && 3113 cam->params.qx3.qx3_detected = (cam->params.pnpID.vendor == 0x0813 &&
3114 cam->params.pnpID.product == 0x0001); 3114 cam->params.pnpID.product == 0x0001);
3115 3115
3116 /* The fatal error checking should be done after 3116 /* The fatal error checking should be done after
3117 * the camera powers up (developer's guide p 3-38) */ 3117 * the camera powers up (developer's guide p 3-38) */
3118 3118
3119 /* Set streamState before transition to high power to avoid bug 3119 /* Set streamState before transition to high power to avoid bug
3120 * in firmware 1-02 */ 3120 * in firmware 1-02 */
3121 do_command(cam, CPIA_COMMAND_ModifyCameraStatus, STREAMSTATE, 0, 3121 do_command(cam, CPIA_COMMAND_ModifyCameraStatus, STREAMSTATE, 0,
3122 STREAM_NOT_READY, 0); 3122 STREAM_NOT_READY, 0);
3123 3123
3124 /* GotoHiPower */ 3124 /* GotoHiPower */
3125 err = goto_high_power(cam); 3125 err = goto_high_power(cam);
3126 if (err) 3126 if (err)
@@ -3142,16 +3142,16 @@ static int reset_camera(struct cam_data *cam)
3142 /* Firmware 1-02 may do this for parallel port cameras, 3142 /* Firmware 1-02 may do this for parallel port cameras,
3143 * just clear the flags (developer's guide p 3-38) */ 3143 * just clear the flags (developer's guide p 3-38) */
3144 do_command(cam, CPIA_COMMAND_ModifyCameraStatus, 3144 do_command(cam, CPIA_COMMAND_ModifyCameraStatus,
3145 FATALERROR, ~(COM_FLAG|CPIA_FLAG), 0, 0); 3145 FATALERROR, ~(COM_FLAG|CPIA_FLAG), 0, 0);
3146 } 3146 }
3147 } 3147 }
3148 3148
3149 /* Check the camera status again */ 3149 /* Check the camera status again */
3150 if (cam->params.status.fatalError) { 3150 if (cam->params.status.fatalError) {
3151 if (cam->params.status.fatalError) 3151 if (cam->params.status.fatalError)
3152 return -EIO; 3152 return -EIO;
3153 } 3153 }
3154 3154
3155 /* VPVersion can't be retrieved before the camera is in HiPower, 3155 /* VPVersion can't be retrieved before the camera is in HiPower,
3156 * so get it here instead of in get_version_information. */ 3156 * so get it here instead of in get_version_information. */
3157 do_command(cam, CPIA_COMMAND_GetVPVersion, 0, 0, 0, 0); 3157 do_command(cam, CPIA_COMMAND_GetVPVersion, 0, 0, 0, 0);
@@ -3193,24 +3193,24 @@ static int cpia_open(struct inode *inode, struct file *file)
3193 if (!cam->raw_image) 3193 if (!cam->raw_image)
3194 goto oops; 3194 goto oops;
3195 } 3195 }
3196 3196
3197 if (!cam->decompressed_frame.data) { 3197 if (!cam->decompressed_frame.data) {
3198 cam->decompressed_frame.data = rvmalloc(CPIA_MAX_FRAME_SIZE); 3198 cam->decompressed_frame.data = rvmalloc(CPIA_MAX_FRAME_SIZE);
3199 if (!cam->decompressed_frame.data) 3199 if (!cam->decompressed_frame.data)
3200 goto oops; 3200 goto oops;
3201 } 3201 }
3202 3202
3203 /* open cpia */ 3203 /* open cpia */
3204 err = -ENODEV; 3204 err = -ENODEV;
3205 if (cam->ops->open(cam->lowlevel_data)) 3205 if (cam->ops->open(cam->lowlevel_data))
3206 goto oops; 3206 goto oops;
3207 3207
3208 /* reset the camera */ 3208 /* reset the camera */
3209 if ((err = reset_camera(cam)) != 0) { 3209 if ((err = reset_camera(cam)) != 0) {
3210 cam->ops->close(cam->lowlevel_data); 3210 cam->ops->close(cam->lowlevel_data);
3211 goto oops; 3211 goto oops;
3212 } 3212 }
3213 3213
3214 err = -EINTR; 3214 err = -EINTR;
3215 if(signal_pending(current)) 3215 if(signal_pending(current))
3216 goto oops; 3216 goto oops;
@@ -3224,7 +3224,7 @@ static int cpia_open(struct inode *inode, struct file *file)
3224 3224
3225 /* init it to something */ 3225 /* init it to something */
3226 cam->mmap_kludge = 0; 3226 cam->mmap_kludge = 0;
3227 3227
3228 ++cam->open_count; 3228 ++cam->open_count;
3229 file->private_data = dev; 3229 file->private_data = dev;
3230 mutex_unlock(&cam->busy_lock); 3230 mutex_unlock(&cam->busy_lock);
@@ -3250,10 +3250,10 @@ static int cpia_close(struct inode *inode, struct file *file)
3250 struct cam_data *cam = dev->priv; 3250 struct cam_data *cam = dev->priv;
3251 3251
3252 if (cam->ops) { 3252 if (cam->ops) {
3253 /* Return ownership of /proc/cpia/videoX to root */ 3253 /* Return ownership of /proc/cpia/videoX to root */
3254 if(cam->proc_entry) 3254 if(cam->proc_entry)
3255 cam->proc_entry->uid = 0; 3255 cam->proc_entry->uid = 0;
3256 3256
3257 /* save camera state for later open (developers guide ch 3.5.3) */ 3257 /* save camera state for later open (developers guide ch 3.5.3) */
3258 save_camera_state(cam); 3258 save_camera_state(cam);
3259 3259
@@ -3342,7 +3342,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
3342 return -EFAULT; 3342 return -EFAULT;
3343 } 3343 }
3344 if (copy_to_user(buf, cam->decompressed_frame.data, 3344 if (copy_to_user(buf, cam->decompressed_frame.data,
3345 cam->decompressed_frame.count)) { 3345 cam->decompressed_frame.count)) {
3346 DBG("copy_to_user failed\n"); 3346 DBG("copy_to_user failed\n");
3347 mutex_unlock(&cam->busy_lock); 3347 mutex_unlock(&cam->busy_lock);
3348 return -EFAULT; 3348 return -EFAULT;
@@ -3361,7 +3361,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3361 3361
3362 if (!cam || !cam->ops) 3362 if (!cam || !cam->ops)
3363 return -ENODEV; 3363 return -ENODEV;
3364 3364
3365 /* make this _really_ smp-safe */ 3365 /* make this _really_ smp-safe */
3366 if (mutex_lock_interruptible(&cam->busy_lock)) 3366 if (mutex_lock_interruptible(&cam->busy_lock))
3367 return -EINTR; 3367 return -EINTR;
@@ -3405,7 +3405,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3405 v->norm = 0; 3405 v->norm = 0;
3406 break; 3406 break;
3407 } 3407 }
3408 3408
3409 case VIDIOCSCHAN: 3409 case VIDIOCSCHAN:
3410 { 3410 {
3411 struct video_channel *v = arg; 3411 struct video_channel *v = arg;
@@ -3424,7 +3424,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3424 *pic = cam->vp; 3424 *pic = cam->vp;
3425 break; 3425 break;
3426 } 3426 }
3427 3427
3428 case VIDIOCSPICT: 3428 case VIDIOCSPICT:
3429 { 3429 {
3430 struct video_picture *vp = arg; 3430 struct video_picture *vp = arg;
@@ -3458,11 +3458,11 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3458 3458
3459 /* Adjust flicker control if necessary */ 3459 /* Adjust flicker control if necessary */
3460 if(cam->params.flickerControl.allowableOverExposure < 0) 3460 if(cam->params.flickerControl.allowableOverExposure < 0)
3461 cam->params.flickerControl.allowableOverExposure = 3461 cam->params.flickerControl.allowableOverExposure =
3462 -find_over_exposure(cam->params.colourParams.brightness); 3462 -find_over_exposure(cam->params.colourParams.brightness);
3463 if(cam->params.flickerControl.flickerMode != 0) 3463 if(cam->params.flickerControl.flickerMode != 0)
3464 cam->cmd_queue |= COMMAND_SETFLICKERCTRL; 3464 cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
3465 3465
3466 3466
3467 /* queue command to update camera */ 3467 /* queue command to update camera */
3468 cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; 3468 cam->cmd_queue |= COMMAND_SETCOLOURPARAMS;
@@ -3482,7 +3482,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3482 *vw = cam->vw; 3482 *vw = cam->vw;
3483 break; 3483 break;
3484 } 3484 }
3485 3485
3486 case VIDIOCSWIN: 3486 case VIDIOCSWIN:
3487 { 3487 {
3488 /* copy_from_user, check validity, copy to internal structure */ 3488 /* copy_from_user, check validity, copy to internal structure */
@@ -3514,7 +3514,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3514 3514
3515 /* video size is changing, reset the subcapture area */ 3515 /* video size is changing, reset the subcapture area */
3516 memset(&cam->vc, 0, sizeof(cam->vc)); 3516 memset(&cam->vc, 0, sizeof(cam->vc));
3517 3517
3518 set_vw_size(cam); 3518 set_vw_size(cam);
3519 DBG("%d / %d\n", cam->vw.width, cam->vw.height); 3519 DBG("%d / %d\n", cam->vw.width, cam->vw.height);
3520 cam->cmd_queue |= COMMAND_SETFORMAT; 3520 cam->cmd_queue |= COMMAND_SETFORMAT;
@@ -3547,7 +3547,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3547 vm->offsets[i] = CPIA_MAX_FRAME_SIZE * i; 3547 vm->offsets[i] = CPIA_MAX_FRAME_SIZE * i;
3548 break; 3548 break;
3549 } 3549 }
3550 3550
3551 case VIDIOCMCAPTURE: 3551 case VIDIOCMCAPTURE:
3552 { 3552 {
3553 struct video_mmap *vm = arg; 3553 struct video_mmap *vm = arg;
@@ -3597,7 +3597,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3597 3597
3598 /* video size is changing, reset the subcapture area */ 3598 /* video size is changing, reset the subcapture area */
3599 memset(&cam->vc, 0, sizeof(cam->vc)); 3599 memset(&cam->vc, 0, sizeof(cam->vc));
3600 3600
3601 set_vw_size(cam); 3601 set_vw_size(cam);
3602 cam->cmd_queue |= COMMAND_SETFORMAT; 3602 cam->cmd_queue |= COMMAND_SETFORMAT;
3603 dispatch_commands(cam); 3603 dispatch_commands(cam);
@@ -3608,7 +3608,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3608 3608
3609 break; 3609 break;
3610 } 3610 }
3611 3611
3612 case VIDIOCSYNC: 3612 case VIDIOCSYNC:
3613 { 3613 {
3614 int *frame = arg; 3614 int *frame = arg;
@@ -3649,7 +3649,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3649 *vc = cam->vc; 3649 *vc = cam->vc;
3650 3650
3651 break; 3651 break;
3652 } 3652 }
3653 3653
3654 case VIDIOCSCAPTURE: 3654 case VIDIOCSCAPTURE:
3655 { 3655 {
@@ -3665,7 +3665,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3665 retval = -EINVAL; 3665 retval = -EINVAL;
3666 break; 3666 break;
3667 } 3667 }
3668 3668
3669 /* Clip to the resolution we can set for the ROI 3669 /* Clip to the resolution we can set for the ROI
3670 (every 8 columns and 4 rows) */ 3670 (every 8 columns and 4 rows) */
3671 vc->x = vc->x & ~(__u32)7; 3671 vc->x = vc->x & ~(__u32)7;
@@ -3681,14 +3681,14 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3681 } 3681 }
3682 3682
3683 DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height); 3683 DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height);
3684 3684
3685 mutex_lock(&cam->param_lock); 3685 mutex_lock(&cam->param_lock);
3686 3686
3687 cam->vc.x = vc->x; 3687 cam->vc.x = vc->x;
3688 cam->vc.y = vc->y; 3688 cam->vc.y = vc->y;
3689 cam->vc.width = vc->width; 3689 cam->vc.width = vc->width;
3690 cam->vc.height = vc->height; 3690 cam->vc.height = vc->height;
3691 3691
3692 set_vw_size(cam); 3692 set_vw_size(cam);
3693 cam->cmd_queue |= COMMAND_SETFORMAT; 3693 cam->cmd_queue |= COMMAND_SETFORMAT;
3694 3694
@@ -3699,7 +3699,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3699 dispatch_commands(cam); 3699 dispatch_commands(cam);
3700 break; 3700 break;
3701 } 3701 }
3702 3702
3703 case VIDIOCGUNIT: 3703 case VIDIOCGUNIT:
3704 { 3704 {
3705 struct video_unit *vu = arg; 3705 struct video_unit *vu = arg;
@@ -3715,7 +3715,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3715 break; 3715 break;
3716 } 3716 }
3717 3717
3718 3718
3719 /* pointless to implement overlay with this camera */ 3719 /* pointless to implement overlay with this camera */
3720 case VIDIOCCAPTURE: 3720 case VIDIOCCAPTURE:
3721 case VIDIOCGFBUF: 3721 case VIDIOCGFBUF:
@@ -3738,7 +3738,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3738 3738
3739 mutex_unlock(&cam->busy_lock); 3739 mutex_unlock(&cam->busy_lock);
3740 return retval; 3740 return retval;
3741} 3741}
3742 3742
3743static int cpia_ioctl(struct inode *inode, struct file *file, 3743static int cpia_ioctl(struct inode *inode, struct file *file,
3744 unsigned int cmd, unsigned long arg) 3744 unsigned int cmd, unsigned long arg)
@@ -3759,7 +3759,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3759 3759
3760 if (!cam || !cam->ops) 3760 if (!cam || !cam->ops)
3761 return -ENODEV; 3761 return -ENODEV;
3762 3762
3763 DBG("cpia_mmap: %ld\n", size); 3763 DBG("cpia_mmap: %ld\n", size);
3764 3764
3765 if (size > FRAME_NUM*CPIA_MAX_FRAME_SIZE) 3765 if (size > FRAME_NUM*CPIA_MAX_FRAME_SIZE)
@@ -3767,7 +3767,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3767 3767
3768 if (!cam || !cam->ops) 3768 if (!cam || !cam->ops)
3769 return -ENODEV; 3769 return -ENODEV;
3770 3770
3771 /* make this _really_ smp-safe */ 3771 /* make this _really_ smp-safe */
3772 if (mutex_lock_interruptible(&cam->busy_lock)) 3772 if (mutex_lock_interruptible(&cam->busy_lock))
3773 return -EINTR; 3773 return -EINTR;
@@ -3851,11 +3851,11 @@ static void reset_camera_struct(struct cam_data *cam)
3851 cam->params.flickerControl.flickerMode = 0; 3851 cam->params.flickerControl.flickerMode = 0;
3852 cam->params.flickerControl.disabled = 1; 3852 cam->params.flickerControl.disabled = 1;
3853 3853
3854 cam->params.flickerControl.coarseJump = 3854 cam->params.flickerControl.coarseJump =
3855 flicker_jumps[cam->mainsFreq] 3855 flicker_jumps[cam->mainsFreq]
3856 [cam->params.sensorFps.baserate] 3856 [cam->params.sensorFps.baserate]
3857 [cam->params.sensorFps.divisor]; 3857 [cam->params.sensorFps.divisor];
3858 cam->params.flickerControl.allowableOverExposure = 3858 cam->params.flickerControl.allowableOverExposure =
3859 -find_over_exposure(cam->params.colourParams.brightness); 3859 -find_over_exposure(cam->params.colourParams.brightness);
3860 cam->params.vlOffset.gain1 = 20; 3860 cam->params.vlOffset.gain1 = 20;
3861 cam->params.vlOffset.gain2 = 24; 3861 cam->params.vlOffset.gain2 = 24;
@@ -3870,21 +3870,21 @@ static void reset_camera_struct(struct cam_data *cam)
3870 cam->params.compressionParams.qDiffStepThresh = 3; 3870 cam->params.compressionParams.qDiffStepThresh = 3;
3871 cam->params.compressionParams.decimationThreshMod = 2; 3871 cam->params.compressionParams.decimationThreshMod = 2;
3872 /* End of default values from Software Developer's Guide */ 3872 /* End of default values from Software Developer's Guide */
3873 3873
3874 cam->transfer_rate = 0; 3874 cam->transfer_rate = 0;
3875 cam->exposure_status = EXPOSURE_NORMAL; 3875 cam->exposure_status = EXPOSURE_NORMAL;
3876 3876
3877 /* Set Sensor FPS to 15fps. This seems better than 30fps 3877 /* Set Sensor FPS to 15fps. This seems better than 30fps
3878 * for indoor lighting. */ 3878 * for indoor lighting. */
3879 cam->params.sensorFps.divisor = 1; 3879 cam->params.sensorFps.divisor = 1;
3880 cam->params.sensorFps.baserate = 1; 3880 cam->params.sensorFps.baserate = 1;
3881 3881
3882 cam->params.yuvThreshold.yThreshold = 6; /* From windows driver */ 3882 cam->params.yuvThreshold.yThreshold = 6; /* From windows driver */
3883 cam->params.yuvThreshold.uvThreshold = 6; /* From windows driver */ 3883 cam->params.yuvThreshold.uvThreshold = 6; /* From windows driver */
3884 3884
3885 cam->params.format.subSample = SUBSAMPLE_422; 3885 cam->params.format.subSample = SUBSAMPLE_422;
3886 cam->params.format.yuvOrder = YUVORDER_YUYV; 3886 cam->params.format.yuvOrder = YUVORDER_YUYV;
3887 3887
3888 cam->params.compression.mode = CPIA_COMPRESSION_AUTO; 3888 cam->params.compression.mode = CPIA_COMPRESSION_AUTO;
3889 cam->params.compressionTarget.frTargeting = 3889 cam->params.compressionTarget.frTargeting =
3890 CPIA_COMPRESSION_TARGET_QUALITY; 3890 CPIA_COMPRESSION_TARGET_QUALITY;
@@ -3898,7 +3898,7 @@ static void reset_camera_struct(struct cam_data *cam)
3898 cam->params.qx3.cradled = 0; 3898 cam->params.qx3.cradled = 0;
3899 3899
3900 cam->video_size = VIDEOSIZE_CIF; 3900 cam->video_size = VIDEOSIZE_CIF;
3901 3901
3902 cam->vp.colour = 32768; /* 50% */ 3902 cam->vp.colour = 32768; /* 50% */
3903 cam->vp.hue = 32768; /* 50% */ 3903 cam->vp.hue = 32768; /* 50% */
3904 cam->vp.brightness = 32768; /* 50% */ 3904 cam->vp.brightness = 32768; /* 50% */
@@ -3911,7 +3911,7 @@ static void reset_camera_struct(struct cam_data *cam)
3911 cam->vc.y = 0; 3911 cam->vc.y = 0;
3912 cam->vc.width = 0; 3912 cam->vc.width = 0;
3913 cam->vc.height = 0; 3913 cam->vc.height = 0;
3914 3914
3915 cam->vw.x = 0; 3915 cam->vw.x = 0;
3916 cam->vw.y = 0; 3916 cam->vw.y = 0;
3917 set_vw_size(cam); 3917 set_vw_size(cam);
@@ -3928,7 +3928,7 @@ static void reset_camera_struct(struct cam_data *cam)
3928 3928
3929/* initialize cam_data structure */ 3929/* initialize cam_data structure */
3930static void init_camera_struct(struct cam_data *cam, 3930static void init_camera_struct(struct cam_data *cam,
3931 struct cpia_camera_ops *ops ) 3931 struct cpia_camera_ops *ops )
3932{ 3932{
3933 int i; 3933 int i;
3934 3934
@@ -3945,7 +3945,7 @@ static void init_camera_struct(struct cam_data *cam,
3945 3945
3946 memcpy(&cam->vdev, &cpia_template, sizeof(cpia_template)); 3946 memcpy(&cam->vdev, &cpia_template, sizeof(cpia_template));
3947 cam->vdev.priv = cam; 3947 cam->vdev.priv = cam;
3948 3948
3949 cam->curframe = 0; 3949 cam->curframe = 0;
3950 for (i = 0; i < FRAME_NUM; i++) { 3950 for (i = 0; i < FRAME_NUM; i++) {
3951 cam->frame[i].width = 0; 3951 cam->frame[i].width = 0;
@@ -3961,15 +3961,15 @@ static void init_camera_struct(struct cam_data *cam,
3961 3961
3962struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowlevel) 3962struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowlevel)
3963{ 3963{
3964 struct cam_data *camera; 3964 struct cam_data *camera;
3965 3965
3966 if ((camera = kmalloc(sizeof(struct cam_data), GFP_KERNEL)) == NULL) 3966 if ((camera = kmalloc(sizeof(struct cam_data), GFP_KERNEL)) == NULL)
3967 return NULL; 3967 return NULL;
3968 3968
3969 3969
3970 init_camera_struct( camera, ops ); 3970 init_camera_struct( camera, ops );
3971 camera->lowlevel_data = lowlevel; 3971 camera->lowlevel_data = lowlevel;
3972 3972
3973 /* register v4l device */ 3973 /* register v4l device */
3974 if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { 3974 if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
3975 kfree(camera); 3975 kfree(camera);
@@ -3982,7 +3982,7 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve
3982 /* open cpia */ 3982 /* open cpia */
3983 if (camera->ops->open(camera->lowlevel_data)) 3983 if (camera->ops->open(camera->lowlevel_data))
3984 return camera; 3984 return camera;
3985 3985
3986 /* reset the camera */ 3986 /* reset the camera */
3987 if (reset_camera(camera) != 0) { 3987 if (reset_camera(camera) != 0) {
3988 camera->ops->close(camera->lowlevel_data); 3988 camera->ops->close(camera->lowlevel_data);
@@ -4022,11 +4022,11 @@ void cpia_unregister_camera(struct cam_data *cam)
4022 DBG("camera open -- setting ops to NULL\n"); 4022 DBG("camera open -- setting ops to NULL\n");
4023 cam->ops = NULL; 4023 cam->ops = NULL;
4024 } 4024 }
4025 4025
4026#ifdef CONFIG_PROC_FS 4026#ifdef CONFIG_PROC_FS
4027 DBG("destroying /proc/cpia/video%d\n", cam->vdev.minor); 4027 DBG("destroying /proc/cpia/video%d\n", cam->vdev.minor);
4028 destroy_proc_cpia_cam(cam); 4028 destroy_proc_cpia_cam(cam);
4029#endif 4029#endif
4030 if (!cam->open_count) { 4030 if (!cam->open_count) {
4031 DBG("freeing camera\n"); 4031 DBG("freeing camera\n");
4032 kfree(cam); 4032 kfree(cam);
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h
index de6678200a57..dde27a6a4a09 100644
--- a/drivers/media/video/cpia.h
+++ b/drivers/media/video/cpia.h
@@ -52,10 +52,10 @@
52struct cpia_camera_ops 52struct cpia_camera_ops
53{ 53{
54 /* open sets privdata to point to structure for this camera. 54 /* open sets privdata to point to structure for this camera.
55 * Returns negative value on error, otherwise 0. 55 * Returns negative value on error, otherwise 0.
56 */ 56 */
57 int (*open)(void *privdata); 57 int (*open)(void *privdata);
58 58
59 /* Registers callback function cb to be called with cbdata 59 /* Registers callback function cb to be called with cbdata
60 * when an image is ready. If cb is NULL, only single image grabs 60 * when an image is ready. If cb is NULL, only single image grabs
61 * should be used. cb should immediately call streamRead to read 61 * should be used. cb should immediately call streamRead to read
@@ -63,8 +63,8 @@ struct cpia_camera_ops
63 * otherwise 0. 63 * otherwise 0.
64 */ 64 */
65 int (*registerCallback)(void *privdata, void (*cb)(void *cbdata), 65 int (*registerCallback)(void *privdata, void (*cb)(void *cbdata),
66 void *cbdata); 66 void *cbdata);
67 67
68 /* transferCmd sends commands to the camera. command MUST point to 68 /* transferCmd sends commands to the camera. command MUST point to
69 * an 8 byte buffer in kernel space. data can be NULL if no extra 69 * an 8 byte buffer in kernel space. data can be NULL if no extra
70 * data is needed. The size of the data is given by the last 2 70 * data is needed. The size of the data is given by the last 2
@@ -77,30 +77,30 @@ struct cpia_camera_ops
77 * Returns negative value on error, otherwise 0. 77 * Returns negative value on error, otherwise 0.
78 */ 78 */
79 int (*streamStart)(void *privdata); 79 int (*streamStart)(void *privdata);
80 80
81 /* streamStop terminates stream capture mode. 81 /* streamStop terminates stream capture mode.
82 * Returns negative value on error, otherwise 0. 82 * Returns negative value on error, otherwise 0.
83 */ 83 */
84 int (*streamStop)(void *privdata); 84 int (*streamStop)(void *privdata);
85 85
86 /* streamRead reads a frame from the camera. buffer points to a 86 /* streamRead reads a frame from the camera. buffer points to a
87 * buffer large enough to hold a complete frame in kernel space. 87 * buffer large enough to hold a complete frame in kernel space.
88 * noblock indicates if this should be a non blocking read. 88 * noblock indicates if this should be a non blocking read.
89 * Returns the number of bytes read, or negative value on error. 89 * Returns the number of bytes read, or negative value on error.
90 */ 90 */
91 int (*streamRead)(void *privdata, u8 *buffer, int noblock); 91 int (*streamRead)(void *privdata, u8 *buffer, int noblock);
92 92
93 /* close disables the device until open() is called again. 93 /* close disables the device until open() is called again.
94 * Returns negative value on error, otherwise 0. 94 * Returns negative value on error, otherwise 0.
95 */ 95 */
96 int (*close)(void *privdata); 96 int (*close)(void *privdata);
97 97
98 /* If wait_for_stream_ready is non-zero, wait until the streamState 98 /* If wait_for_stream_ready is non-zero, wait until the streamState
99 * is STREAM_READY before calling streamRead. 99 * is STREAM_READY before calling streamRead.
100 */ 100 */
101 int wait_for_stream_ready; 101 int wait_for_stream_ready;
102 102
103 /* 103 /*
104 * Used to maintain lowlevel module usage counts 104 * Used to maintain lowlevel module usage counts
105 */ 105 */
106 struct module *owner; 106 struct module *owner;
@@ -215,14 +215,14 @@ struct cam_params {
215 u8 videoSize; /* CIF/QCIF */ 215 u8 videoSize; /* CIF/QCIF */
216 u8 subSample; 216 u8 subSample;
217 u8 yuvOrder; 217 u8 yuvOrder;
218 } format; 218 } format;
219 struct { /* Intel QX3 specific data */ 219 struct { /* Intel QX3 specific data */
220 u8 qx3_detected; /* a QX3 is present */ 220 u8 qx3_detected; /* a QX3 is present */
221 u8 toplight; /* top light lit , R/W */ 221 u8 toplight; /* top light lit , R/W */
222 u8 bottomlight; /* bottom light lit, R/W */ 222 u8 bottomlight; /* bottom light lit, R/W */
223 u8 button; /* snapshot button pressed (R/O) */ 223 u8 button; /* snapshot button pressed (R/O) */
224 u8 cradled; /* microscope is in cradle (R/O) */ 224 u8 cradled; /* microscope is in cradle (R/O) */
225 } qx3; 225 } qx3;
226 struct { 226 struct {
227 u8 colStart; /* skip first 8*colStart pixels */ 227 u8 colStart; /* skip first 8*colStart pixels */
228 u8 colEnd; /* finish at 8*colEnd pixels */ 228 u8 colEnd; /* finish at 8*colEnd pixels */
@@ -247,13 +247,13 @@ enum v4l_camstates {
247struct cam_data { 247struct cam_data {
248 struct list_head cam_data_list; 248 struct list_head cam_data_list;
249 249
250 struct mutex busy_lock; /* guard against SMP multithreading */ 250 struct mutex busy_lock; /* guard against SMP multithreading */
251 struct cpia_camera_ops *ops; /* lowlevel driver operations */ 251 struct cpia_camera_ops *ops; /* lowlevel driver operations */
252 void *lowlevel_data; /* private data for lowlevel driver */ 252 void *lowlevel_data; /* private data for lowlevel driver */
253 u8 *raw_image; /* buffer for raw image data */ 253 u8 *raw_image; /* buffer for raw image data */
254 struct cpia_frame decompressed_frame; 254 struct cpia_frame decompressed_frame;
255 /* buffer to hold decompressed frame */ 255 /* buffer to hold decompressed frame */
256 int image_size; /* sizeof last decompressed image */ 256 int image_size; /* sizeof last decompressed image */
257 int open_count; /* # of process that have camera open */ 257 int open_count; /* # of process that have camera open */
258 258
259 /* camera status */ 259 /* camera status */
@@ -265,7 +265,7 @@ struct cam_data {
265 struct mutex param_lock; /* params lock for this camera */ 265 struct mutex param_lock; /* params lock for this camera */
266 struct cam_params params; /* camera settings */ 266 struct cam_params params; /* camera settings */
267 struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */ 267 struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */
268 268
269 /* v4l */ 269 /* v4l */
270 int video_size; /* VIDEO_SIZE_ */ 270 int video_size; /* VIDEO_SIZE_ */
271 volatile enum v4l_camstates camstate; /* v4l layer status */ 271 volatile enum v4l_camstates camstate; /* v4l layer status */
@@ -277,7 +277,7 @@ struct cam_data {
277 /* mmap interface */ 277 /* mmap interface */
278 int curframe; /* the current frame to grab into */ 278 int curframe; /* the current frame to grab into */
279 u8 *frame_buf; /* frame buffer data */ 279 u8 *frame_buf; /* frame buffer data */
280 struct cpia_frame frame[FRAME_NUM]; 280 struct cpia_frame frame[FRAME_NUM];
281 /* FRAME_NUM-buffering, so we need a array */ 281 /* FRAME_NUM-buffering, so we need a array */
282 282
283 int first_frame; 283 int first_frame;
@@ -424,7 +424,7 @@ void cpia_unregister_camera(struct cam_data *cam);
424#define DEB_BYTE(p)\ 424#define DEB_BYTE(p)\
425 DBG("%1d %1d %1d %1d %1d %1d %1d %1d \n",\ 425 DBG("%1d %1d %1d %1d %1d %1d %1d %1d \n",\
426 (p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\ 426 (p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\
427 (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0); 427 (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0);
428 428
429#endif /* __KERNEL__ */ 429#endif /* __KERNEL__ */
430 430
diff --git a/drivers/media/video/cpia2/cpia2.h b/drivers/media/video/cpia2/cpia2.h
index 95d3afa94a3d..8394283993f6 100644
--- a/drivers/media/video/cpia2/cpia2.h
+++ b/drivers/media/video/cpia2/cpia2.h
@@ -381,7 +381,7 @@ struct cpia2_fh {
381 381
382struct camera_data { 382struct camera_data {
383 /* locks */ 383 /* locks */
384 struct semaphore busy_lock; /* guard against SMP multithreading */ 384 struct mutex busy_lock; /* guard against SMP multithreading */
385 struct v4l2_prio_state prio; 385 struct v4l2_prio_state prio;
386 386
387 /* camera status */ 387 /* camera status */
diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c
index 5dfb242d5b8c..fd771c7a2fe2 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)
2238 memset(cam, 0, sizeof(struct camera_data)); 2238 memset(cam, 0, sizeof(struct camera_data));
2239 2239
2240 cam->present = 1; 2240 cam->present = 1;
2241 init_MUTEX(&cam->busy_lock); 2241 mutex_init(&cam->busy_lock);
2242 init_waitqueue_head(&cam->wq_stream); 2242 init_waitqueue_head(&cam->wq_stream);
2243 2243
2244 return cam; 2244 return cam;
@@ -2371,12 +2371,12 @@ long cpia2_read(struct camera_data *cam,
2371 } 2371 }
2372 2372
2373 /* make this _really_ smp and multithread-safe */ 2373 /* make this _really_ smp and multithread-safe */
2374 if (down_interruptible(&cam->busy_lock)) 2374 if (mutex_lock_interruptible(&cam->busy_lock))
2375 return -ERESTARTSYS; 2375 return -ERESTARTSYS;
2376 2376
2377 if (!cam->present) { 2377 if (!cam->present) {
2378 LOG("%s: camera removed\n",__FUNCTION__); 2378 LOG("%s: camera removed\n",__FUNCTION__);
2379 up(&cam->busy_lock); 2379 mutex_unlock(&cam->busy_lock);
2380 return 0; /* EOF */ 2380 return 0; /* EOF */
2381 } 2381 }
2382 2382
@@ -2389,34 +2389,34 @@ long cpia2_read(struct camera_data *cam,
2389 /* Copy cam->curbuff in case it changes while we're processing */ 2389 /* Copy cam->curbuff in case it changes while we're processing */
2390 frame = cam->curbuff; 2390 frame = cam->curbuff;
2391 if (noblock && frame->status != FRAME_READY) { 2391 if (noblock && frame->status != FRAME_READY) {
2392 up(&cam->busy_lock); 2392 mutex_unlock(&cam->busy_lock);
2393 return -EAGAIN; 2393 return -EAGAIN;
2394 } 2394 }
2395 2395
2396 if(frame->status != FRAME_READY) { 2396 if(frame->status != FRAME_READY) {
2397 up(&cam->busy_lock); 2397 mutex_unlock(&cam->busy_lock);
2398 wait_event_interruptible(cam->wq_stream, 2398 wait_event_interruptible(cam->wq_stream,
2399 !cam->present || 2399 !cam->present ||
2400 (frame = cam->curbuff)->status == FRAME_READY); 2400 (frame = cam->curbuff)->status == FRAME_READY);
2401 if (signal_pending(current)) 2401 if (signal_pending(current))
2402 return -ERESTARTSYS; 2402 return -ERESTARTSYS;
2403 /* make this _really_ smp and multithread-safe */ 2403 /* make this _really_ smp and multithread-safe */
2404 if (down_interruptible(&cam->busy_lock)) { 2404 if (mutex_lock_interruptible(&cam->busy_lock)) {
2405 return -ERESTARTSYS; 2405 return -ERESTARTSYS;
2406 } 2406 }
2407 if(!cam->present) { 2407 if(!cam->present) {
2408 up(&cam->busy_lock); 2408 mutex_unlock(&cam->busy_lock);
2409 return 0; 2409 return 0;
2410 } 2410 }
2411 } 2411 }
2412 2412
2413 /* copy data to user space */ 2413 /* copy data to user space */
2414 if (frame->length > count) { 2414 if (frame->length > count) {
2415 up(&cam->busy_lock); 2415 mutex_unlock(&cam->busy_lock);
2416 return -EFAULT; 2416 return -EFAULT;
2417 } 2417 }
2418 if (copy_to_user(buf, frame->data, frame->length)) { 2418 if (copy_to_user(buf, frame->data, frame->length)) {
2419 up(&cam->busy_lock); 2419 mutex_unlock(&cam->busy_lock);
2420 return -EFAULT; 2420 return -EFAULT;
2421 } 2421 }
2422 2422
@@ -2424,7 +2424,7 @@ long cpia2_read(struct camera_data *cam,
2424 2424
2425 frame->status = FRAME_EMPTY; 2425 frame->status = FRAME_EMPTY;
2426 2426
2427 up(&cam->busy_lock); 2427 mutex_unlock(&cam->busy_lock);
2428 return count; 2428 return count;
2429} 2429}
2430 2430
@@ -2443,10 +2443,10 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
2443 return POLLERR; 2443 return POLLERR;
2444 } 2444 }
2445 2445
2446 down(&cam->busy_lock); 2446 mutex_lock(&cam->busy_lock);
2447 2447
2448 if(!cam->present) { 2448 if(!cam->present) {
2449 up(&cam->busy_lock); 2449 mutex_unlock(&cam->busy_lock);
2450 return POLLHUP; 2450 return POLLHUP;
2451 } 2451 }
2452 2452
@@ -2456,16 +2456,16 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
2456 cam->params.camera_state.stream_mode); 2456 cam->params.camera_state.stream_mode);
2457 } 2457 }
2458 2458
2459 up(&cam->busy_lock); 2459 mutex_unlock(&cam->busy_lock);
2460 poll_wait(filp, &cam->wq_stream, wait); 2460 poll_wait(filp, &cam->wq_stream, wait);
2461 down(&cam->busy_lock); 2461 mutex_lock(&cam->busy_lock);
2462 2462
2463 if(!cam->present) 2463 if(!cam->present)
2464 status = POLLHUP; 2464 status = POLLHUP;
2465 else if(cam->curbuff->status == FRAME_READY) 2465 else if(cam->curbuff->status == FRAME_READY)
2466 status = POLLIN | POLLRDNORM; 2466 status = POLLIN | POLLRDNORM;
2467 2467
2468 up(&cam->busy_lock); 2468 mutex_unlock(&cam->busy_lock);
2469 return status; 2469 return status;
2470} 2470}
2471 2471
@@ -2488,18 +2488,18 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
2488 DBG("mmap offset:%ld size:%ld\n", start_offset, size); 2488 DBG("mmap offset:%ld size:%ld\n", start_offset, size);
2489 2489
2490 /* make this _really_ smp-safe */ 2490 /* make this _really_ smp-safe */
2491 if (down_interruptible(&cam->busy_lock)) 2491 if (mutex_lock_interruptible(&cam->busy_lock))
2492 return -ERESTARTSYS; 2492 return -ERESTARTSYS;
2493 2493
2494 if (!cam->present) { 2494 if (!cam->present) {
2495 up(&cam->busy_lock); 2495 mutex_unlock(&cam->busy_lock);
2496 return -ENODEV; 2496 return -ENODEV;
2497 } 2497 }
2498 2498
2499 if (size > cam->frame_size*cam->num_frames || 2499 if (size > cam->frame_size*cam->num_frames ||
2500 (start_offset % cam->frame_size) != 0 || 2500 (start_offset % cam->frame_size) != 0 ||
2501 (start_offset+size > cam->frame_size*cam->num_frames)) { 2501 (start_offset+size > cam->frame_size*cam->num_frames)) {
2502 up(&cam->busy_lock); 2502 mutex_unlock(&cam->busy_lock);
2503 return -EINVAL; 2503 return -EINVAL;
2504 } 2504 }
2505 2505
@@ -2507,7 +2507,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
2507 while (size > 0) { 2507 while (size > 0) {
2508 page = kvirt_to_pa(pos); 2508 page = kvirt_to_pa(pos);
2509 if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) { 2509 if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) {
2510 up(&cam->busy_lock); 2510 mutex_unlock(&cam->busy_lock);
2511 return -EAGAIN; 2511 return -EAGAIN;
2512 } 2512 }
2513 start += PAGE_SIZE; 2513 start += PAGE_SIZE;
@@ -2519,7 +2519,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
2519 } 2519 }
2520 2520
2521 cam->mmapped = true; 2521 cam->mmapped = true;
2522 up(&cam->busy_lock); 2522 mutex_unlock(&cam->busy_lock);
2523 return 0; 2523 return 0;
2524} 2524}
2525 2525
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 08f8be345fa8..481e178ef56d 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)
255 return -ENODEV; 255 return -ENODEV;
256 } 256 }
257 257
258 if(down_interruptible(&cam->busy_lock)) 258 if(mutex_lock_interruptible(&cam->busy_lock))
259 return -ERESTARTSYS; 259 return -ERESTARTSYS;
260 260
261 if(!cam->present) { 261 if(!cam->present) {
@@ -299,7 +299,7 @@ skip_init:
299 cpia2_dbg_dump_registers(cam); 299 cpia2_dbg_dump_registers(cam);
300 300
301err_return: 301err_return:
302 up(&cam->busy_lock); 302 mutex_unlock(&cam->busy_lock);
303 return retval; 303 return retval;
304} 304}
305 305
@@ -314,7 +314,7 @@ static int cpia2_close(struct inode *inode, struct file *file)
314 struct camera_data *cam = video_get_drvdata(dev); 314 struct camera_data *cam = video_get_drvdata(dev);
315 struct cpia2_fh *fh = file->private_data; 315 struct cpia2_fh *fh = file->private_data;
316 316
317 down(&cam->busy_lock); 317 mutex_lock(&cam->busy_lock);
318 318
319 if (cam->present && 319 if (cam->present &&
320 (cam->open_count == 1 320 (cam->open_count == 1
@@ -347,7 +347,7 @@ static int cpia2_close(struct inode *inode, struct file *file)
347 } 347 }
348 } 348 }
349 349
350 up(&cam->busy_lock); 350 mutex_unlock(&cam->busy_lock);
351 351
352 return 0; 352 return 0;
353} 353}
@@ -523,11 +523,11 @@ static int sync(struct camera_data *cam, int frame_nr)
523 return 0; 523 return 0;
524 } 524 }
525 525
526 up(&cam->busy_lock); 526 mutex_unlock(&cam->busy_lock);
527 wait_event_interruptible(cam->wq_stream, 527 wait_event_interruptible(cam->wq_stream,
528 !cam->streaming || 528 !cam->streaming ||
529 frame->status == FRAME_READY); 529 frame->status == FRAME_READY);
530 down(&cam->busy_lock); 530 mutex_lock(&cam->busy_lock);
531 if (signal_pending(current)) 531 if (signal_pending(current))
532 return -ERESTARTSYS; 532 return -ERESTARTSYS;
533 if(!cam->present) 533 if(!cam->present)
@@ -1544,11 +1544,11 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file)
1544 if(frame < 0) { 1544 if(frame < 0) {
1545 /* Wait for a frame to become available */ 1545 /* Wait for a frame to become available */
1546 struct framebuf *cb=cam->curbuff; 1546 struct framebuf *cb=cam->curbuff;
1547 up(&cam->busy_lock); 1547 mutex_unlock(&cam->busy_lock);
1548 wait_event_interruptible(cam->wq_stream, 1548 wait_event_interruptible(cam->wq_stream,
1549 !cam->present || 1549 !cam->present ||
1550 (cb=cam->curbuff)->status == FRAME_READY); 1550 (cb=cam->curbuff)->status == FRAME_READY);
1551 down(&cam->busy_lock); 1551 mutex_lock(&cam->busy_lock);
1552 if (signal_pending(current)) 1552 if (signal_pending(current))
1553 return -ERESTARTSYS; 1553 return -ERESTARTSYS;
1554 if(!cam->present) 1554 if(!cam->present)
@@ -1591,11 +1591,11 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
1591 return -ENOTTY; 1591 return -ENOTTY;
1592 1592
1593 /* make this _really_ smp-safe */ 1593 /* make this _really_ smp-safe */
1594 if (down_interruptible(&cam->busy_lock)) 1594 if (mutex_lock_interruptible(&cam->busy_lock))
1595 return -ERESTARTSYS; 1595 return -ERESTARTSYS;
1596 1596
1597 if (!cam->present) { 1597 if (!cam->present) {
1598 up(&cam->busy_lock); 1598 mutex_unlock(&cam->busy_lock);
1599 return -ENODEV; 1599 return -ENODEV;
1600 } 1600 }
1601 1601
@@ -1608,7 +1608,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
1608 struct cpia2_fh *fh = file->private_data; 1608 struct cpia2_fh *fh = file->private_data;
1609 retval = v4l2_prio_check(&cam->prio, &fh->prio); 1609 retval = v4l2_prio_check(&cam->prio, &fh->prio);
1610 if(retval) { 1610 if(retval) {
1611 up(&cam->busy_lock); 1611 mutex_unlock(&cam->busy_lock);
1612 return retval; 1612 return retval;
1613 } 1613 }
1614 break; 1614 break;
@@ -1618,7 +1618,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
1618 { 1618 {
1619 struct cpia2_fh *fh = file->private_data; 1619 struct cpia2_fh *fh = file->private_data;
1620 if(fh->prio != V4L2_PRIORITY_RECORD) { 1620 if(fh->prio != V4L2_PRIORITY_RECORD) {
1621 up(&cam->busy_lock); 1621 mutex_unlock(&cam->busy_lock);
1622 return -EBUSY; 1622 return -EBUSY;
1623 } 1623 }
1624 break; 1624 break;
@@ -1847,7 +1847,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
1847 break; 1847 break;
1848 } 1848 }
1849 1849
1850 up(&cam->busy_lock); 1850 mutex_unlock(&cam->busy_lock);
1851 return retval; 1851 return retval;
1852} 1852}
1853 1853
@@ -1924,14 +1924,15 @@ static void reset_camera_struct_v4l(struct camera_data *cam)
1924 * The v4l video device structure initialized for this device 1924 * The v4l video device structure initialized for this device
1925 ***/ 1925 ***/
1926static struct file_operations fops_template = { 1926static struct file_operations fops_template = {
1927 .owner= THIS_MODULE, 1927 .owner = THIS_MODULE,
1928 .open= cpia2_open, 1928 .open = cpia2_open,
1929 .release= cpia2_close, 1929 .release = cpia2_close,
1930 .read= cpia2_v4l_read, 1930 .read = cpia2_v4l_read,
1931 .poll= cpia2_v4l_poll, 1931 .poll = cpia2_v4l_poll,
1932 .ioctl= cpia2_ioctl, 1932 .ioctl = cpia2_ioctl,
1933 .llseek= no_llseek, 1933 .llseek = no_llseek,
1934 .mmap= cpia2_mmap, 1934 .compat_ioctl = v4l_compat_ioctl32,
1935 .mmap = cpia2_mmap,
1935}; 1936};
1936 1937
1937static struct video_device cpia2_template = { 1938static struct video_device cpia2_template = {
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 74cff626e044..3021f21aae36 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 25/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
26/* #define _CPIA_DEBUG_ 1 */ 26/* #define _CPIA_DEBUG_ 1 */
27 27
28#include <linux/config.h> 28#include <linux/config.h>
29 29
@@ -45,7 +45,7 @@
45 45
46static int cpia_pp_open(void *privdata); 46static int cpia_pp_open(void *privdata);
47static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata), 47static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata),
48 void *cbdata); 48 void *cbdata);
49static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data); 49static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data);
50static int cpia_pp_streamStart(void *privdata); 50static int cpia_pp_streamStart(void *privdata);
51static int cpia_pp_streamStop(void *privdata); 51static int cpia_pp_streamStop(void *privdata);
@@ -93,7 +93,7 @@ struct pp_cam_entry {
93 int stream_irq; 93 int stream_irq;
94}; 94};
95 95
96static struct cpia_camera_ops cpia_pp_ops = 96static struct cpia_camera_ops cpia_pp_ops =
97{ 97{
98 cpia_pp_open, 98 cpia_pp_open,
99 cpia_pp_registerCallback, 99 cpia_pp_registerCallback,
@@ -123,7 +123,7 @@ static void cpia_parport_disable_irq( struct parport *port ) {
123} 123}
124 124
125/* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility 125/* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility
126 * Link Flag during negotiation */ 126 * Link Flag during negotiation */
127#define UPLOAD_FLAG 0x08 127#define UPLOAD_FLAG 0x08
128#define NIBBLE_TRANSFER 0x01 128#define NIBBLE_TRANSFER 0x01
129#define ECP_TRANSFER 0x03 129#define ECP_TRANSFER 0x03
@@ -139,17 +139,17 @@ static void cpia_parport_disable_irq( struct parport *port ) {
139/* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */ 139/* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */
140/* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */ 140/* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */
141 141
142static size_t cpia_read_nibble (struct parport *port, 142static size_t cpia_read_nibble (struct parport *port,
143 void *buffer, size_t len, 143 void *buffer, size_t len,
144 int flags) 144 int flags)
145{ 145{
146 /* adapted verbatim, with one change, from 146 /* adapted verbatim, with one change, from
147 parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */ 147 parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */
148 148
149 unsigned char *buf = buffer; 149 unsigned char *buf = buffer;
150 int i; 150 int i;
151 unsigned char byte = 0; 151 unsigned char byte = 0;
152 152
153 len *= 2; /* in nibbles */ 153 len *= 2; /* in nibbles */
154 for (i=0; i < len; i++) { 154 for (i=0; i < len; i++) {
155 unsigned char nibble; 155 unsigned char nibble;
@@ -158,12 +158,12 @@ static size_t cpia_read_nibble (struct parport *port,
158 * after every second nibble to signal that more 158 * after every second nibble to signal that more
159 * data is available. (the total number of Bytes that 159 * data is available. (the total number of Bytes that
160 * should be sent is known; if too few are received, an error 160 * should be sent is known; if too few are received, an error
161 * will be recorded after a timeout). 161 * will be recorded after a timeout).
162 * This is incompatible with parport_ieee1284_read_nibble(), 162 * This is incompatible with parport_ieee1284_read_nibble(),
163 * which expects to find nFault LO after every second nibble. 163 * which expects to find nFault LO after every second nibble.
164 */ 164 */
165 165
166 /* Solution: modify cpia_read_nibble to only check for 166 /* Solution: modify cpia_read_nibble to only check for
167 * nDataAvail before the first nibble is sent. 167 * nDataAvail before the first nibble is sent.
168 */ 168 */
169 169
@@ -216,7 +216,7 @@ static size_t cpia_read_nibble (struct parport *port,
216 /* Second nibble */ 216 /* Second nibble */
217 byte |= nibble << 4; 217 byte |= nibble << 4;
218 *buf++ = byte; 218 *buf++ = byte;
219 } else 219 } else
220 byte = nibble; 220 byte = nibble;
221 } 221 }
222 222
@@ -238,18 +238,18 @@ static size_t cpia_read_nibble (struct parport *port,
238} 238}
239 239
240/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) 240/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1)
241 * (See CPiA Data sheet p. 31) 241 * (See CPiA Data sheet p. 31)
242 * 242 *
243 * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a 243 * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a
244 * nonstandard variant of nibble mode which allows the same (mediocre) 244 * nonstandard variant of nibble mode which allows the same (mediocre)
245 * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable 245 * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable
246 * parallel ports, but works also for non-TRISTATE-capable ports. 246 * parallel ports, but works also for non-TRISTATE-capable ports.
247 * (Standard nibble mode only send 4 bits per cycle) 247 * (Standard nibble mode only send 4 bits per cycle)
248 * 248 *
249 */ 249 */
250 250
251static size_t cpia_read_nibble_stream(struct parport *port, 251static size_t cpia_read_nibble_stream(struct parport *port,
252 void *buffer, size_t len, 252 void *buffer, size_t len,
253 int flags) 253 int flags)
254{ 254{
255 int i; 255 int i;
@@ -260,7 +260,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
260 unsigned char nibble[2], byte = 0; 260 unsigned char nibble[2], byte = 0;
261 int j; 261 int j;
262 262
263 /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ 263 /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */
264 if (endseen > 3 ) 264 if (endseen > 3 )
265 break; 265 break;
266 266
@@ -268,7 +268,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
268 parport_frob_control (port, 268 parport_frob_control (port,
269 PARPORT_CONTROL_AUTOFD, 269 PARPORT_CONTROL_AUTOFD,
270 PARPORT_CONTROL_AUTOFD); 270 PARPORT_CONTROL_AUTOFD);
271 271
272 /* Event 9: nAck goes low. */ 272 /* Event 9: nAck goes low. */
273 port->ieee1284.phase = IEEE1284_PH_REV_DATA; 273 port->ieee1284.phase = IEEE1284_PH_REV_DATA;
274 if (parport_wait_peripheral (port, 274 if (parport_wait_peripheral (port,
@@ -282,7 +282,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
282 282
283 /* Read lower nibble */ 283 /* Read lower nibble */
284 nibble[0] = parport_read_status (port) >>3; 284 nibble[0] = parport_read_status (port) >>3;
285 285
286 /* Event 10: Set nAutoFd high. */ 286 /* Event 10: Set nAutoFd high. */
287 parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); 287 parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0);
288 288
@@ -295,10 +295,10 @@ static size_t cpia_read_nibble_stream(struct parport *port,
295 port->name); 295 port->name);
296 break; 296 break;
297 } 297 }
298 298
299 /* Read upper nibble */ 299 /* Read upper nibble */
300 nibble[1] = parport_read_status (port) >>3; 300 nibble[1] = parport_read_status (port) >>3;
301 301
302 /* reassemble the byte */ 302 /* reassemble the byte */
303 for (j = 0; j < 2 ; j++ ) { 303 for (j = 0; j < 2 ; j++ ) {
304 nibble[j] &= ~8; 304 nibble[j] &= ~8;
@@ -335,8 +335,8 @@ static void EndTransferMode(struct pp_cam_entry *cam)
335static int ForwardSetup(struct pp_cam_entry *cam) 335static int ForwardSetup(struct pp_cam_entry *cam)
336{ 336{
337 int retry; 337 int retry;
338 338
339 /* The CPiA uses ECP protocol for Downloads from the Host to the camera. 339 /* The CPiA uses ECP protocol for Downloads from the Host to the camera.
340 * This will be software-emulated if ECP hardware is not present 340 * This will be software-emulated if ECP hardware is not present
341 */ 341 */
342 342
@@ -375,9 +375,9 @@ static int ReverseSetup(struct pp_cam_entry *cam, int extensibility)
375 upload_mode = mode; 375 upload_mode = mode;
376 if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK; 376 if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK;
377 377
378 /* the usual camera maximum response time is 10ms, but after 378 /* the usual camera maximum response time is 10ms, but after
379 * receiving some commands, it needs up to 40ms. */ 379 * receiving some commands, it needs up to 40ms. */
380 380
381 for(retry = 0; retry < 4; ++retry) { 381 for(retry = 0; retry < 4; ++retry) {
382 if(!parport_negotiate(cam->port, mode)) { 382 if(!parport_negotiate(cam->port, mode)) {
383 break; 383 break;
@@ -439,10 +439,10 @@ static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size)
439 439
440 /* support for CPiA variant nibble reads */ 440 /* support for CPiA variant nibble reads */
441 if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) { 441 if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) {
442 if(cpia_read_nibble(cam->port, packet, size, 0) != size) 442 if(cpia_read_nibble(cam->port, packet, size, 0) != size)
443 retval = -EIO; 443 retval = -EIO;
444 } else { 444 } else {
445 if(parport_read(cam->port, packet, size) != size) 445 if(parport_read(cam->port, packet, size) != size)
446 retval = -EIO; 446 retval = -EIO;
447 } 447 }
448 EndTransferMode(cam); 448 EndTransferMode(cam);
@@ -542,18 +542,18 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock)
542 block_size = PARPORT_CHUNK_SIZE; 542 block_size = PARPORT_CHUNK_SIZE;
543 while( !cam->image_complete ) { 543 while( !cam->image_complete ) {
544 cond_resched(); 544 cond_resched();
545 545
546 new_bytes = cpia_pp_read(cam->port, buffer, block_size ); 546 new_bytes = cpia_pp_read(cam->port, buffer, block_size );
547 if( new_bytes <= 0 ) { 547 if( new_bytes <= 0 ) {
548 break; 548 break;
549 } 549 }
550 i=-1; 550 i=-1;
551 while(++i<new_bytes && endseen<4) { 551 while(++i<new_bytes && endseen<4) {
552 if(*buffer==EOI) { 552 if(*buffer==EOI) {
553 endseen++; 553 endseen++;
554 } else { 554 } else {
555 endseen=0; 555 endseen=0;
556 } 556 }
557 buffer++; 557 buffer++;
558 } 558 }
559 read_bytes += i; 559 read_bytes += i;
@@ -601,7 +601,7 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
601 } 601 }
602 if((err = ReadPacket(cam, buffer, 8)) < 0) { 602 if((err = ReadPacket(cam, buffer, 8)) < 0) {
603 DBG("Error reading command result\n"); 603 DBG("Error reading command result\n");
604 return err; 604 return err;
605 } 605 }
606 memcpy(data, buffer, databytes); 606 memcpy(data, buffer, databytes);
607 } else if(command[0] == DATA_OUT) { 607 } else if(command[0] == DATA_OUT) {
@@ -631,10 +631,10 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
631static int cpia_pp_open(void *privdata) 631static int cpia_pp_open(void *privdata)
632{ 632{
633 struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata; 633 struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata;
634 634
635 if (cam == NULL) 635 if (cam == NULL)
636 return -EINVAL; 636 return -EINVAL;
637 637
638 if(cam->open_count == 0) { 638 if(cam->open_count == 0) {
639 if (parport_claim(cam->pdev)) { 639 if (parport_claim(cam->pdev)) {
640 DBG("failed to claim the port\n"); 640 DBG("failed to claim the port\n");
@@ -645,12 +645,12 @@ static int cpia_pp_open(void *privdata)
645 parport_write_control(cam->port, PARPORT_CONTROL_SELECT); 645 parport_write_control(cam->port, PARPORT_CONTROL_SELECT);
646 udelay(50); 646 udelay(50);
647 parport_write_control(cam->port, 647 parport_write_control(cam->port,
648 PARPORT_CONTROL_SELECT 648 PARPORT_CONTROL_SELECT
649 | PARPORT_CONTROL_INIT); 649 | PARPORT_CONTROL_INIT);
650 } 650 }
651 651
652 ++cam->open_count; 652 ++cam->open_count;
653 653
654 return 0; 654 return 0;
655} 655}
656 656
@@ -663,7 +663,7 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
663{ 663{
664 struct pp_cam_entry *cam = privdata; 664 struct pp_cam_entry *cam = privdata;
665 int retval = 0; 665 int retval = 0;
666 666
667 if(cam->port->irq != PARPORT_IRQ_NONE) { 667 if(cam->port->irq != PARPORT_IRQ_NONE) {
668 INIT_WORK(&cam->cb_task, cb, cbdata); 668 INIT_WORK(&cam->cb_task, cb, cbdata);
669 } else { 669 } else {
@@ -707,9 +707,9 @@ static int cpia_pp_register(struct parport *port)
707 LOG("failed to allocate camera structure\n"); 707 LOG("failed to allocate camera structure\n");
708 return -ENOMEM; 708 return -ENOMEM;
709 } 709 }
710 710
711 pdev = parport_register_device(port, "cpia_pp", NULL, NULL, 711 pdev = parport_register_device(port, "cpia_pp", NULL, NULL,
712 NULL, 0, cam); 712 NULL, 0, cam);
713 713
714 if (!pdev) { 714 if (!pdev) {
715 LOG("failed to parport_register_device\n"); 715 LOG("failed to parport_register_device\n");
@@ -753,19 +753,19 @@ static void cpia_pp_detach (struct parport *port)
753 } 753 }
754 cpia = NULL; 754 cpia = NULL;
755 } 755 }
756 spin_unlock( &cam_list_lock_pp ); 756 spin_unlock( &cam_list_lock_pp );
757 757
758 if (!cpia) { 758 if (!cpia) {
759 DBG("cpia_pp_detach failed to find cam_data in cam_list\n"); 759 DBG("cpia_pp_detach failed to find cam_data in cam_list\n");
760 return; 760 return;
761 } 761 }
762 762
763 cam = (struct pp_cam_entry *) cpia->lowlevel_data; 763 cam = (struct pp_cam_entry *) cpia->lowlevel_data;
764 cpia_unregister_camera(cpia); 764 cpia_unregister_camera(cpia);
765 if(cam->open_count > 0) 765 if(cam->open_count > 0)
766 cpia_pp_close(cam); 766 cpia_pp_close(cam);
767 parport_unregister_device(cam->pdev); 767 parport_unregister_device(cam->pdev);
768 cpia->lowlevel_data = NULL; 768 cpia->lowlevel_data = NULL;
769 kfree(cam); 769 kfree(cam);
770} 770}
771 771
@@ -805,14 +805,14 @@ static struct parport_driver cpia_pp_driver = {
805 805
806int cpia_pp_init(void) 806int cpia_pp_init(void)
807{ 807{
808 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, 808 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
809 CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER); 809 CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER);
810 810
811 if(parport_nr[0] == PPCPIA_PARPORT_OFF) { 811 if(parport_nr[0] == PPCPIA_PARPORT_OFF) {
812 printk(" disabled\n"); 812 printk(" disabled\n");
813 return 0; 813 return 0;
814 } 814 }
815 815
816 spin_lock_init( &cam_list_lock_pp ); 816 spin_lock_init( &cam_list_lock_pp );
817 817
818 if (parport_register_driver (&cpia_pp_driver)) { 818 if (parport_register_driver (&cpia_pp_driver)) {
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index 03275c37c5d3..9c49a4b00116 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -22,7 +22,7 @@
22 */ 22 */
23 23
24/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 24/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
25/* #define _CPIA_DEBUG_ 1 */ 25/* #define _CPIA_DEBUG_ 1 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -85,7 +85,7 @@ struct usb_cpia {
85 85
86static int cpia_usb_open(void *privdata); 86static int cpia_usb_open(void *privdata);
87static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata), 87static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata),
88 void *cbdata); 88 void *cbdata);
89static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data); 89static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data);
90static int cpia_usb_streamStart(void *privdata); 90static int cpia_usb_streamStart(void *privdata);
91static int cpia_usb_streamStop(void *privdata); 91static int cpia_usb_streamStop(void *privdata);
@@ -127,7 +127,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
127 ucpia->workbuff->status = FRAME_READING; 127 ucpia->workbuff->status = FRAME_READING;
128 ucpia->workbuff->length = 0; 128 ucpia->workbuff->length = 0;
129 } 129 }
130 130
131 for (i = 0; i < urb->number_of_packets; i++) { 131 for (i = 0; i < urb->number_of_packets; i++) {
132 int n = urb->iso_frame_desc[i].actual_length; 132 int n = urb->iso_frame_desc[i].actual_length;
133 int st = urb->iso_frame_desc[i].status; 133 int st = urb->iso_frame_desc[i].status;
@@ -141,9 +141,9 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
141 printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n); 141 printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n);
142 return; 142 return;
143 } 143 }
144 144
145 if (n) { 145 if (n) {
146 if ((ucpia->workbuff->length > 0) || 146 if ((ucpia->workbuff->length > 0) ||
147 (0x19 == cdata[0] && 0x68 == cdata[1])) { 147 (0x19 == cdata[0] && 0x68 == cdata[1])) {
148 memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n); 148 memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n);
149 ucpia->workbuff->length += n; 149 ucpia->workbuff->length += n;
@@ -160,7 +160,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
160 ucpia->workbuff = ucpia->workbuff->next; 160 ucpia->workbuff = ucpia->workbuff->next;
161 ucpia->workbuff->status = FRAME_EMPTY; 161 ucpia->workbuff->status = FRAME_EMPTY;
162 ucpia->workbuff->length = 0; 162 ucpia->workbuff->length = 0;
163 163
164 if (waitqueue_active(&ucpia->wq_stream)) 164 if (waitqueue_active(&ucpia->wq_stream))
165 wake_up_interruptible(&ucpia->wq_stream); 165 wake_up_interruptible(&ucpia->wq_stream);
166 } 166 }
@@ -178,7 +178,7 @@ static int cpia_usb_open(void *privdata)
178 struct usb_cpia *ucpia = (struct usb_cpia *) privdata; 178 struct usb_cpia *ucpia = (struct usb_cpia *) privdata;
179 struct urb *urb; 179 struct urb *urb;
180 int ret, retval = 0, fx, err; 180 int ret, retval = 0, fx, err;
181 181
182 if (!ucpia) 182 if (!ucpia)
183 return -EINVAL; 183 return -EINVAL;
184 184
@@ -191,7 +191,7 @@ static int cpia_usb_open(void *privdata)
191 retval = -EINVAL; 191 retval = -EINVAL;
192 goto error_0; 192 goto error_0;
193 } 193 }
194 194
195 ret = usb_set_interface(ucpia->dev, ucpia->iface, 3); 195 ret = usb_set_interface(ucpia->dev, ucpia->iface, 3);
196 if (ret < 0) { 196 if (ret < 0) {
197 printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret); 197 printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret);
@@ -286,7 +286,7 @@ error_1:
286error_0: 286error_0:
287 kfree (ucpia->sbuf[0].data); 287 kfree (ucpia->sbuf[0].data);
288 ucpia->sbuf[0].data = NULL; 288 ucpia->sbuf[0].data = NULL;
289 289
290 return retval; 290 return retval;
291} 291}
292 292
@@ -307,7 +307,7 @@ static int WritePacket(struct usb_device *udev, const u8 *packet, u8 *buf, size_
307 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 307 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
308 packet[1] + (packet[0] << 8), 308 packet[1] + (packet[0] << 8),
309 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 309 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
310 packet[2] + (packet[3] << 8), 310 packet[2] + (packet[3] << 8),
311 packet[4] + (packet[5] << 8), buf, size, 1000); 311 packet[4] + (packet[5] << 8), buf, size, 1000);
312} 312}
313 313
@@ -324,7 +324,7 @@ static int ReadPacket(struct usb_device *udev, u8 *packet, u8 *buf, size_t size)
324 return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 324 return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
325 packet[1] + (packet[0] << 8), 325 packet[1] + (packet[0] << 8),
326 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 326 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
327 packet[2] + (packet[3] << 8), 327 packet[2] + (packet[3] << 8),
328 packet[4] + (packet[5] << 8), buf, size, 1000); 328 packet[4] + (packet[5] << 8), buf, size, 1000);
329} 329}
330 330
@@ -393,7 +393,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
393 393
394 if (!ucpia || !ucpia->present) 394 if (!ucpia || !ucpia->present)
395 return -1; 395 return -1;
396 396
397 if (ucpia->curbuff->status != FRAME_READY) 397 if (ucpia->curbuff->status != FRAME_READY)
398 interruptible_sleep_on(&ucpia->wq_stream); 398 interruptible_sleep_on(&ucpia->wq_stream);
399 else 399 else
@@ -403,7 +403,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
403 403
404 if (!mybuff) 404 if (!mybuff)
405 return -1; 405 return -1;
406 406
407 if (mybuff->status != FRAME_READY || mybuff->length < 4) { 407 if (mybuff->status != FRAME_READY || mybuff->length < 4) {
408 DBG("Something went wrong!\n"); 408 DBG("Something went wrong!\n");
409 return -1; 409 return -1;
@@ -411,7 +411,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
411 411
412 memcpy(frame, mybuff->data, mybuff->length); 412 memcpy(frame, mybuff->data, mybuff->length);
413 mybuff->status = FRAME_EMPTY; 413 mybuff->status = FRAME_EMPTY;
414 414
415/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */ 415/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */
416/* mybuff->length, frame[0], frame[1], */ 416/* mybuff->length, frame[0], frame[1], */
417/* frame[mybuff->length-4], frame[mybuff->length-3], */ 417/* frame[mybuff->length-4], frame[mybuff->length-3], */
@@ -447,7 +447,7 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
447 447
448 kfree(ucpia->sbuf[1].data); 448 kfree(ucpia->sbuf[1].data);
449 ucpia->sbuf[1].data = NULL; 449 ucpia->sbuf[1].data = NULL;
450 450
451 if (ucpia->sbuf[0].urb) { 451 if (ucpia->sbuf[0].urb) {
452 usb_kill_urb(ucpia->sbuf[0].urb); 452 usb_kill_urb(ucpia->sbuf[0].urb);
453 usb_free_urb(ucpia->sbuf[0].urb); 453 usb_free_urb(ucpia->sbuf[0].urb);
@@ -490,7 +490,7 @@ static int cpia_probe(struct usb_interface *intf,
490 struct usb_cpia *ucpia; 490 struct usb_cpia *ucpia;
491 struct cam_data *cam; 491 struct cam_data *cam;
492 int ret; 492 int ret;
493 493
494 /* A multi-config CPiA camera? */ 494 /* A multi-config CPiA camera? */
495 if (udev->descriptor.bNumConfigurations != 1) 495 if (udev->descriptor.bNumConfigurations != 1)
496 return -ENODEV; 496 return -ENODEV;
@@ -539,7 +539,7 @@ static int cpia_probe(struct usb_interface *intf,
539 539
540 /* Before register_camera, important */ 540 /* Before register_camera, important */
541 ucpia->present = 1; 541 ucpia->present = 1;
542 542
543 cam = cpia_register_camera(&cpia_usb_ops, ucpia); 543 cam = cpia_register_camera(&cpia_usb_ops, ucpia);
544 if (!cam) { 544 if (!cam) {
545 LOG("failed to cpia_register_camera\n"); 545 LOG("failed to cpia_register_camera\n");
@@ -591,7 +591,7 @@ static void cpia_disconnect(struct usb_interface *intf)
591 struct cam_data *cam = usb_get_intfdata(intf); 591 struct cam_data *cam = usb_get_intfdata(intf);
592 struct usb_cpia *ucpia; 592 struct usb_cpia *ucpia;
593 struct usb_device *udev; 593 struct usb_device *udev;
594 594
595 usb_set_intfdata(intf, NULL); 595 usb_set_intfdata(intf, NULL);
596 if (!cam) 596 if (!cam)
597 return; 597 return;
@@ -600,7 +600,7 @@ static void cpia_disconnect(struct usb_interface *intf)
600 spin_lock( &cam_list_lock_usb ); 600 spin_lock( &cam_list_lock_usb );
601 list_del(&cam->cam_data_list); 601 list_del(&cam->cam_data_list);
602 spin_unlock( &cam_list_lock_usb ); 602 spin_unlock( &cam_list_lock_usb );
603 603
604 ucpia->present = 0; 604 ucpia->present = 0;
605 605
606 cpia_unregister_camera(cam); 606 cpia_unregister_camera(cam);
@@ -631,7 +631,7 @@ static void cpia_disconnect(struct usb_interface *intf)
631 631
632static int __init usb_cpia_init(void) 632static int __init usb_cpia_init(void)
633{ 633{
634 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, 634 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
635 CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER); 635 CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER);
636 636
637 spin_lock_init(&cam_list_lock_usb); 637 spin_lock_init(&cam_list_lock_usb);
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 8739c64785ef..de87247c74ee 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)
59static int cs53l32a_command(struct i2c_client *client, unsigned int cmd, 59static int cs53l32a_command(struct i2c_client *client, unsigned int cmd,
60 void *arg) 60 void *arg)
61{ 61{
62 struct v4l2_audio *input = arg; 62 struct v4l2_routing *route = arg;
63 struct v4l2_control *ctrl = arg; 63 struct v4l2_control *ctrl = arg;
64 64
65 switch (cmd) { 65 switch (cmd) {
66 case VIDIOC_S_AUDIO: 66 case VIDIOC_INT_G_AUDIO_ROUTING:
67 route->input = (cs53l32a_read(client, 0x01) >> 4) & 3;
68 route->output = 0;
69 break;
70
71 case VIDIOC_INT_S_AUDIO_ROUTING:
67 /* There are 2 physical inputs, but the second input can be 72 /* There are 2 physical inputs, but the second input can be
68 placed in two modes, the first mode bypasses the PGA (gain), 73 placed in two modes, the first mode bypasses the PGA (gain),
69 the second goes through the PGA. Hence there are three 74 the second goes through the PGA. Hence there are three
70 possible inputs to choose from. */ 75 possible inputs to choose from. */
71 if (input->index > 2) { 76 if (route->input > 2) {
72 v4l_err(client, "Invalid input %d.\n", input->index); 77 v4l_err(client, "Invalid input %d.\n", route->input);
73 return -EINVAL; 78 return -EINVAL;
74 } 79 }
75 cs53l32a_write(client, 0x01, 0x01 + (input->index << 4)); 80 cs53l32a_write(client, 0x01, 0x01 + (route->input << 4));
76 break;
77
78 case VIDIOC_G_AUDIO:
79 memset(input, 0, sizeof(*input));
80 input->index = (cs53l32a_read(client, 0x01) >> 4) & 3;
81 break; 81 break;
82 82
83 case VIDIOC_G_CTRL: 83 case VIDIOC_G_CTRL:
diff --git a/drivers/media/video/cs8420.h b/drivers/media/video/cs8420.h
index 2b22f3a38de5..621c0c6678ea 100644
--- a/drivers/media/video/cs8420.h
+++ b/drivers/media/video/cs8420.h
@@ -20,7 +20,7 @@
20#define __CS8420_H__ 20#define __CS8420_H__
21 21
22/* Initialization Sequence */ 22/* Initialization Sequence */
23 23
24static __u8 init8420[] = { 24static __u8 init8420[] = {
25 1, 0x01, 2, 0x02, 3, 0x00, 4, 0x46, 25 1, 0x01, 2, 0x02, 3, 0x00, 4, 0x46,
26 5, 0x24, 6, 0x84, 18, 0x18, 19, 0x13, 26 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 cb9a7981e408..a4540e858f21 100644
--- a/drivers/media/video/cx25840/cx25840-audio.c
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -18,7 +18,6 @@
18 18
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <media/audiochip.h>
22#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
23 22
24#include "cx25840.h" 23#include "cx25840.h"
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 8a257978056f..a65b3cc4bf03 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -31,7 +31,6 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/videodev2.h> 32#include <linux/videodev2.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <media/audiochip.h>
35#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
36 35
37#include "cx25840.h" 36#include "cx25840.h"
@@ -176,9 +175,9 @@ static void cx25840_initialize(struct i2c_client *client, int loadfw)
176 cx25840_write(client, 0x4a5, 0x00); 175 cx25840_write(client, 0x4a5, 0x00);
177 cx25840_write(client, 0x402, 0x00); 176 cx25840_write(client, 0x402, 0x00);
178 /* 8. */ 177 /* 8. */
179 cx25840_write(client, 0x401, 0x18); 178 cx25840_and_or(client, 0x401, ~0x18, 0);
180 cx25840_write(client, 0x4a2, 0x10); 179 cx25840_and_or(client, 0x4a2, ~0x10, 0x10);
181 cx25840_write(client, 0x402, 0x04); 180 /* steps 8c and 8d are done in change_input() */
182 /* 10. */ 181 /* 10. */
183 cx25840_write(client, 0x8d3, 0x1f); 182 cx25840_write(client, 0x8d3, 0x1f);
184 cx25840_write(client, 0x8e3, 0x03); 183 cx25840_write(client, 0x8e3, 0x03);
@@ -209,6 +208,17 @@ static void input_change(struct i2c_client *client)
209 struct cx25840_state *state = i2c_get_clientdata(client); 208 struct cx25840_state *state = i2c_get_clientdata(client);
210 v4l2_std_id std = cx25840_get_v4lstd(client); 209 v4l2_std_id std = cx25840_get_v4lstd(client);
211 210
211 /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */
212 if (std & V4L2_STD_SECAM) {
213 cx25840_write(client, 0x402, 0);
214 }
215 else {
216 cx25840_write(client, 0x402, 0x04);
217 cx25840_write(client, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
218 }
219 cx25840_and_or(client, 0x401, ~0x60, 0);
220 cx25840_and_or(client, 0x401, ~0x60, 0x60);
221
212 /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC 222 /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC
213 instead of V4L2_STD_PAL. Someone needs to test this. */ 223 instead of V4L2_STD_PAL. Someone needs to test this. */
214 if (std & V4L2_STD_PAL) { 224 if (std & V4L2_STD_PAL) {
@@ -343,6 +353,15 @@ static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
343 } 353 }
344 } 354 }
345 355
356 /* Follow step 9 of section 3.16 in the cx25840 datasheet.
357 Without this PAL may display a vertical ghosting effect.
358 This happens for example with the Yuan MPC622. */
359 if (fmt >= 4 && fmt < 8) {
360 /* Set format to NTSC-M */
361 cx25840_and_or(client, 0x400, ~0xf, 1);
362 /* Turn off LCOMB */
363 cx25840_and_or(client, 0x47b, ~6, 0);
364 }
346 cx25840_and_or(client, 0x400, ~0xf, fmt); 365 cx25840_and_or(client, 0x400, ~0xf, fmt);
347 cx25840_vbi_setup(client); 366 cx25840_vbi_setup(client);
348 return 0; 367 return 0;
@@ -359,7 +378,14 @@ v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
359 } 378 }
360 379
361 switch (fmt) { 380 switch (fmt) {
362 case 0x1: return V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR; 381 case 0x1:
382 {
383 /* if the audio std is A2-M, then this is the South Korean
384 NTSC standard */
385 if (cx25840_read(client, 0x805) == 2)
386 return V4L2_STD_NTSC_M_KR;
387 return V4L2_STD_NTSC_M;
388 }
363 case 0x2: return V4L2_STD_NTSC_M_JP; 389 case 0x2: return V4L2_STD_NTSC_M_JP;
364 case 0x3: return V4L2_STD_NTSC_443; 390 case 0x3: return V4L2_STD_NTSC_443;
365 case 0x4: return V4L2_STD_PAL; 391 case 0x4: return V4L2_STD_PAL;
@@ -737,16 +763,6 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
737 return set_input(client, state->vid_input, input->index); 763 return set_input(client, state->vid_input, input->index);
738 } 764 }
739 765
740 case VIDIOC_G_AUDIO:
741 {
742 struct v4l2_audio *input = arg;
743
744 memset(input, 0, sizeof(*input));
745 input->index = state->aud_input;
746 input->capability = V4L2_AUDCAP_STEREO;
747 break;
748 }
749
750 case VIDIOC_S_FREQUENCY: 766 case VIDIOC_S_FREQUENCY:
751 input_change(client); 767 input_change(client);
752 break; 768 break;
@@ -794,13 +810,14 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
794 bilingual -> lang1 */ 810 bilingual -> lang1 */
795 cx25840_and_or(client, 0x809, ~0xf, 0x00); 811 cx25840_and_or(client, 0x809, ~0xf, 0x00);
796 break; 812 break;
813 case V4L2_TUNER_MODE_STEREO:
797 case V4L2_TUNER_MODE_LANG1: 814 case V4L2_TUNER_MODE_LANG1:
798 /* mono -> mono 815 /* mono -> mono
799 stereo -> stereo 816 stereo -> stereo
800 bilingual -> lang1 */ 817 bilingual -> lang1 */
801 cx25840_and_or(client, 0x809, ~0xf, 0x04); 818 cx25840_and_or(client, 0x809, ~0xf, 0x04);
802 break; 819 break;
803 case V4L2_TUNER_MODE_STEREO: 820 case V4L2_TUNER_MODE_LANG1_LANG2:
804 /* mono -> mono 821 /* mono -> mono
805 stereo -> stereo 822 stereo -> stereo
806 bilingual -> lang1/lang2 */ 823 bilingual -> lang1/lang2 */
@@ -808,7 +825,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
808 break; 825 break;
809 case V4L2_TUNER_MODE_LANG2: 826 case V4L2_TUNER_MODE_LANG2:
810 /* mono -> mono 827 /* mono -> mono
811 stereo ->stereo 828 stereo -> stereo
812 bilingual -> lang2 */ 829 bilingual -> lang2 */
813 cx25840_and_or(client, 0x809, ~0xf, 0x01); 830 cx25840_and_or(client, 0x809, ~0xf, 0x01);
814 break; 831 break;
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index e140996e6ee4..ff0f72340d69 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -16,12 +16,13 @@ config VIDEO_CX88
16 module will be called cx8800 16 module will be called cx8800
17 17
18config VIDEO_CX88_ALSA 18config VIDEO_CX88_ALSA
19 tristate "ALSA DMA audio support" 19 tristate "Conexant 2388x DMA audio support"
20 depends on VIDEO_CX88 && SND && EXPERIMENTAL 20 depends on VIDEO_CX88 && SND && EXPERIMENTAL
21 select SND_PCM 21 select SND_PCM
22 ---help--- 22 ---help---
23 This is a video4linux driver for direct (DMA) audio on 23 This is a video4linux driver for direct (DMA) audio on
24 Conexant 2388x based TV cards. 24 Conexant 2388x based TV cards using ALSA.
25
25 It only works with boards with function 01 enabled. 26 It only works with boards with function 01 enabled.
26 To check if your board supports, use lspci -n. 27 To check if your board supports, use lspci -n.
27 If supported, you should see 1471:8801 or 1471:8811 28 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 3170b8f72c68..f9d87b86492c 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)
303 BUG_ON(!chip->dma_size); 303 BUG_ON(!chip->dma_size);
304 304
305 dprintk(2,"Freeing buffer\n"); 305 dprintk(2,"Freeing buffer\n");
306 videobuf_dma_pci_unmap(chip->pci, &chip->dma_risc); 306 videobuf_pci_dma_unmap(chip->pci, &chip->dma_risc);
307 videobuf_dma_free(&chip->dma_risc); 307 videobuf_dma_free(&chip->dma_risc);
308 btcx_riscmem_free(chip->pci,&chip->buf->risc); 308 btcx_riscmem_free(chip->pci,&chip->buf->risc);
309 kfree(chip->buf); 309 kfree(chip->buf);
@@ -429,7 +429,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
429 videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE, 429 videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE,
430 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); 430 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
431 431
432 videobuf_dma_pci_map(chip->pci,&buf->vb.dma); 432 videobuf_pci_dma_map(chip->pci,&buf->vb.dma);
433 433
434 434
435 cx88_risc_databuffer(chip->pci, &buf->risc, 435 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 a502a4d6e4ae..e100d8ef369a 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,
1341 enum v4l2_field field) 1341 enum v4l2_field field)
1342{ 1342{
1343 struct cx8802_fh *fh = q->priv_data; 1343 struct cx8802_fh *fh = q->priv_data;
1344 return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb, field); 1344 return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);
1345} 1345}
1346 1346
1347static void 1347static void
@@ -1354,8 +1354,7 @@ bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
1354static void 1354static void
1355bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 1355bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1356{ 1356{
1357 struct cx8802_fh *fh = q->priv_data; 1357 cx88_free_buffer(q, (struct cx88_buffer*)vb);
1358 cx88_free_buffer(fh->dev->pci, (struct cx88_buffer*)vb);
1359} 1358}
1360 1359
1361static struct videobuf_queue_ops blackbird_qops = { 1360static 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 c2cdbafdb77b..2c3d9f1999be 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,
213} 213}
214 214
215void 215void
216cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf) 216cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
217{ 217{
218 BUG_ON(in_interrupt()); 218 BUG_ON(in_interrupt());
219 videobuf_waiton(&buf->vb,0,0); 219 videobuf_waiton(&buf->vb,0,0);
220 videobuf_dma_pci_unmap(pci, &buf->vb.dma); 220 videobuf_dma_unmap(q, &buf->vb.dma);
221 videobuf_dma_free(&buf->vb.dma); 221 videobuf_dma_free(&buf->vb.dma);
222 btcx_riscmem_free(pci, &buf->risc); 222 btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc);
223 buf->vb.state = STATE_NEEDS_INIT; 223 buf->vb.state = STATE_NEEDS_INIT;
224} 224}
225 225
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index a9fc2695b157..f0ea9b5cdbc2 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,
90 enum v4l2_field field) 90 enum v4l2_field field)
91{ 91{
92 struct cx8802_dev *dev = q->priv_data; 92 struct cx8802_dev *dev = q->priv_data;
93 return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb,field); 93 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
94} 94}
95 95
96static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 96static 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)
101 101
102static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 102static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
103{ 103{
104 struct cx8802_dev *dev = q->priv_data; 104 cx88_free_buffer(q, (struct cx88_buffer*)vb);
105 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
106} 105}
107 106
108static struct videobuf_queue_ops dvb_qops = { 107static 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 c79cc1d2bf8b..7d16888b4a86 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,
163 163
164/* ------------------------------------------------------------------ */ 164/* ------------------------------------------------------------------ */
165 165
166int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf, 166int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev,
167 enum v4l2_field field) 167 struct cx88_buffer *buf, enum v4l2_field field)
168{ 168{
169 int size = dev->ts_packet_size * dev->ts_packet_count; 169 int size = dev->ts_packet_size * dev->ts_packet_count;
170 int rc; 170 int rc;
@@ -179,7 +179,7 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
179 buf->vb.size = size; 179 buf->vb.size = size;
180 buf->vb.field = field /*V4L2_FIELD_TOP*/; 180 buf->vb.field = field /*V4L2_FIELD_TOP*/;
181 181
182 if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL))) 182 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
183 goto fail; 183 goto fail;
184 cx88_risc_databuffer(dev->pci, &buf->risc, 184 cx88_risc_databuffer(dev->pci, &buf->risc,
185 buf->vb.dma.sglist, 185 buf->vb.dma.sglist,
@@ -189,36 +189,36 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
189 return 0; 189 return 0;
190 190
191 fail: 191 fail:
192 cx88_free_buffer(dev->pci,buf); 192 cx88_free_buffer(q,buf);
193 return rc; 193 return rc;
194} 194}
195 195
196void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) 196void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
197{ 197{
198 struct cx88_buffer *prev; 198 struct cx88_buffer *prev;
199 struct cx88_dmaqueue *q = &dev->mpegq; 199 struct cx88_dmaqueue *cx88q = &dev->mpegq;
200 200
201 dprintk( 1, "cx8802_buf_queue\n" ); 201 dprintk( 1, "cx8802_buf_queue\n" );
202 /* add jump to stopper */ 202 /* add jump to stopper */
203 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); 203 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
204 buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); 204 buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma);
205 205
206 if (list_empty(&q->active)) { 206 if (list_empty(&cx88q->active)) {
207 dprintk( 0, "queue is empty - first active\n" ); 207 dprintk( 0, "queue is empty - first active\n" );
208 list_add_tail(&buf->vb.queue,&q->active); 208 list_add_tail(&buf->vb.queue,&cx88q->active);
209 cx8802_start_dma(dev, q, buf); 209 cx8802_start_dma(dev, cx88q, buf);
210 buf->vb.state = STATE_ACTIVE; 210 buf->vb.state = STATE_ACTIVE;
211 buf->count = q->count++; 211 buf->count = cx88q->count++;
212 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 212 mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT);
213 dprintk(0,"[%p/%d] %s - first active\n", 213 dprintk(0,"[%p/%d] %s - first active\n",
214 buf, buf->vb.i, __FUNCTION__); 214 buf, buf->vb.i, __FUNCTION__);
215 215
216 } else { 216 } else {
217 dprintk( 1, "queue is not empty - append to active\n" ); 217 dprintk( 1, "queue is not empty - append to active\n" );
218 prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue); 218 prev = list_entry(cx88q->active.prev, struct cx88_buffer, vb.queue);
219 list_add_tail(&buf->vb.queue,&q->active); 219 list_add_tail(&buf->vb.queue,&cx88q->active);
220 buf->vb.state = STATE_ACTIVE; 220 buf->vb.state = STATE_ACTIVE;
221 buf->count = q->count++; 221 buf->count = cx88q->count++;
222 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 222 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
223 dprintk( 1, "[%p/%d] %s - append to active\n", 223 dprintk( 1, "[%p/%d] %s - append to active\n",
224 buf, buf->vb.i, __FUNCTION__); 224 buf, buf->vb.i, __FUNCTION__);
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index da8d97ce0c4b..641a0c5a6490 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)
885 set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP); 885 set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP);
886 break; 886 break;
887 case V4L2_TUNER_MODE_STEREO: 887 case V4L2_TUNER_MODE_STEREO:
888 case V4L2_TUNER_MODE_LANG1_LANG2:
888 set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO); 889 set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO);
889 break; 890 break;
890 } 891 }
@@ -905,6 +906,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
905 EN_NICAM_FORCE_MONO2); 906 EN_NICAM_FORCE_MONO2);
906 break; 907 break;
907 case V4L2_TUNER_MODE_STEREO: 908 case V4L2_TUNER_MODE_STEREO:
909 case V4L2_TUNER_MODE_LANG1_LANG2:
908 set_audio_standard_NICAM(core, 910 set_audio_standard_NICAM(core,
909 EN_NICAM_FORCE_STEREO); 911 EN_NICAM_FORCE_STEREO);
910 break; 912 break;
@@ -926,6 +928,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
926 EN_A2_FORCE_MONO2); 928 EN_A2_FORCE_MONO2);
927 break; 929 break;
928 case V4L2_TUNER_MODE_STEREO: 930 case V4L2_TUNER_MODE_STEREO:
931 case V4L2_TUNER_MODE_LANG1_LANG2:
929 set_audio_standard_A2(core, 932 set_audio_standard_A2(core,
930 EN_A2_FORCE_STEREO); 933 EN_A2_FORCE_STEREO);
931 break; 934 break;
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 9bc6c8995581..846faadc9f1c 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,
175 buf->vb.size = size; 175 buf->vb.size = size;
176 buf->vb.field = V4L2_FIELD_SEQ_TB; 176 buf->vb.field = V4L2_FIELD_SEQ_TB;
177 177
178 if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL))) 178 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
179 goto fail; 179 goto fail;
180 cx88_risc_buffer(dev->pci, &buf->risc, 180 cx88_risc_buffer(dev->pci, &buf->risc,
181 buf->vb.dma.sglist, 181 buf->vb.dma.sglist,
@@ -187,7 +187,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
187 return 0; 187 return 0;
188 188
189 fail: 189 fail:
190 cx88_free_buffer(dev->pci,buf); 190 cx88_free_buffer(q,buf);
191 return rc; 191 return rc;
192} 192}
193 193
@@ -227,9 +227,8 @@ vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
227static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 227static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
228{ 228{
229 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); 229 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
230 struct cx8800_fh *fh = q->priv_data;
231 230
232 cx88_free_buffer(fh->dev->pci,buf); 231 cx88_free_buffer(q,buf);
233} 232}
234 233
235struct videobuf_queue_ops cx8800_vbi_qops = { 234struct 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 6c97aa740d27..72a417b31745 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,
564 564
565 if (STATE_NEEDS_INIT == buf->vb.state) { 565 if (STATE_NEEDS_INIT == buf->vb.state) {
566 init_buffer = 1; 566 init_buffer = 1;
567 if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL))) 567 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
568 goto fail; 568 goto fail;
569 } 569 }
570 570
@@ -614,7 +614,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
614 return 0; 614 return 0;
615 615
616 fail: 616 fail:
617 cx88_free_buffer(dev->pci,buf); 617 cx88_free_buffer(q,buf);
618 return rc; 618 return rc;
619} 619}
620 620
@@ -671,9 +671,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
671static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 671static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
672{ 672{
673 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); 673 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
674 struct cx8800_fh *fh = q->priv_data;
675 674
676 cx88_free_buffer(fh->dev->pci,buf); 675 cx88_free_buffer(q,buf);
677} 676}
678 677
679static struct videobuf_queue_ops cx8800_video_qops = { 678static struct videobuf_queue_ops cx8800_video_qops = {
@@ -1251,9 +1250,17 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1251{ 1250{
1252 int err; 1251 int err;
1253 1252
1254 dprintk(2, "CORE IOCTL: 0x%x\n", cmd ); 1253 if (video_debug) {
1255 if (video_debug > 1) 1254 if (video_debug > 1) {
1256 v4l_print_ioctl(core->name,cmd); 1255 if (_IOC_DIR(cmd) & _IOC_WRITE)
1256 v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
1257 else if (!_IOC_DIR(cmd) & _IOC_READ) {
1258 v4l_print_ioctl("cx88", cmd);
1259 }
1260 } else
1261 v4l_print_ioctl(core->name,cmd);
1262
1263 }
1257 1264
1258 switch (cmd) { 1265 switch (cmd) {
1259 /* ---------- tv norms ---------- */ 1266 /* ---------- tv norms ---------- */
@@ -1460,7 +1467,19 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1460static int video_ioctl(struct inode *inode, struct file *file, 1467static int video_ioctl(struct inode *inode, struct file *file,
1461 unsigned int cmd, unsigned long arg) 1468 unsigned int cmd, unsigned long arg)
1462{ 1469{
1463 return video_usercopy(inode, file, cmd, arg, video_do_ioctl); 1470 int retval;
1471
1472 retval=video_usercopy(inode, file, cmd, arg, video_do_ioctl);
1473
1474 if (video_debug > 1) {
1475 if (retval < 0) {
1476 v4l_print_ioctl("cx88(err)", cmd);
1477 printk(KERN_DEBUG "cx88(err): errcode=%d\n",retval);
1478 } else if (_IOC_DIR(cmd) & _IOC_READ)
1479 v4l_printk_ioctl_arg("cx88(r)",cmd, (void *)arg);
1480 }
1481
1482 return retval;
1464} 1483}
1465 1484
1466/* ----------------------------------------------------------- */ 1485/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index cfa8668784b4..326a25f147f6 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -27,7 +27,6 @@
27 27
28#include <media/tuner.h> 28#include <media/tuner.h>
29#include <media/tveeprom.h> 29#include <media/tveeprom.h>
30#include <media/audiochip.h>
31#include <media/video-buf.h> 30#include <media/video-buf.h>
32#include <media/video-buf-dvb.h> 31#include <media/video-buf-dvb.h>
33 32
@@ -485,7 +484,7 @@ extern int
485cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 484cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
486 u32 reg, u32 mask, u32 value); 485 u32 reg, u32 mask, u32 value);
487extern void 486extern void
488cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf); 487cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf);
489 488
490extern void cx88_risc_disasm(struct cx88_core *core, 489extern void cx88_risc_disasm(struct cx88_core *core,
491 struct btcx_riscmem *risc); 490 struct btcx_riscmem *risc);
@@ -577,8 +576,8 @@ void cx88_ir_irq(struct cx88_core *core);
577/* ----------------------------------------------------------- */ 576/* ----------------------------------------------------------- */
578/* cx88-mpeg.c */ 577/* cx88-mpeg.c */
579 578
580int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf, 579int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev,
581 enum v4l2_field field); 580 struct cx88_buffer *buf, enum v4l2_field field);
582void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); 581void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
583void cx8802_cancel_buffers(struct cx8802_dev *dev); 582void cx8802_cancel_buffers(struct cx8802_dev *dev);
584 583
diff --git a/drivers/usb/media/dabfirmware.h b/drivers/media/video/dabfirmware.h
index d14d803566a3..d14d803566a3 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 1774ab7a40d2..b9ba95f5e026 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_
86 return ret; 86 return ret;
87} 87}
88/*-------------------------------------------------------------------*/ 88/*-------------------------------------------------------------------*/
89#ifdef DEBUG 89#ifdef DEBUG
90static void dump_urb (struct urb *urb) 90static void dump_urb (struct urb *urb)
91{ 91{
92 dbg("urb :%p", urb); 92 dbg("urb :%p", urb);
@@ -136,7 +136,7 @@ static int dabusb_free_queue (struct list_head *q)
136 for (p = q->next; p != q;) { 136 for (p = q->next; p != q;) {
137 b = list_entry (p, buff_t, buff_list); 137 b = list_entry (p, buff_t, buff_list);
138 138
139#ifdef DEBUG 139#ifdef DEBUG
140 dump_urb(b->purb); 140 dump_urb(b->purb);
141#endif 141#endif
142 kfree(b->purb->transfer_buffer); 142 kfree(b->purb->transfer_buffer);
@@ -287,7 +287,7 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb)
287 } 287 }
288 288
289 } 289 }
290 290
291 if( ret == -EPIPE ) { 291 if( ret == -EPIPE ) {
292 warn("CLEAR_FEATURE request to remove STALL condition."); 292 warn("CLEAR_FEATURE request to remove STALL condition.");
293 if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe))) 293 if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe)))
@@ -328,7 +328,7 @@ static int dabusb_loadmem (pdabusb_t s, const char *fname)
328 PINTEL_HEX_RECORD ptr = firmware; 328 PINTEL_HEX_RECORD ptr = firmware;
329 329
330 dbg("Enter dabusb_loadmem (internal)"); 330 dbg("Enter dabusb_loadmem (internal)");
331 331
332 ret = dabusb_8051_reset (s, 1); 332 ret = dabusb_8051_reset (s, 1);
333 while (ptr->Type == 0) { 333 while (ptr->Type == 0) {
334 334
@@ -449,7 +449,7 @@ static int dabusb_startrek (pdabusb_t s)
449 if (!list_empty (&s->free_buff_list)) { 449 if (!list_empty (&s->free_buff_list)) {
450 pbuff_t end; 450 pbuff_t end;
451 int ret; 451 int ret;
452 452
453 while (!dabusb_add_buf_tail (s, &s->rec_buff_list, &s->free_buff_list)) { 453 while (!dabusb_add_buf_tail (s, &s->rec_buff_list, &s->free_buff_list)) {
454 454
455 dbg("submitting: end:%p s->rec_buff_list:%p", s->rec_buff_list.prev, &s->rec_buff_list); 455 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
506 err("error: rec_buf_list is empty"); 506 err("error: rec_buf_list is empty");
507 goto err; 507 goto err;
508 } 508 }
509 509
510 b = list_entry (s->rec_buff_list.next, buff_t, buff_list); 510 b = list_entry (s->rec_buff_list.next, buff_t, buff_list);
511 purb = b->purb; 511 purb = b->purb;
512 512
@@ -783,9 +783,9 @@ static void dabusb_disconnect (struct usb_interface *intf)
783 pdabusb_t s = usb_get_intfdata (intf); 783 pdabusb_t s = usb_get_intfdata (intf);
784 784
785 dbg("dabusb_disconnect"); 785 dbg("dabusb_disconnect");
786 786
787 init_waitqueue_entry(&__wait, current); 787 init_waitqueue_entry(&__wait, current);
788 788
789 usb_set_intfdata (intf, NULL); 789 usb_set_intfdata (intf, NULL);
790 if (s) { 790 if (s) {
791 usb_deregister_dev (intf, &dabusb_class); 791 usb_deregister_dev (intf, &dabusb_class);
@@ -797,7 +797,7 @@ static void dabusb_disconnect (struct usb_interface *intf)
797 schedule(); 797 schedule();
798 current->state = TASK_RUNNING; 798 current->state = TASK_RUNNING;
799 remove_wait_queue(&s->remove_ok, &__wait); 799 remove_wait_queue(&s->remove_ok, &__wait);
800 800
801 s->usbdev = NULL; 801 s->usbdev = NULL;
802 s->overruns = 0; 802 s->overruns = 0;
803 } 803 }
diff --git a/drivers/usb/media/dabusb.h b/drivers/media/video/dabusb.h
index 96b03e4af8b9..00eb34c863eb 100644
--- a/drivers/usb/media/dabusb.h
+++ b/drivers/media/video/dabusb.h
@@ -10,7 +10,7 @@ typedef struct
10#define DABUSB_VERSION 0x1000 10#define DABUSB_VERSION 0x1000
11#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t) 11#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t)
12#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int) 12#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int)
13#define IOCTL_DAB_VERSION _IOR('d', 0x3f, int) 13#define IOCTL_DAB_VERSION _IOR('d', 0x3f, int)
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16 16
@@ -36,7 +36,7 @@ typedef struct
36 struct list_head rec_buff_list; 36 struct list_head rec_buff_list;
37} dabusb_t,*pdabusb_t; 37} dabusb_t,*pdabusb_t;
38 38
39typedef struct 39typedef struct
40{ 40{
41 pdabusb_t s; 41 pdabusb_t s;
42 struct urb *purb; 42 struct urb *purb;
diff --git a/drivers/usb/media/dsbr100.c b/drivers/media/video/dsbr100.c
index 25646804d5be..3b4e9985c3d7 100644
--- a/drivers/usb/media/dsbr100.c
+++ b/drivers/media/video/dsbr100.c
@@ -37,28 +37,28 @@
37 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing 37 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing
38 38
39 Version 0.30: 39 Version 0.30:
40 Markus: Updates for 2.5.x kernel and more ISO compliant source 40 Markus: Updates for 2.5.x kernel and more ISO compliant source
41 41
42 Version 0.25: 42 Version 0.25:
43 PSL and Markus: Cleanup, radio now doesn't stop on device close 43 PSL and Markus: Cleanup, radio now doesn't stop on device close
44 44
45 Version 0.24: 45 Version 0.24:
46 Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally 46 Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally
47 right. Some minor cleanup, improved standalone compilation 47 right. Some minor cleanup, improved standalone compilation
48 48
49 Version 0.23: 49 Version 0.23:
50 Markus: Sign extension bug fixed by declaring transfer_buffer unsigned 50 Markus: Sign extension bug fixed by declaring transfer_buffer unsigned
51 51
52 Version 0.22: 52 Version 0.22:
53 Markus: Some (brown bag) cleanup in what VIDIOCSTUNER returns, 53 Markus: Some (brown bag) cleanup in what VIDIOCSTUNER returns,
54 thanks to Mike Cox for pointing the problem out. 54 thanks to Mike Cox for pointing the problem out.
55 55
56 Version 0.21: 56 Version 0.21:
57 Markus: Minor cleanup, warnings if something goes wrong, lame attempt 57 Markus: Minor cleanup, warnings if something goes wrong, lame attempt
58 to adhere to Documentation/CodingStyle 58 to adhere to Documentation/CodingStyle
59 59
60 Version 0.2: 60 Version 0.2:
61 Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module 61 Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module
62 Markus: Copyright clarification 62 Markus: Copyright clarification
63 63
64 Version 0.01: Markus: initial release 64 Version 0.01: Markus: initial release
@@ -163,11 +163,11 @@ static struct usb_driver usb_dsbr100_driver = {
163static int dsbr100_start(dsbr100_device *radio) 163static int dsbr100_start(dsbr100_device *radio)
164{ 164{
165 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 165 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
166 USB_REQ_GET_STATUS, 166 USB_REQ_GET_STATUS,
167 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 167 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
168 0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 || 168 0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 ||
169 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 169 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
170 DSB100_ONOFF, 170 DSB100_ONOFF,
171 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 171 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
172 0x01, 0x00, radio->transfer_buffer, 8, 300)<0) 172 0x01, 0x00, radio->transfer_buffer, 8, 300)<0)
173 return -1; 173 return -1;
@@ -179,11 +179,11 @@ static int dsbr100_start(dsbr100_device *radio)
179static int dsbr100_stop(dsbr100_device *radio) 179static int dsbr100_stop(dsbr100_device *radio)
180{ 180{
181 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 181 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
182 USB_REQ_GET_STATUS, 182 USB_REQ_GET_STATUS,
183 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 183 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
184 0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 || 184 0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 ||
185 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 185 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
186 DSB100_ONOFF, 186 DSB100_ONOFF,
187 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 187 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
188 0x00, 0x00, radio->transfer_buffer, 8, 300)<0) 188 0x00, 0x00, radio->transfer_buffer, 8, 300)<0)
189 return -1; 189 return -1;
@@ -195,16 +195,16 @@ static int dsbr100_setfreq(dsbr100_device *radio, int freq)
195{ 195{
196 freq = (freq/16*80)/1000+856; 196 freq = (freq/16*80)/1000+856;
197 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 197 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
198 DSB100_TUNE, 198 DSB100_TUNE,
199 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 199 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
200 (freq>>8)&0x00ff, freq&0xff, 200 (freq>>8)&0x00ff, freq&0xff,
201 radio->transfer_buffer, 8, 300)<0 || 201 radio->transfer_buffer, 8, 300)<0 ||
202 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 202 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
203 USB_REQ_GET_STATUS, 203 USB_REQ_GET_STATUS,
204 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 204 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
205 0x96, 0xB7, radio->transfer_buffer, 8, 300)<0 || 205 0x96, 0xB7, radio->transfer_buffer, 8, 300)<0 ||
206 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 206 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
207 USB_REQ_GET_STATUS, 207 USB_REQ_GET_STATUS,
208 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 208 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
209 0x00, 0x24, radio->transfer_buffer, 8, 300)<0) { 209 0x00, 0x24, radio->transfer_buffer, 8, 300)<0) {
210 radio->stereo = -1; 210 radio->stereo = -1;
@@ -219,7 +219,7 @@ sees a stereo signal or not. Pity. */
219static void dsbr100_getstat(dsbr100_device *radio) 219static void dsbr100_getstat(dsbr100_device *radio)
220{ 220{
221 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 221 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
222 USB_REQ_GET_STATUS, 222 USB_REQ_GET_STATUS,
223 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 223 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
224 0x00 , 0x24, radio->transfer_buffer, 8, 300)<0) 224 0x00 , 0x24, radio->transfer_buffer, 8, 300)<0)
225 radio->stereo = -1; 225 radio->stereo = -1;
@@ -232,7 +232,7 @@ static void dsbr100_getstat(dsbr100_device *radio)
232 232
233/* check if the device is present and register with v4l and 233/* check if the device is present and register with v4l and
234usb if it is */ 234usb if it is */
235static int usb_dsbr100_probe(struct usb_interface *intf, 235static int usb_dsbr100_probe(struct usb_interface *intf,
236 const struct usb_device_id *id) 236 const struct usb_device_id *id)
237{ 237{
238 dsbr100_device *radio; 238 dsbr100_device *radio;
@@ -243,7 +243,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
243 kfree(radio); 243 kfree(radio);
244 return -ENOMEM; 244 return -ENOMEM;
245 } 245 }
246 memcpy(radio->videodev, &dsbr100_videodev_template, 246 memcpy(radio->videodev, &dsbr100_videodev_template,
247 sizeof(dsbr100_videodev_template)); 247 sizeof(dsbr100_videodev_template));
248 radio->removed = 0; 248 radio->removed = 0;
249 radio->users = 0; 249 radio->users = 0;
@@ -310,7 +310,7 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
310 struct video_tuner *v = arg; 310 struct video_tuner *v = arg;
311 311
312 dsbr100_getstat(radio); 312 dsbr100_getstat(radio);
313 if(v->tuner) /* Only 1 tuner */ 313 if(v->tuner) /* Only 1 tuner */
314 return -EINVAL; 314 return -EINVAL;
315 v->rangelow = FREQ_MIN*FREQ_MUL; 315 v->rangelow = FREQ_MIN*FREQ_MUL;
316 v->rangehigh = FREQ_MAX*FREQ_MUL; 316 v->rangehigh = FREQ_MAX*FREQ_MUL;
@@ -355,12 +355,12 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
355 v->volume = 1; 355 v->volume = 1;
356 v->step = 1; 356 v->step = 1;
357 strcpy(v->name, "Radio"); 357 strcpy(v->name, "Radio");
358 return 0; 358 return 0;
359 } 359 }
360 case VIDIOCSAUDIO: { 360 case VIDIOCSAUDIO: {
361 struct video_audio *v = arg; 361 struct video_audio *v = arg;
362 362
363 if (v->audio) 363 if (v->audio)
364 return -EINVAL; 364 return -EINVAL;
365 if (v->flags&VIDEO_AUDIO_MUTE) { 365 if (v->flags&VIDEO_AUDIO_MUTE) {
366 if (dsbr100_stop(radio)==-1) 366 if (dsbr100_stop(radio)==-1)
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 4e22fc4889e1..f62fd706b45a 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -28,10 +28,10 @@
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include <media/tuner.h> 30#include <media/tuner.h>
31#include <media/audiochip.h> 31#include <media/msp3400.h>
32#include <media/tveeprom.h> 32#include <media/tveeprom.h>
33#include <media/audiochip.h>
33#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
34#include "msp3400.h"
35 35
36#include "em28xx.h" 36#include "em28xx.h"
37 37
@@ -147,11 +147,12 @@ struct em28xx_board em28xx_boards[] = {
147 .input = {{ 147 .input = {{
148 .type = EM28XX_VMUX_TELEVISION, 148 .type = EM28XX_VMUX_TELEVISION,
149 .vmux = 0, 149 .vmux = 0,
150 .amux = 6, 150 .amux = MSP_INPUT_DEFAULT,
151 },{ 151 },{
152 .type = EM28XX_VMUX_SVIDEO, 152 .type = EM28XX_VMUX_SVIDEO,
153 .vmux = 2, 153 .vmux = 2,
154 .amux = 1, 154 .amux = MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1,
155 MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART),
155 }}, 156 }},
156 }, 157 },
157 [EM2820_BOARD_MSI_VOX_USB_2] = { 158 [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 780342f7b239..dfba33d0fa61 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -38,6 +38,7 @@
38#include "em28xx.h" 38#include "em28xx.h"
39#include <media/tuner.h> 39#include <media/tuner.h>
40#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
41#include <media/msp3400.h>
41 42
42#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \ 43#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \
43 "Markus Rechberger <mrechberger@gmail.com>, " \ 44 "Markus Rechberger <mrechberger@gmail.com>, " \
@@ -216,9 +217,14 @@ static void video_mux(struct em28xx *dev, int index)
216 em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput); 217 em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput);
217 218
218 if (dev->has_msp34xx) { 219 if (dev->has_msp34xx) {
220 struct v4l2_routing route;
221
219 if (dev->i2s_speed) 222 if (dev->i2s_speed)
220 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); 223 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed);
221 em28xx_i2c_call_clients(dev, VIDIOC_S_AUDIO, &dev->ctl_ainput); 224 route.input = dev->ctl_ainput;
225 route.output = MSP_OUTPUT(MSP_OUT_SCART1_DA);
226 /* Note: this is msp3400 specific */
227 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route);
222 ainput = EM28XX_AUDIO_SRC_TUNER; 228 ainput = EM28XX_AUDIO_SRC_TUNER;
223 em28xx_audio_source(dev, ainput); 229 em28xx_audio_source(dev, ainput);
224 } else { 230 } else {
diff --git a/drivers/media/video/et61x251/Makefile b/drivers/media/video/et61x251/Makefile
new file mode 100644
index 000000000000..2ff4db9ec882
--- /dev/null
+++ b/drivers/media/video/et61x251/Makefile
@@ -0,0 +1,4 @@
1et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
2
3obj-$(CONFIG_USB_ET61X251) += et61x251.o
4
diff --git a/drivers/usb/media/et61x251.h b/drivers/media/video/et61x251/et61x251.h
index eee8afc9be72..2e5ca4032489 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)
180 180
181void 181void
182et61x251_attach_sensor(struct et61x251_device* cam, 182et61x251_attach_sensor(struct et61x251_device* cam,
183 struct et61x251_sensor* sensor) 183 struct et61x251_sensor* sensor)
184{ 184{
185 memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor)); 185 memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor));
186} 186}
@@ -199,7 +199,7 @@ do { \
199 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 199 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
200 else if ((level) >= 3) \ 200 else if ((level) >= 3) \
201 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 201 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
202 __FUNCTION__, __LINE__ , ## args); \ 202 __FUNCTION__, __LINE__ , ## args); \
203 } \ 203 } \
204} while (0) 204} while (0)
205# define KDBG(level, fmt, args...) \ 205# define KDBG(level, fmt, args...) \
@@ -209,7 +209,7 @@ do { \
209 pr_info("et61x251: " fmt "\n", ## args); \ 209 pr_info("et61x251: " fmt "\n", ## args); \
210 else if ((level) == 3) \ 210 else if ((level) == 3) \
211 pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \ 211 pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \
212 __LINE__ , ## args); \ 212 __LINE__ , ## args); \
213 } \ 213 } \
214} while (0) 214} while (0)
215# define V4LDBG(level, name, cmd) \ 215# define V4LDBG(level, name, cmd) \
@@ -226,7 +226,7 @@ do { \
226#undef PDBG 226#undef PDBG
227#define PDBG(fmt, args...) \ 227#define PDBG(fmt, args...) \
228dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 228dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
229 __FUNCTION__, __LINE__ , ## args) 229 __FUNCTION__, __LINE__ , ## args)
230 230
231#undef PDBGG 231#undef PDBGG
232#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 232#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 7cc01b828b3d..dfc9dd732c9d 100644
--- a/drivers/usb/media/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -44,7 +44,7 @@
44/*****************************************************************************/ 44/*****************************************************************************/
45 45
46#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \ 46#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \
47 "PC Camera Controllers" 47 "PC Camera Controllers"
48#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia" 48#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia"
49#define ET61X251_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 49#define ET61X251_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
50#define ET61X251_MODULE_LICENSE "GPL" 50#define ET61X251_MODULE_LICENSE "GPL"
@@ -63,68 +63,68 @@ MODULE_LICENSE(ET61X251_MODULE_LICENSE);
63static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1}; 63static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1};
64module_param_array(video_nr, short, NULL, 0444); 64module_param_array(video_nr, short, NULL, 0444);
65MODULE_PARM_DESC(video_nr, 65MODULE_PARM_DESC(video_nr,
66 "\n<-1|n[,...]> Specify V4L2 minor mode number." 66 "\n<-1|n[,...]> Specify V4L2 minor mode number."
67 "\n -1 = use next available (default)" 67 "\n -1 = use next available (default)"
68 "\n n = use minor number n (integer >= 0)" 68 "\n n = use minor number n (integer >= 0)"
69 "\nYou can specify up to " 69 "\nYou can specify up to "
70 __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way." 70 __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way."
71 "\nFor example:" 71 "\nFor example:"
72 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 72 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
73 "\nthe second registered camera and use auto for the first" 73 "\nthe second registered camera and use auto for the first"
74 "\none and for every other camera." 74 "\none and for every other camera."
75 "\n"); 75 "\n");
76 76
77static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] = 77static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
78 ET61X251_FORCE_MUNMAP}; 78 ET61X251_FORCE_MUNMAP};
79module_param_array(force_munmap, bool, NULL, 0444); 79module_param_array(force_munmap, bool, NULL, 0444);
80MODULE_PARM_DESC(force_munmap, 80MODULE_PARM_DESC(force_munmap,
81 "\n<0|1[,...]> Force the application to unmap previously" 81 "\n<0|1[,...]> Force the application to unmap previously"
82 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 82 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
83 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 83 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
84 "\nthis feature. This parameter is specific for each" 84 "\nthis feature. This parameter is specific for each"
85 "\ndetected camera." 85 "\ndetected camera."
86 "\n 0 = do not force memory unmapping" 86 "\n 0 = do not force memory unmapping"
87 "\n 1 = force memory unmapping (save memory)" 87 "\n 1 = force memory unmapping (save memory)"
88 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 88 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
89 "\n"); 89 "\n");
90 90
91static unsigned int frame_timeout[] = {[0 ... ET61X251_MAX_DEVICES-1] = 91static unsigned int frame_timeout[] = {[0 ... ET61X251_MAX_DEVICES-1] =
92 ET61X251_FRAME_TIMEOUT}; 92 ET61X251_FRAME_TIMEOUT};
93module_param_array(frame_timeout, uint, NULL, 0644); 93module_param_array(frame_timeout, uint, NULL, 0644);
94MODULE_PARM_DESC(frame_timeout, 94MODULE_PARM_DESC(frame_timeout,
95 "\n<n[,...]> Timeout for a video frame in seconds." 95 "\n<n[,...]> Timeout for a video frame in seconds."
96 "\nThis parameter is specific for each detected camera." 96 "\nThis parameter is specific for each detected camera."
97 "\nDefault value is " 97 "\nDefault value is "
98 __MODULE_STRING(ET61X251_FRAME_TIMEOUT)"." 98 __MODULE_STRING(ET61X251_FRAME_TIMEOUT)"."
99 "\n"); 99 "\n");
100 100
101#ifdef ET61X251_DEBUG 101#ifdef ET61X251_DEBUG
102static unsigned short debug = ET61X251_DEBUG_LEVEL; 102static unsigned short debug = ET61X251_DEBUG_LEVEL;
103module_param(debug, ushort, 0644); 103module_param(debug, ushort, 0644);
104MODULE_PARM_DESC(debug, 104MODULE_PARM_DESC(debug,
105 "\n<n> Debugging information level, from 0 to 3:" 105 "\n<n> Debugging information level, from 0 to 3:"
106 "\n0 = none (use carefully)" 106 "\n0 = none (use carefully)"
107 "\n1 = critical errors" 107 "\n1 = critical errors"
108 "\n2 = significant informations" 108 "\n2 = significant informations"
109 "\n3 = more verbose messages" 109 "\n3 = more verbose messages"
110 "\nLevel 3 is useful for testing only, when only " 110 "\nLevel 3 is useful for testing only, when only "
111 "one device is used." 111 "one device is used."
112 "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"." 112 "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"."
113 "\n"); 113 "\n");
114#endif 114#endif
115 115
116/*****************************************************************************/ 116/*****************************************************************************/
117 117
118static u32 118static u32
119et61x251_request_buffers(struct et61x251_device* cam, u32 count, 119et61x251_request_buffers(struct et61x251_device* cam, u32 count,
120 enum et61x251_io_method io) 120 enum et61x251_io_method io)
121{ 121{
122 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 122 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
123 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 123 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
124 const size_t imagesize = cam->module_param.force_munmap || 124 const size_t imagesize = cam->module_param.force_munmap ||
125 io == IO_READ ? 125 io == IO_READ ?
126 (p->width * p->height * p->priv) / 8 : 126 (p->width * p->height * p->priv) / 8 :
127 (r->width * r->height * p->priv) / 8; 127 (r->width * r->height * p->priv) / 8;
128 void* buff = NULL; 128 void* buff = NULL;
129 u32 i; 129 u32 i;
130 130
@@ -216,7 +216,7 @@ int et61x251_write_reg(struct et61x251_device* cam, u8 value, u16 index)
216 *buff = value; 216 *buff = value;
217 217
218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
219 0, index, buff, 1, ET61X251_CTRL_TIMEOUT); 219 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
220 if (res < 0) { 220 if (res < 0) {
221 DBG(3, "Failed to write a register (value 0x%02X, index " 221 DBG(3, "Failed to write a register (value 0x%02X, index "
222 "0x%02X, error %d)", value, index, res); 222 "0x%02X, error %d)", value, index, res);
@@ -234,7 +234,7 @@ int et61x251_read_reg(struct et61x251_device* cam, u16 index)
234 int res; 234 int res;
235 235
236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
237 0, index, buff, 1, ET61X251_CTRL_TIMEOUT); 237 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
238 if (res < 0) 238 if (res < 0)
239 DBG(3, "Failed to read a register (index 0x%02X, error %d)", 239 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
240 index, res); 240 index, res);
@@ -269,7 +269,7 @@ et61x251_i2c_wait(struct et61x251_device* cam, struct et61x251_sensor* sensor)
269 269
270int 270int
271et61x251_i2c_try_read(struct et61x251_device* cam, 271et61x251_i2c_try_read(struct et61x251_device* cam,
272 struct et61x251_sensor* sensor, u8 address) 272 struct et61x251_sensor* sensor, u8 address)
273{ 273{
274 struct usb_device* udev = cam->usbdev; 274 struct usb_device* udev = cam->usbdev;
275 u8* data = cam->control_buffer; 275 u8* data = cam->control_buffer;
@@ -280,14 +280,14 @@ et61x251_i2c_try_read(struct et61x251_device* cam,
280 data[2] = cam->sensor.rsta | 0x10; 280 data[2] = cam->sensor.rsta | 0x10;
281 data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02); 281 data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02);
282 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 282 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
283 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT); 283 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT);
284 if (res < 0) 284 if (res < 0)
285 err += res; 285 err += res;
286 286
287 err += et61x251_i2c_wait(cam, sensor); 287 err += et61x251_i2c_wait(cam, sensor);
288 288
289 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 289 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
290 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT); 290 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT);
291 if (res < 0) 291 if (res < 0)
292 err += res; 292 err += res;
293 293
@@ -302,7 +302,7 @@ et61x251_i2c_try_read(struct et61x251_device* cam,
302 302
303int 303int
304et61x251_i2c_try_write(struct et61x251_device* cam, 304et61x251_i2c_try_write(struct et61x251_device* cam,
305 struct et61x251_sensor* sensor, u8 address, u8 value) 305 struct et61x251_sensor* sensor, u8 address, u8 value)
306{ 306{
307 struct usb_device* udev = cam->usbdev; 307 struct usb_device* udev = cam->usbdev;
308 u8* data = cam->control_buffer; 308 u8* data = cam->control_buffer;
@@ -312,13 +312,13 @@ et61x251_i2c_try_write(struct et61x251_device* cam,
312 data[1] = cam->sensor.i2c_slave_id; 312 data[1] = cam->sensor.i2c_slave_id;
313 data[2] = cam->sensor.rsta | 0x12; 313 data[2] = cam->sensor.rsta | 0x12;
314 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 314 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
315 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT); 315 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
316 if (res < 0) 316 if (res < 0)
317 err += res; 317 err += res;
318 318
319 data[0] = value; 319 data[0] = value;
320 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 320 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
321 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT); 321 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
322 if (res < 0) 322 if (res < 0)
323 err += res; 323 err += res;
324 324
@@ -335,8 +335,8 @@ et61x251_i2c_try_write(struct et61x251_device* cam,
335 335
336int 336int
337et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2, 337et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
338 u8 data3, u8 data4, u8 data5, u8 data6, u8 data7, 338 u8 data3, u8 data4, u8 data5, u8 data6, u8 data7,
339 u8 data8, u8 address) 339 u8 data8, u8 address)
340{ 340{
341 struct usb_device* udev = cam->usbdev; 341 struct usb_device* udev = cam->usbdev;
342 u8* data = cam->control_buffer; 342 u8* data = cam->control_buffer;
@@ -350,7 +350,7 @@ et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
350 data[5] = data7; 350 data[5] = data7;
351 data[6] = data8; 351 data[6] = data8;
352 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 352 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
353 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT); 353 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT);
354 if (res < 0) 354 if (res < 0)
355 err += res; 355 err += res;
356 356
@@ -358,14 +358,14 @@ et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
358 data[1] = cam->sensor.i2c_slave_id; 358 data[1] = cam->sensor.i2c_slave_id;
359 data[2] = cam->sensor.rsta | 0x02 | (n << 4); 359 data[2] = cam->sensor.rsta | 0x02 | (n << 4);
360 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 360 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
361 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT); 361 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
362 if (res < 0) 362 if (res < 0)
363 err += res; 363 err += res;
364 364
365 /* Start writing through the serial interface */ 365 /* Start writing through the serial interface */
366 data[0] = data1; 366 data[0] = data1;
367 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, 367 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
368 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT); 368 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
369 if (res < 0) 369 if (res < 0)
370 err += res; 370 err += res;
371 371
@@ -432,11 +432,11 @@ static void et61x251_urb_complete(struct urb *urb, struct pt_regs* regs)
432 432
433 if (!(*f)) 433 if (!(*f))
434 (*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t, 434 (*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t,
435 frame); 435 frame);
436 436
437 imagesize = (cam->sensor.pix_format.width * 437 imagesize = (cam->sensor.pix_format.width *
438 cam->sensor.pix_format.height * 438 cam->sensor.pix_format.height *
439 cam->sensor.pix_format.priv) / 8; 439 cam->sensor.pix_format.priv) / 8;
440 440
441 for (i = 0; i < urb->number_of_packets; i++) { 441 for (i = 0; i < urb->number_of_packets; i++) {
442 unsigned int len, status; 442 unsigned int len, status;
@@ -476,7 +476,7 @@ start_of_frame:
476 if ((*f)->state == F_GRABBING) { 476 if ((*f)->state == F_GRABBING) {
477 if (sof && (*f)->buf.bytesused) { 477 if (sof && (*f)->buf.bytesused) {
478 if (cam->sensor.pix_format.pixelformat == 478 if (cam->sensor.pix_format.pixelformat ==
479 V4L2_PIX_FMT_ET61X251) 479 V4L2_PIX_FMT_ET61X251)
480 goto end_of_frame; 480 goto end_of_frame;
481 else { 481 else {
482 DBG(3, "Not expected SOF detected " 482 DBG(3, "Not expected SOF detected "
@@ -508,8 +508,8 @@ end_of_frame:
508 list_move_tail(&(*f)->frame, &cam->outqueue); 508 list_move_tail(&(*f)->frame, &cam->outqueue);
509 if (!list_empty(&cam->inqueue)) 509 if (!list_empty(&cam->inqueue))
510 (*f) = list_entry(cam->inqueue.next, 510 (*f) = list_entry(cam->inqueue.next,
511 struct et61x251_frame_t, 511 struct et61x251_frame_t,
512 frame); 512 frame);
513 else 513 else
514 (*f) = NULL; 514 (*f) = NULL;
515 spin_unlock(&cam->queue_lock); 515 spin_unlock(&cam->queue_lock);
@@ -521,7 +521,7 @@ end_of_frame:
521 521
522 if (sof && 522 if (sof &&
523 cam->sensor.pix_format.pixelformat == 523 cam->sensor.pix_format.pixelformat ==
524 V4L2_PIX_FMT_ET61X251) 524 V4L2_PIX_FMT_ET61X251)
525 goto start_of_frame; 525 goto start_of_frame;
526 } 526 }
527 } 527 }
@@ -544,15 +544,15 @@ static int et61x251_start_transfer(struct et61x251_device* cam)
544 struct usb_device *udev = cam->usbdev; 544 struct usb_device *udev = cam->usbdev;
545 struct urb* urb; 545 struct urb* urb;
546 const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832, 546 const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832,
547 864, 896, 920, 956, 980, 1000, 547 864, 896, 920, 956, 980, 1000,
548 1022}; 548 1022};
549 const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING]; 549 const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING];
550 s8 i, j; 550 s8 i, j;
551 int err = 0; 551 int err = 0;
552 552
553 for (i = 0; i < ET61X251_URBS; i++) { 553 for (i = 0; i < ET61X251_URBS; i++) {
554 cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz, 554 cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz,
555 GFP_KERNEL); 555 GFP_KERNEL);
556 if (!cam->transfer_buffer[i]) { 556 if (!cam->transfer_buffer[i]) {
557 err = -ENOMEM; 557 err = -ENOMEM;
558 DBG(1, "Not enough memory"); 558 DBG(1, "Not enough memory");
@@ -653,9 +653,9 @@ static int et61x251_stream_interrupt(struct et61x251_device* cam)
653 653
654 cam->stream = STREAM_INTERRUPT; 654 cam->stream = STREAM_INTERRUPT;
655 timeout = wait_event_timeout(cam->wait_stream, 655 timeout = wait_event_timeout(cam->wait_stream,
656 (cam->stream == STREAM_OFF) || 656 (cam->stream == STREAM_OFF) ||
657 (cam->state & DEV_DISCONNECTED), 657 (cam->state & DEV_DISCONNECTED),
658 ET61X251_URB_TIMEOUT); 658 ET61X251_URB_TIMEOUT);
659 if (cam->state & DEV_DISCONNECTED) 659 if (cam->state & DEV_DISCONNECTED)
660 return -ENODEV; 660 return -ENODEV;
661 else if (cam->stream != STREAM_OFF) { 661 else if (cam->stream != STREAM_OFF) {
@@ -699,7 +699,7 @@ static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count)
699 699
700/* 700/*
701 NOTE 1: being inside one of the following methods implies that the v4l 701 NOTE 1: being inside one of the following methods implies that the v4l
702 device exists for sure (see kobjects and reference counters) 702 device exists for sure (see kobjects and reference counters)
703 NOTE 2: buffers are PAGE_SIZE long 703 NOTE 2: buffers are PAGE_SIZE long
704*/ 704*/
705 705
@@ -964,13 +964,13 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
964 964
965 965
966static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, 966static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
967 et61x251_show_reg, et61x251_store_reg); 967 et61x251_show_reg, et61x251_store_reg);
968static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, 968static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
969 et61x251_show_val, et61x251_store_val); 969 et61x251_show_val, et61x251_store_val);
970static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, 970static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
971 et61x251_show_i2c_reg, et61x251_store_i2c_reg); 971 et61x251_show_i2c_reg, et61x251_store_i2c_reg);
972static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, 972static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
973 et61x251_show_i2c_val, et61x251_store_i2c_val); 973 et61x251_show_i2c_val, et61x251_store_i2c_val);
974 974
975 975
976static void et61x251_create_sysfs(struct et61x251_device* cam) 976static void et61x251_create_sysfs(struct et61x251_device* cam)
@@ -990,7 +990,7 @@ static void et61x251_create_sysfs(struct et61x251_device* cam)
990 990
991static int 991static int
992et61x251_set_pix_format(struct et61x251_device* cam, 992et61x251_set_pix_format(struct et61x251_device* cam,
993 struct v4l2_pix_format* pix) 993 struct v4l2_pix_format* pix)
994{ 994{
995 int r, err = 0; 995 int r, err = 0;
996 996
@@ -1007,7 +1007,7 @@ et61x251_set_pix_format(struct et61x251_device* cam,
1007 1007
1008static int 1008static int
1009et61x251_set_compression(struct et61x251_device* cam, 1009et61x251_set_compression(struct et61x251_device* cam,
1010 struct v4l2_jpegcompression* compression) 1010 struct v4l2_jpegcompression* compression)
1011{ 1011{
1012 int r, err = 0; 1012 int r, err = 0;
1013 1013
@@ -1049,9 +1049,9 @@ et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
1049{ 1049{
1050 struct et61x251_sensor* s = &cam->sensor; 1050 struct et61x251_sensor* s = &cam->sensor;
1051 u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left + 1051 u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left +
1052 s->active_pixel.left), 1052 s->active_pixel.left),
1053 fmw_sy = (u16)(rect->top - s->cropcap.bounds.top + 1053 fmw_sy = (u16)(rect->top - s->cropcap.bounds.top +
1054 s->active_pixel.top), 1054 s->active_pixel.top),
1055 fmw_length = (u16)(rect->width), 1055 fmw_length = (u16)(rect->width),
1056 fmw_height = (u16)(rect->height); 1056 fmw_height = (u16)(rect->height);
1057 int err = 0; 1057 int err = 0;
@@ -1061,8 +1061,8 @@ et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
1061 err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b); 1061 err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b);
1062 err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c); 1062 err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c);
1063 err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6) 1063 err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6)
1064 | ((fmw_length & 0x300) >> 4) 1064 | ((fmw_length & 0x300) >> 4)
1065 | ((fmw_height & 0x300) >> 2), 0x6d); 1065 | ((fmw_height & 0x300) >> 2), 0x6d);
1066 if (err) 1066 if (err)
1067 return -EIO; 1067 return -EIO;
1068 1068
@@ -1203,8 +1203,8 @@ static int et61x251_open(struct inode* inode, struct file* filp)
1203 } 1203 }
1204 mutex_unlock(&cam->dev_mutex); 1204 mutex_unlock(&cam->dev_mutex);
1205 err = wait_event_interruptible_exclusive(cam->open, 1205 err = wait_event_interruptible_exclusive(cam->open,
1206 cam->state & DEV_DISCONNECTED 1206 cam->state & DEV_DISCONNECTED
1207 || !cam->users); 1207 || !cam->users);
1208 if (err) { 1208 if (err) {
1209 up_read(&et61x251_disconnect); 1209 up_read(&et61x251_disconnect);
1210 return err; 1210 return err;
@@ -1277,7 +1277,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
1277 1277
1278static ssize_t 1278static ssize_t
1279et61x251_read(struct file* filp, char __user * buf, 1279et61x251_read(struct file* filp, char __user * buf,
1280 size_t count, loff_t* f_pos) 1280 size_t count, loff_t* f_pos)
1281{ 1281{
1282 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 1282 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1283 struct et61x251_frame_t* f, * i; 1283 struct et61x251_frame_t* f, * i;
@@ -1310,7 +1310,7 @@ et61x251_read(struct file* filp, char __user * buf,
1310 1310
1311 if (cam->io == IO_NONE) { 1311 if (cam->io == IO_NONE) {
1312 if (!et61x251_request_buffers(cam, cam->nreadbuffers, 1312 if (!et61x251_request_buffers(cam, cam->nreadbuffers,
1313 IO_READ)) { 1313 IO_READ)) {
1314 DBG(1, "read() failed, not enough memory"); 1314 DBG(1, "read() failed, not enough memory");
1315 mutex_unlock(&cam->fileop_mutex); 1315 mutex_unlock(&cam->fileop_mutex);
1316 return -ENOMEM; 1316 return -ENOMEM;
@@ -1336,12 +1336,12 @@ et61x251_read(struct file* filp, char __user * buf,
1336 return -EAGAIN; 1336 return -EAGAIN;
1337 } 1337 }
1338 timeout = wait_event_interruptible_timeout 1338 timeout = wait_event_interruptible_timeout
1339 ( cam->wait_frame, 1339 ( cam->wait_frame,
1340 (!list_empty(&cam->outqueue)) || 1340 (!list_empty(&cam->outqueue)) ||
1341 (cam->state & DEV_DISCONNECTED) || 1341 (cam->state & DEV_DISCONNECTED) ||
1342 (cam->state & DEV_MISCONFIGURED), 1342 (cam->state & DEV_MISCONFIGURED),
1343 cam->module_param.frame_timeout * 1343 cam->module_param.frame_timeout *
1344 1000 * msecs_to_jiffies(1) ); 1344 1000 * msecs_to_jiffies(1) );
1345 if (timeout < 0) { 1345 if (timeout < 0) {
1346 mutex_unlock(&cam->fileop_mutex); 1346 mutex_unlock(&cam->fileop_mutex);
1347 return timeout; 1347 return timeout;
@@ -1408,7 +1408,7 @@ static unsigned int et61x251_poll(struct file *filp, poll_table *wait)
1408 1408
1409 if (cam->io == IO_NONE) { 1409 if (cam->io == IO_NONE) {
1410 if (!et61x251_request_buffers(cam, cam->nreadbuffers, 1410 if (!et61x251_request_buffers(cam, cam->nreadbuffers,
1411 IO_READ)) { 1411 IO_READ)) {
1412 DBG(1, "poll() failed, not enough memory"); 1412 DBG(1, "poll() failed, not enough memory");
1413 goto error; 1413 goto error;
1414 } 1414 }
@@ -1465,7 +1465,7 @@ static int et61x251_mmap(struct file* filp, struct vm_area_struct *vma)
1465{ 1465{
1466 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 1466 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1467 unsigned long size = vma->vm_end - vma->vm_start, 1467 unsigned long size = vma->vm_end - vma->vm_start,
1468 start = vma->vm_start; 1468 start = vma->vm_start;
1469 void *pos; 1469 void *pos;
1470 u32 i; 1470 u32 i;
1471 1471
@@ -1533,13 +1533,13 @@ et61x251_vidioc_querycap(struct et61x251_device* cam, void __user * arg)
1533 .driver = "et61x251", 1533 .driver = "et61x251",
1534 .version = ET61X251_MODULE_VERSION_CODE, 1534 .version = ET61X251_MODULE_VERSION_CODE,
1535 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1535 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1536 V4L2_CAP_STREAMING, 1536 V4L2_CAP_STREAMING,
1537 }; 1537 };
1538 1538
1539 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1539 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1540 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1540 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1541 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1541 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1542 sizeof(cap.bus_info)); 1542 sizeof(cap.bus_info));
1543 1543
1544 if (copy_to_user(arg, &cap, sizeof(cap))) 1544 if (copy_to_user(arg, &cap, sizeof(cap)))
1545 return -EFAULT; 1545 return -EFAULT;
@@ -1871,7 +1871,7 @@ et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
1871 return -EINVAL; 1871 return -EINVAL;
1872 1872
1873 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251) 1873 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251)
1874 ? 0 : (pfmt->width * pfmt->priv) / 8; 1874 ? 0 : (pfmt->width * pfmt->priv) / 8;
1875 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8); 1875 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
1876 pfmt->field = V4L2_FIELD_NONE; 1876 pfmt->field = V4L2_FIELD_NONE;
1877 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt)); 1877 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -1885,7 +1885,7 @@ et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
1885 1885
1886static int 1886static int
1887et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd, 1887et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
1888 void __user * arg) 1888 void __user * arg)
1889{ 1889{
1890 struct et61x251_sensor* s = &cam->sensor; 1890 struct et61x251_sensor* s = &cam->sensor;
1891 struct v4l2_format format; 1891 struct v4l2_format format;
@@ -1947,7 +1947,7 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
1947 pix->priv = pfmt->priv; /* bpp */ 1947 pix->priv = pfmt->priv; /* bpp */
1948 pix->colorspace = pfmt->colorspace; 1948 pix->colorspace = pfmt->colorspace;
1949 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251) 1949 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251)
1950 ? 0 : (pix->width * pix->priv) / 8; 1950 ? 0 : (pix->width * pix->priv) / 8;
1951 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8); 1951 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
1952 pix->field = V4L2_FIELD_NONE; 1952 pix->field = V4L2_FIELD_NONE;
1953 1953
@@ -2020,7 +2020,7 @@ static int
2020et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg) 2020et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg)
2021{ 2021{
2022 if (copy_to_user(arg, &cam->compression, 2022 if (copy_to_user(arg, &cam->compression,
2023 sizeof(cam->compression))) 2023 sizeof(cam->compression)))
2024 return -EFAULT; 2024 return -EFAULT;
2025 2025
2026 return 0; 2026 return 0;
@@ -2169,7 +2169,7 @@ et61x251_vidioc_qbuf(struct et61x251_device* cam, void __user * arg)
2169 2169
2170static int 2170static int
2171et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp, 2171et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
2172 void __user * arg) 2172 void __user * arg)
2173{ 2173{
2174 struct v4l2_buffer b; 2174 struct v4l2_buffer b;
2175 struct et61x251_frame_t *f; 2175 struct et61x251_frame_t *f;
@@ -2188,12 +2188,12 @@ et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
2188 if (filp->f_flags & O_NONBLOCK) 2188 if (filp->f_flags & O_NONBLOCK)
2189 return -EAGAIN; 2189 return -EAGAIN;
2190 timeout = wait_event_interruptible_timeout 2190 timeout = wait_event_interruptible_timeout
2191 ( cam->wait_frame, 2191 ( cam->wait_frame,
2192 (!list_empty(&cam->outqueue)) || 2192 (!list_empty(&cam->outqueue)) ||
2193 (cam->state & DEV_DISCONNECTED) || 2193 (cam->state & DEV_DISCONNECTED) ||
2194 (cam->state & DEV_MISCONFIGURED), 2194 (cam->state & DEV_MISCONFIGURED),
2195 cam->module_param.frame_timeout * 2195 cam->module_param.frame_timeout *
2196 1000 * msecs_to_jiffies(1) ); 2196 1000 * msecs_to_jiffies(1) );
2197 if (timeout < 0) 2197 if (timeout < 0)
2198 return timeout; 2198 return timeout;
2199 if (cam->state & DEV_DISCONNECTED) 2199 if (cam->state & DEV_DISCONNECTED)
@@ -2317,7 +2317,7 @@ et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg)
2317 2317
2318 2318
2319static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp, 2319static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
2320 unsigned int cmd, void __user * arg) 2320 unsigned int cmd, void __user * arg)
2321{ 2321{
2322 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 2322 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
2323 2323
@@ -2411,7 +2411,7 @@ static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
2411 2411
2412 2412
2413static int et61x251_ioctl(struct inode* inode, struct file* filp, 2413static int et61x251_ioctl(struct inode* inode, struct file* filp,
2414 unsigned int cmd, unsigned long arg) 2414 unsigned int cmd, unsigned long arg)
2415{ 2415{
2416 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); 2416 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
2417 int err = 0; 2417 int err = 0;
@@ -2518,7 +2518,7 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2518 mutex_lock(&cam->dev_mutex); 2518 mutex_lock(&cam->dev_mutex);
2519 2519
2520 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 2520 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2521 video_nr[dev_nr]); 2521 video_nr[dev_nr]);
2522 if (err) { 2522 if (err) {
2523 DBG(1, "V4L2 device registration failed"); 2523 DBG(1, "V4L2 device registration failed");
2524 if (err == -ENFILE && video_nr[dev_nr] == -1) 2524 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 56841ae8a207..65edd08dc386 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);
47 47
48extern void 48extern void
49et61x251_attach_sensor(struct et61x251_device* cam, 49et61x251_attach_sensor(struct et61x251_device* cam,
50 struct et61x251_sensor* sensor); 50 struct et61x251_sensor* sensor);
51 51
52/*****************************************************************************/ 52/*****************************************************************************/
53 53
@@ -56,13 +56,13 @@ extern int et61x251_read_reg(struct et61x251_device*, u16 index);
56extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value); 56extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value);
57extern int et61x251_i2c_read(struct et61x251_device*, u8 address); 57extern int et61x251_i2c_read(struct et61x251_device*, u8 address);
58extern int et61x251_i2c_try_write(struct et61x251_device*, 58extern int et61x251_i2c_try_write(struct et61x251_device*,
59 struct et61x251_sensor*, u8 address, 59 struct et61x251_sensor*, u8 address,
60 u8 value); 60 u8 value);
61extern int et61x251_i2c_try_read(struct et61x251_device*, 61extern int et61x251_i2c_try_read(struct et61x251_device*,
62 struct et61x251_sensor*, u8 address); 62 struct et61x251_sensor*, u8 address);
63extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1, 63extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
64 u8 data2, u8 data3, u8 data4, u8 data5, 64 u8 data2, u8 data3, u8 data4, u8 data5,
65 u8 data6, u8 data7, u8 data8, u8 address); 65 u8 data6, u8 data7, u8 data8, u8 address);
66 66
67/*****************************************************************************/ 67/*****************************************************************************/
68 68
@@ -100,13 +100,13 @@ struct et61x251_sensor {
100 100
101 int (*init)(struct et61x251_device* cam); 101 int (*init)(struct et61x251_device* cam);
102 int (*get_ctrl)(struct et61x251_device* cam, 102 int (*get_ctrl)(struct et61x251_device* cam,
103 struct v4l2_control* ctrl); 103 struct v4l2_control* ctrl);
104 int (*set_ctrl)(struct et61x251_device* cam, 104 int (*set_ctrl)(struct et61x251_device* cam,
105 const struct v4l2_control* ctrl); 105 const struct v4l2_control* ctrl);
106 int (*set_crop)(struct et61x251_device* cam, 106 int (*set_crop)(struct et61x251_device* cam,
107 const struct v4l2_rect* rect); 107 const struct v4l2_rect* rect);
108 int (*set_pix_format)(struct et61x251_device* cam, 108 int (*set_pix_format)(struct et61x251_device* cam,
109 const struct v4l2_pix_format* pix); 109 const struct v4l2_pix_format* pix);
110 110
111 /* Private */ 111 /* Private */
112 struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS]; 112 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 3998d76a307a..a7d65b82b2fb 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)
46 46
47 47
48static int tas5130d1b_set_ctrl(struct et61x251_device* cam, 48static int tas5130d1b_set_ctrl(struct et61x251_device* cam,
49 const struct v4l2_control* ctrl) 49 const struct v4l2_control* ctrl)
50{ 50{
51 int err = 0; 51 int err = 0;
52 52
53 switch (ctrl->id) { 53 switch (ctrl->id) {
54 case V4L2_CID_GAIN: 54 case V4L2_CID_GAIN:
55 err += et61x251_i2c_raw_write(cam, 2, 0x20, 55 err += et61x251_i2c_raw_write(cam, 2, 0x20,
56 0xf6-ctrl->value, 0, 0, 0, 56 0xf6-ctrl->value, 0, 0, 0,
57 0, 0, 0, 0); 57 0, 0, 0, 0);
58 break; 58 break;
59 case V4L2_CID_EXPOSURE: 59 case V4L2_CID_EXPOSURE:
60 err += et61x251_i2c_raw_write(cam, 2, 0x40, 60 err += et61x251_i2c_raw_write(cam, 2, 0x40,
61 0x47-ctrl->value, 0, 0, 0, 61 0x47-ctrl->value, 0, 0, 0,
62 0, 0, 0, 0); 62 0, 0, 0, 0);
63 break; 63 break;
64 default: 64 default:
65 return -EINVAL; 65 return -EINVAL;
diff --git a/drivers/media/video/font.h b/drivers/media/video/font.h
new file mode 100644
index 000000000000..8b1fecc37599
--- /dev/null
+++ b/drivers/media/video/font.h
@@ -0,0 +1,407 @@
1static unsigned char rom8x16_bits[] = {
2/* Character 0 (0x30):
3 ht=16, width=8
4 +--------+
5 | |
6 | |
7 | ***** |
8 |** ** |
9 |** ** |
10 |** *** |
11 |** **** |
12 |**** ** |
13 |*** ** |
14 |** ** |
15 |** ** |
16 | ***** |
17 | |
18 | |
19 | |
20 | |
21 +--------+ */
220x00,
230x00,
240x7c,
250xc6,
260xc6,
270xce,
280xde,
290xf6,
300xe6,
310xc6,
320xc6,
330x7c,
340x00,
350x00,
360x00,
370x00,
38
39/* Character 1 (0x31):
40 ht=16, width=8
41 +--------+
42 | |
43 | |
44 | ** |
45 | **** |
46 | ** |
47 | ** |
48 | ** |
49 | ** |
50 | ** |
51 | ** |
52 | ** |
53 | ****** |
54 | |
55 | |
56 | |
57 | |
58 +--------+ */
590x00,
600x00,
610x18,
620x78,
630x18,
640x18,
650x18,
660x18,
670x18,
680x18,
690x18,
700x7e,
710x00,
720x00,
730x00,
740x00,
75
76/* Character 2 (0x32):
77 ht=16, width=8
78 +--------+
79 | |
80 | |
81 | ***** |
82 |** ** |
83 |** ** |
84 | ** |
85 | ** |
86 | ** |
87 | ** |
88 | ** |
89 |** ** |
90 |******* |
91 | |
92 | |
93 | |
94 | |
95 +--------+ */
960x00,
970x00,
980x7c,
990xc6,
1000xc6,
1010x06,
1020x0c,
1030x18,
1040x30,
1050x60,
1060xc6,
1070xfe,
1080x00,
1090x00,
1100x00,
1110x00,
112
113/* Character 3 (0x33):
114 ht=16, width=8
115 +--------+
116 | |
117 | |
118 | ***** |
119 |** ** |
120 | ** |
121 | ** |
122 | **** |
123 | ** |
124 | ** |
125 | ** |
126 |** ** |
127 | ***** |
128 | |
129 | |
130 | |
131 | |
132 +--------+ */
1330x00,
1340x00,
1350x7c,
1360xc6,
1370x06,
1380x06,
1390x3c,
1400x06,
1410x06,
1420x06,
1430xc6,
1440x7c,
1450x00,
1460x00,
1470x00,
1480x00,
149
150/* Character 4 (0x34):
151 ht=16, width=8
152 +--------+
153 | |
154 | |
155 | ** |
156 | *** |
157 | **** |
158 | ** ** |
159 |** ** |
160 |** ** |
161 |******* |
162 | ** |
163 | ** |
164 | **** |
165 | |
166 | |
167 | |
168 | |
169 +--------+ */
1700x00,
1710x00,
1720x0c,
1730x1c,
1740x3c,
1750x6c,
1760xcc,
1770xcc,
1780xfe,
1790x0c,
1800x0c,
1810x1e,
1820x00,
1830x00,
1840x00,
1850x00,
186
187/* Character 5 (0x35):
188 ht=16, width=8
189 +--------+
190 | |
191 | |
192 |******* |
193 |** |
194 |** |
195 |** |
196 |****** |
197 | ** |
198 | ** |
199 | ** |
200 |** ** |
201 | ***** |
202 | |
203 | |
204 | |
205 | |
206 +--------+ */
2070x00,
2080x00,
2090xfe,
2100xc0,
2110xc0,
2120xc0,
2130xfc,
2140x06,
2150x06,
2160x06,
2170xc6,
2180x7c,
2190x00,
2200x00,
2210x00,
2220x00,
223
224/* Character 6 (0x36):
225 ht=16, width=8
226 +--------+
227 | |
228 | |
229 | ***** |
230 |** ** |
231 |** |
232 |** |
233 |****** |
234 |** ** |
235 |** ** |
236 |** ** |
237 |** ** |
238 | ***** |
239 | |
240 | |
241 | |
242 | |
243 +--------+ */
2440x00,
2450x00,
2460x7c,
2470xc6,
2480xc0,
2490xc0,
2500xfc,
2510xc6,
2520xc6,
2530xc6,
2540xc6,
2550x7c,
2560x00,
2570x00,
2580x00,
2590x00,
260
261/* Character 7 (0x37):
262 ht=16, width=8
263 +--------+
264 | |
265 | |
266 |******* |
267 |** ** |
268 | ** |
269 | ** |
270 | ** |
271 | ** |
272 | ** |
273 | ** |
274 | ** |
275 | ** |
276 | |
277 | |
278 | |
279 | |
280 +--------+ */
2810x00,
2820x00,
2830xfe,
2840xc6,
2850x06,
2860x0c,
2870x18,
2880x30,
2890x30,
2900x30,
2910x30,
2920x30,
2930x00,
2940x00,
2950x00,
2960x00,
297
298/* Character 8 (0x38):
299 ht=16, width=8
300 +--------+
301 | |
302 | |
303 | ***** |
304 |** ** |
305 |** ** |
306 |** ** |
307 | ***** |
308 |** ** |
309 |** ** |
310 |** ** |
311 |** ** |
312 | ***** |
313 | |
314 | |
315 | |
316 | |
317 +--------+ */
3180x00,
3190x00,
3200x7c,
3210xc6,
3220xc6,
3230xc6,
3240x7c,
3250xc6,
3260xc6,
3270xc6,
3280xc6,
3290x7c,
3300x00,
3310x00,
3320x00,
3330x00,
334
335/* Character 9 (0x39):
336 ht=16, width=8
337 +--------+
338 | |
339 | |
340 | ***** |
341 |** ** |
342 |** ** |
343 |** ** |
344 |** ** |
345 | ****** |
346 | ** |
347 | ** |
348 |** ** |
349 | ***** |
350 | |
351 | |
352 | |
353 | |
354 +--------+ */
3550x00,
3560x00,
3570x7c,
3580xc6,
3590xc6,
3600xc6,
3610xc6,
3620x7e,
3630x06,
3640x06,
3650xc6,
3660x7c,
3670x00,
3680x00,
3690x00,
3700x00,
371/* Character : (0x3a):
372 ht=16, width=8
373 +--------+
374 | |
375 | |
376 | |
377 | |
378 | |
379 | ** |
380 | ** |
381 | |
382 | |
383 | ** |
384 | ** |
385 | |
386 | |
387 | |
388 | |
389 | |
390 +--------+ */
3910x00,
3920x00,
3930x00,
3940x00,
3950x00,
3960x0c,
3970x0c,
3980x00,
3990x00,
4000x0c,
4010x0c,
4020x00,
4030x00,
4040x00,
4050x00,
4060x00,
407};
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 11ea9765769c..c40e8ba9a2ea 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -53,10 +53,11 @@
53#include <linux/videodev.h> 53#include <linux/videodev.h>
54#include <linux/videodev2.h> 54#include <linux/videodev2.h>
55#include <media/v4l2-common.h> 55#include <media/v4l2-common.h>
56#include <media/audiochip.h> 56#include <media/tvaudio.h>
57#include <media/msp3400.h>
57#include <linux/kthread.h> 58#include <linux/kthread.h>
58#include <linux/suspend.h> 59#include <linux/suspend.h>
59#include "msp3400.h" 60#include "msp3400-driver.h"
60 61
61/* ---------------------------------------------------------------------- */ 62/* ---------------------------------------------------------------------- */
62 63
@@ -245,31 +246,31 @@ int msp_write_dsp(struct i2c_client *client, int addr, int val)
245 * ----------------------------------------------------------------------- */ 246 * ----------------------------------------------------------------------- */
246 247
247static int scarts[3][9] = { 248static int scarts[3][9] = {
248 /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */ 249 /* MASK IN1 IN2 IN3 IN4 IN1_DA IN2_DA MONO MUTE */
249 /* SCART DSP Input select */ 250 /* SCART DSP Input select */
250 { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 }, 251 { 0x0320, 0x0000, 0x0200, 0x0300, 0x0020, -1, -1, 0x0100, 0x0320 },
251 /* SCART1 Output select */ 252 /* SCART1 Output select */
252 { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 }, 253 { 0x0c40, 0x0440, 0x0400, 0x0000, 0x0840, 0x0c00, 0x0040, 0x0800, 0x0c40 },
253 /* SCART2 Output select */ 254 /* SCART2 Output select */
254 { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 }, 255 { 0x3080, 0x1000, 0x1080, 0x2080, 0x3080, 0x0000, 0x0080, 0x2000, 0x3000 },
255}; 256};
256 257
257static char *scart_names[] = { 258static char *scart_names[] = {
258 "mask", "in1", "in2", "in1 da", "in2 da", "in3", "in4", "mono", "mute" 259 "in1", "in2", "in3", "in4", "in1 da", "in2 da", "mono", "mute"
259}; 260};
260 261
261void msp_set_scart(struct i2c_client *client, int in, int out) 262void msp_set_scart(struct i2c_client *client, int in, int out)
262{ 263{
263 struct msp_state *state = i2c_get_clientdata(client); 264 struct msp_state *state = i2c_get_clientdata(client);
264 265
265 state->in_scart=in; 266 state->in_scart = in;
266 267
267 if (in >= 1 && in <= 8 && out >= 0 && out <= 2) { 268 if (in >= 0 && in <= 7 && out >= 0 && out <= 2) {
268 if (-1 == scarts[out][in]) 269 if (-1 == scarts[out][in + 1])
269 return; 270 return;
270 271
271 state->acb &= ~scarts[out][SCART_MASK]; 272 state->acb &= ~scarts[out][0];
272 state->acb |= scarts[out][in]; 273 state->acb |= scarts[out][in + 1];
273 } else 274 } else
274 state->acb = 0xf60; /* Mute Input and SCART 1 Output */ 275 state->acb = 0xf60; /* Mute Input and SCART 1 Output */
275 276
@@ -336,37 +337,6 @@ void msp_set_audio(struct i2c_client *client)
336 msp_write_dsp(client, 0x0033, loudness); 337 msp_write_dsp(client, 0x0033, loudness);
337} 338}
338 339
339int msp_modus(struct i2c_client *client)
340{
341 struct msp_state *state = i2c_get_clientdata(client);
342
343 if (state->radio) {
344 v4l_dbg(1, msp_debug, client, "video mode selected to Radio\n");
345 return 0x0003;
346 }
347
348 if (state->v4l2_std & V4L2_STD_PAL) {
349 v4l_dbg(1, msp_debug, client, "video mode selected to PAL\n");
350
351#if 1
352 /* experimental: not sure this works with all chip versions */
353 return 0x7003;
354#else
355 /* previous value, try this if it breaks ... */
356 return 0x1003;
357#endif
358 }
359 if (state->v4l2_std & V4L2_STD_NTSC) {
360 v4l_dbg(1, msp_debug, client, "video mode selected to NTSC\n");
361 return 0x2003;
362 }
363 if (state->v4l2_std & V4L2_STD_SECAM) {
364 v4l_dbg(1, msp_debug, client, "video mode selected to SECAM\n");
365 return 0x0003;
366 }
367 return 0x0003;
368}
369
370/* ------------------------------------------------------------------------ */ 340/* ------------------------------------------------------------------------ */
371 341
372 342
@@ -585,51 +555,11 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
585static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) 555static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
586{ 556{
587 struct msp_state *state = i2c_get_clientdata(client); 557 struct msp_state *state = i2c_get_clientdata(client);
588 u16 *sarg = arg;
589 int scart = 0;
590 558
591 if (msp_debug >= 2) 559 if (msp_debug >= 2)
592 v4l_i2c_print_ioctl(client, cmd); 560 v4l_i2c_print_ioctl(client, cmd);
593 561
594 switch (cmd) { 562 switch (cmd) {
595 case AUDC_SET_INPUT:
596 if (*sarg == state->input)
597 break;
598 state->input = *sarg;
599 switch (*sarg) {
600 case AUDIO_RADIO:
601 /* Hauppauge uses IN2 for the radio */
602 state->mode = MSP_MODE_FM_RADIO;
603 scart = SCART_IN2;
604 break;
605 case AUDIO_EXTERN_1:
606 /* IN1 is often used for external input ... */
607 state->mode = MSP_MODE_EXTERN;
608 scart = SCART_IN1;
609 break;
610 case AUDIO_EXTERN_2:
611 /* ... sometimes it is IN2 through ;) */
612 state->mode = MSP_MODE_EXTERN;
613 scart = SCART_IN2;
614 break;
615 case AUDIO_TUNER:
616 state->mode = -1;
617 break;
618 default:
619 if (*sarg & AUDIO_MUTE)
620 msp_set_scart(client, SCART_MUTE, 0);
621 break;
622 }
623 if (scart) {
624 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
625 msp_set_scart(client, scart, 0);
626 msp_write_dsp(client, 0x000d, 0x1900);
627 if (state->opmode != OPMODE_AUTOSELECT)
628 msp_set_audmode(client);
629 }
630 msp_wake_thread(client);
631 break;
632
633 case AUDC_SET_RADIO: 563 case AUDC_SET_RADIO:
634 if (state->radio) 564 if (state->radio)
635 return 0; 565 return 0;
@@ -692,6 +622,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
692 622
693 if (va->mode != 0 && state->radio == 0) { 623 if (va->mode != 0 && state->radio == 0) {
694 state->audmode = msp_mode_v4l1_to_v4l2(va->mode); 624 state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
625 msp_set_audmode(client);
695 } 626 }
696 break; 627 break;
697 } 628 }
@@ -728,15 +659,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
728 break; 659 break;
729 } 660 }
730 661
731 /* msp34xx specific */
732 case MSP_SET_MATRIX:
733 {
734 struct msp_matrix *mspm = arg;
735
736 msp_set_scart(client, mspm->input, mspm->output);
737 break;
738 }
739
740 /* --- v4l2 ioctls --- */ 662 /* --- v4l2 ioctls --- */
741 case VIDIOC_S_STD: 663 case VIDIOC_S_STD:
742 { 664 {
@@ -750,90 +672,34 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
750 return 0; 672 return 0;
751 } 673 }
752 674
753 case VIDIOC_ENUMINPUT: 675 case VIDIOC_INT_G_AUDIO_ROUTING:
754 {
755 struct v4l2_input *i = arg;
756
757 if (i->index != 0)
758 return -EINVAL;
759
760 i->type = V4L2_INPUT_TYPE_TUNER;
761 switch (i->index) {
762 case AUDIO_RADIO:
763 strcpy(i->name, "Radio");
764 break;
765 case AUDIO_EXTERN_1:
766 strcpy(i->name, "Extern 1");
767 break;
768 case AUDIO_EXTERN_2:
769 strcpy(i->name, "Extern 2");
770 break;
771 case AUDIO_TUNER:
772 strcpy(i->name, "Television");
773 break;
774 default:
775 return -EINVAL;
776 }
777 return 0;
778 }
779
780 case VIDIOC_G_AUDIO:
781 { 676 {
782 struct v4l2_audio *a = arg; 677 struct v4l2_routing *rt = arg;
783 678
784 memset(a, 0, sizeof(*a)); 679 *rt = state->routing;
785
786 switch (a->index) {
787 case AUDIO_RADIO:
788 strcpy(a->name, "Radio");
789 break;
790 case AUDIO_EXTERN_1:
791 strcpy(a->name, "Extern 1");
792 break;
793 case AUDIO_EXTERN_2:
794 strcpy(a->name, "Extern 2");
795 break;
796 case AUDIO_TUNER:
797 strcpy(a->name, "Television");
798 break;
799 default:
800 return -EINVAL;
801 }
802
803 a->capability = V4L2_AUDCAP_STEREO;
804 a->mode = 0; /* TODO: add support for AVL */
805 break; 680 break;
806 } 681 }
807 682
808 case VIDIOC_S_AUDIO: 683 case VIDIOC_INT_S_AUDIO_ROUTING:
809 { 684 {
810 struct v4l2_audio *sarg = arg; 685 struct v4l2_routing *rt = arg;
811 686 int tuner = (rt->input >> 3) & 1;
812 switch (sarg->index) { 687 int sc_in = rt->input & 0x7;
813 case AUDIO_RADIO: 688 int sc1_out = rt->output & 0xf;
814 /* Hauppauge uses IN2 for the radio */ 689 int sc2_out = (rt->output >> 4) & 0xf;
815 state->mode = MSP_MODE_FM_RADIO; 690 u16 val;
816 scart = SCART_IN2; 691
817 break; 692 state->routing = *rt;
818 case AUDIO_EXTERN_1: 693 if (state->opmode == OPMODE_AUTOSELECT) {
819 /* IN1 is often used for external input ... */ 694 val = msp_read_dem(client, 0x30) & ~0x100;
820 state->mode = MSP_MODE_EXTERN; 695 msp_write_dem(client, 0x30, val | (tuner ? 0x100 : 0));
821 scart = SCART_IN1; 696 } else {
822 break; 697 val = msp_read_dem(client, 0xbb) & ~0x100;
823 case AUDIO_EXTERN_2: 698 msp_write_dem(client, 0xbb, val | (tuner ? 0x100 : 0));
824 /* ... sometimes it is IN2 through ;) */
825 state->mode = MSP_MODE_EXTERN;
826 scart = SCART_IN2;
827 break;
828 case AUDIO_TUNER:
829 state->mode = -1;
830 break;
831 }
832 if (scart) {
833 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
834 msp_set_scart(client, scart, 0);
835 msp_write_dsp(client, 0x000d, 0x1900);
836 } 699 }
700 msp_set_scart(client, sc_in, 0);
701 msp_set_scart(client, sc1_out, 1);
702 msp_set_scart(client, sc2_out, 2);
837 msp_set_audmode(client); 703 msp_set_audmode(client);
838 msp_wake_thread(client); 704 msp_wake_thread(client);
839 break; 705 break;
@@ -866,42 +732,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
866 break; 732 break;
867 } 733 }
868 734
869 case VIDIOC_G_AUDOUT:
870 {
871 struct v4l2_audioout *a = (struct v4l2_audioout *)arg;
872 int idx = a->index;
873
874 memset(a, 0, sizeof(*a));
875
876 switch (idx) {
877 case 0:
878 strcpy(a->name, "Scart1 Out");
879 break;
880 case 1:
881 strcpy(a->name, "Scart2 Out");
882 break;
883 case 2:
884 strcpy(a->name, "I2S Out");
885 break;
886 default:
887 return -EINVAL;
888 }
889 break;
890 }
891
892 case VIDIOC_S_AUDOUT:
893 {
894 struct v4l2_audioout *a = (struct v4l2_audioout *)arg;
895
896 if (a->index < 0 || a->index > 2)
897 return -EINVAL;
898
899 v4l_dbg(1, msp_debug, client, "Setting audio out on msp34xx to input %i\n", a->index);
900 msp_set_scart(client, state->in_scart, a->index + 1);
901
902 break;
903 }
904
905 case VIDIOC_INT_I2S_CLOCK_FREQ: 735 case VIDIOC_INT_I2S_CLOCK_FREQ:
906 { 736 {
907 u32 *a = (u32 *)arg; 737 u32 *a = (u32 *)arg;
@@ -979,12 +809,16 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
979 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", 809 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
980 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); 810 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
981 } else { 811 } else {
982 v4l_info(client, "Mode: %s\n", p); 812 if (state->opmode == OPMODE_AUTODETECT)
813 v4l_info(client, "Mode: %s\n", p);
983 v4l_info(client, "Standard: %s (%s%s)\n", 814 v4l_info(client, "Standard: %s (%s%s)\n",
984 msp_standard_std_name(state->std), 815 msp_standard_std_name(state->std),
985 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", 816 (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
986 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); 817 (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
987 } 818 }
819 v4l_info(client, "Audmode: 0x%04x\n", state->audmode);
820 v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n",
821 state->routing.input, state->routing.output);
988 v4l_info(client, "ACB: 0x%04x\n", state->acb); 822 v4l_info(client, "ACB: 0x%04x\n", state->acb);
989 break; 823 break;
990 } 824 }
@@ -1063,6 +897,9 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
1063 state->muted = 0; 897 state->muted = 0;
1064 state->i2s_mode = 0; 898 state->i2s_mode = 0;
1065 init_waitqueue_head(&state->wq); 899 init_waitqueue_head(&state->wq);
900 /* These are the reset input/output positions */
901 state->routing.input = MSP_INPUT_DEFAULT;
902 state->routing.output = MSP_OUTPUT_DEFAULT;
1066 903
1067 state->rev1 = msp_read_dsp(client, 0x1e); 904 state->rev1 = msp_read_dsp(client, 0x1e);
1068 if (state->rev1 != -1) 905 if (state->rev1 != -1)
diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400-driver.h
index 6fb5c8c994e7..1940748bb633 100644
--- a/drivers/media/video/msp3400.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -1,8 +1,10 @@
1/* 1/*
2 */ 2 */
3 3
4#ifndef MSP3400_H 4#ifndef MSP3400_DRIVER_H
5#define MSP3400_H 5#define MSP3400_DRIVER_H
6
7#include <media/msp3400.h>
6 8
7/* ---------------------------------------------------------------------- */ 9/* ---------------------------------------------------------------------- */
8 10
@@ -20,15 +22,14 @@
20#define MSP_MODE_BTSC 8 22#define MSP_MODE_BTSC 8
21#define MSP_MODE_EXTERN 9 23#define MSP_MODE_EXTERN 9
22 24
23#define SCART_MASK 0 25#define SCART_IN1 0
24#define SCART_IN1 1 26#define SCART_IN2 1
25#define SCART_IN2 2 27#define SCART_IN3 2
26#define SCART_IN1_DA 3 28#define SCART_IN4 3
27#define SCART_IN2_DA 4 29#define SCART_IN1_DA 4
28#define SCART_IN3 5 30#define SCART_IN2_DA 5
29#define SCART_IN4 6 31#define SCART_MONO 6
30#define SCART_MONO 7 32#define SCART_MUTE 7
31#define SCART_MUTE 8
32 33
33#define SCART_DSP_IN 0 34#define SCART_DSP_IN 0
34#define SCART1_OUT 1 35#define SCART1_OUT 1
@@ -73,7 +74,7 @@ struct msp_state {
73 int i2s_mode; 74 int i2s_mode;
74 int main, second; /* sound carrier */ 75 int main, second; /* sound carrier */
75 int input; 76 int input;
76 int source; /* see msp34xxg_set_source */ 77 struct v4l2_routing routing;
77 78
78 /* v4l2 */ 79 /* v4l2 */
79 int audmode; 80 int audmode;
@@ -99,17 +100,16 @@ int msp_reset(struct i2c_client *client);
99void msp_set_scart(struct i2c_client *client, int in, int out); 100void msp_set_scart(struct i2c_client *client, int in, int out);
100void msp_set_mute(struct i2c_client *client); 101void msp_set_mute(struct i2c_client *client);
101void msp_set_audio(struct i2c_client *client); 102void msp_set_audio(struct i2c_client *client);
102int msp_modus(struct i2c_client *client);
103int msp_sleep(struct msp_state *state, int timeout); 103int msp_sleep(struct msp_state *state, int timeout);
104 104
105/* msp3400-kthreads.c */ 105/* msp3400-kthreads.c */
106const char *msp_standard_std_name(int std); 106const char *msp_standard_std_name(int std);
107void msp_set_audmode(struct i2c_client *client); 107void msp_set_audmode(struct i2c_client *client);
108void msp_detect_stereo(struct i2c_client *client); 108int msp_detect_stereo(struct i2c_client *client);
109int msp3400c_thread(void *data); 109int msp3400c_thread(void *data);
110int msp3410d_thread(void *data); 110int msp3410d_thread(void *data);
111int msp34xxg_thread(void *data); 111int msp34xxg_thread(void *data);
112void msp3400c_set_mode(struct i2c_client *client, int mode); 112void msp3400c_set_mode(struct i2c_client *client, int mode);
113void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2); 113void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
114 114
115#endif /* MSP3400_H */ 115#endif /* MSP3400_DRIVER_H */
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 852ab6a115fa..c3984ea9ca07 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -26,10 +26,10 @@
26#include <linux/videodev.h> 26#include <linux/videodev.h>
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <media/v4l2-common.h> 28#include <media/v4l2-common.h>
29#include <media/audiochip.h> 29#include <media/msp3400.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <linux/suspend.h> 31#include <linux/suspend.h>
32#include "msp3400.h" 32#include "msp3400-driver.h"
33 33
34/* this one uses the automatic sound standard detection of newer msp34xx 34/* this one uses the automatic sound standard detection of newer msp34xx
35 chip versions */ 35 chip versions */
@@ -45,11 +45,13 @@ static struct {
45 { 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" }, 45 { 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" },
46 { 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" }, 46 { 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" },
47 { 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" }, 47 { 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" },
48 { 0x0007, MSP_CARRIER(6.5), MSP_CARRIER(5.7421875), "6.5/5.74 D/K3 Dual FM-Stereo" },
48 { 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" }, 49 { 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" },
49 { 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" }, 50 { 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" },
50 { 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" }, 51 { 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" },
51 { 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" }, 52 { 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" },
52 { 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" }, 53 { 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" },
54 { 0x000d, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV3)" },
53 { 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" }, 55 { 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" },
54 { 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" }, 56 { 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" },
55 { 0x0030, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M EIA-J Japan Stereo" }, 57 { 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)
185{ 187{
186 struct msp_state *state = i2c_get_clientdata(client); 188 struct msp_state *state = i2c_get_clientdata(client);
187 struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode]; 189 struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode];
190 int tuner = (state->routing.input >> 3) & 1;
188 int i; 191 int i;
189 192
190 v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode); 193 v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode);
191 state->mode = mode; 194 state->mode = mode;
192 state->rxsubchans = V4L2_TUNER_SUB_MONO; 195 state->rxsubchans = V4L2_TUNER_SUB_MONO;
193 196
194 msp_write_dem(client, 0x00bb, data->ad_cv); 197 msp_write_dem(client, 0x00bb, data->ad_cv | (tuner ? 0x100 : 0));
195 198
196 for (i = 5; i >= 0; i--) /* fir 1 */ 199 for (i = 5; i >= 0; i--) /* fir 1 */
197 msp_write_dem(client, 0x0001, data->fir1[i]); 200 msp_write_dem(client, 0x0001, data->fir1[i]);
@@ -207,21 +210,22 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
207 msp3400c_set_carrier(client, data->cdo1, data->cdo2); 210 msp3400c_set_carrier(client, data->cdo1, data->cdo2);
208 211
209 msp_set_source(client, data->dsp_src); 212 msp_set_source(client, data->dsp_src);
210 msp_write_dsp(client, 0x000e, data->dsp_matrix); 213 /* set prescales */
211 214
212 if (state->has_nicam) { 215 /* volume prescale for SCART (AM mono input) */
213 /* nicam prescale */ 216 msp_write_dsp(client, 0x000d, 0x1900);
214 msp_write_dsp(client, 0x0010, 0x5a00); /* was: 0x3000 */ 217 msp_write_dsp(client, 0x000e, data->dsp_matrix);
215 } 218 if (state->has_nicam) /* nicam prescale */
219 msp_write_dsp(client, 0x0010, 0x5a00);
216} 220}
217 221
218/* Set audio mode. Note that the pre-'G' models do not support BTSC+SAP, 222/* Set audio mode. Note that the pre-'G' models do not support BTSC+SAP,
219 nor do they support stereo BTSC. */ 223 nor do they support stereo BTSC. */
220static void msp3400c_set_audmode(struct i2c_client *client) 224static void msp3400c_set_audmode(struct i2c_client *client)
221{ 225{
222 static char *strmode[] = { "mono", "stereo", "lang2", "lang1" }; 226 static char *strmode[] = { "mono", "stereo", "lang2", "lang1", "lang1+lang2" };
223 struct msp_state *state = i2c_get_clientdata(client); 227 struct msp_state *state = i2c_get_clientdata(client);
224 char *modestr = (state->audmode >= 0 && state->audmode < 4) ? 228 char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
225 strmode[state->audmode] : "unknown"; 229 strmode[state->audmode] : "unknown";
226 int src = 0; /* channel source: FM/AM, nicam or SCART */ 230 int src = 0; /* channel source: FM/AM, nicam or SCART */
227 231
@@ -246,6 +250,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
246 case V4L2_TUNER_MODE_MONO: 250 case V4L2_TUNER_MODE_MONO:
247 case V4L2_TUNER_MODE_LANG1: 251 case V4L2_TUNER_MODE_LANG1:
248 case V4L2_TUNER_MODE_LANG2: 252 case V4L2_TUNER_MODE_LANG2:
253 case V4L2_TUNER_MODE_LANG1_LANG2:
249 msp_write_dsp(client, 0x000e, 0x3000); 254 msp_write_dsp(client, 0x000e, 0x3000);
250 break; 255 break;
251 } 256 }
@@ -257,6 +262,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
257 msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); 262 msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
258 break; 263 break;
259 case V4L2_TUNER_MODE_STEREO: 264 case V4L2_TUNER_MODE_STEREO:
265 case V4L2_TUNER_MODE_LANG1_LANG2:
260 msp3400c_set_carrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02)); 266 msp3400c_set_carrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02));
261 break; 267 break;
262 case V4L2_TUNER_MODE_LANG1: 268 case V4L2_TUNER_MODE_LANG1:
@@ -271,7 +277,6 @@ static void msp3400c_set_audmode(struct i2c_client *client)
271 case MSP_MODE_FM_NICAM2: 277 case MSP_MODE_FM_NICAM2:
272 case MSP_MODE_AM_NICAM: 278 case MSP_MODE_AM_NICAM:
273 v4l_dbg(1, msp_debug, client, "NICAM set_audmode: %s\n",modestr); 279 v4l_dbg(1, msp_debug, client, "NICAM set_audmode: %s\n",modestr);
274 msp3400c_set_carrier(client, state->second, state->main);
275 if (state->nicam_on) 280 if (state->nicam_on)
276 src = 0x0100; /* NICAM */ 281 src = 0x0100; /* NICAM */
277 break; 282 break;
@@ -293,6 +298,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
293 /* switch audio */ 298 /* switch audio */
294 switch (state->audmode) { 299 switch (state->audmode) {
295 case V4L2_TUNER_MODE_STEREO: 300 case V4L2_TUNER_MODE_STEREO:
301 case V4L2_TUNER_MODE_LANG1_LANG2:
296 src |= 0x0020; 302 src |= 0x0020;
297 break; 303 break;
298 case V4L2_TUNER_MODE_MONO: 304 case V4L2_TUNER_MODE_MONO:
@@ -427,8 +433,8 @@ static void watch_stereo(struct i2c_client *client)
427{ 433{
428 struct msp_state *state = i2c_get_clientdata(client); 434 struct msp_state *state = i2c_get_clientdata(client);
429 435
430 if (msp3400c_detect_stereo(client)) { 436 if (msp_detect_stereo(client)) {
431 msp3400c_set_audmode(client); 437 msp_set_audmode(client);
432 } 438 }
433 439
434 if (msp_once) 440 if (msp_once)
@@ -464,7 +470,7 @@ int msp3400c_thread(void *data)
464 470
465 /* mute */ 471 /* mute */
466 msp_set_mute(client); 472 msp_set_mute(client);
467 msp3400c_set_mode(client, MSP_MODE_AM_DETECT /* +1 */ ); 473 msp3400c_set_mode(client, MSP_MODE_AM_DETECT);
468 val1 = val2 = 0; 474 val1 = val2 = 0;
469 max1 = max2 = -1; 475 max1 = max2 = -1;
470 state->watch_stereo = 0; 476 state->watch_stereo = 0;
@@ -572,8 +578,6 @@ int msp3400c_thread(void *data)
572 state->second = msp3400c_carrier_detect_65[max2].cdo; 578 state->second = msp3400c_carrier_detect_65[max2].cdo;
573 msp3400c_set_mode(client, MSP_MODE_AM_NICAM); 579 msp3400c_set_mode(client, MSP_MODE_AM_NICAM);
574 msp3400c_set_carrier(client, state->second, state->main); 580 msp3400c_set_carrier(client, state->second, state->main);
575 /* volume prescale for SCART (AM mono input) */
576 msp_write_dsp(client, 0x000d, 0x1900);
577 state->watch_stereo = 1; 581 state->watch_stereo = 1;
578 } else if (max2 == 0 && state->has_nicam) { 582 } else if (max2 == 0 && state->has_nicam) {
579 /* D/K NICAM */ 583 /* D/K NICAM */
@@ -651,7 +655,8 @@ int msp3410d_thread(void *data)
651 if (msp_sleep(state,200)) 655 if (msp_sleep(state,200))
652 goto restart; 656 goto restart;
653 657
654 /* start autodetect */ 658 /* start autodetect. Note: autodetect is not supported for
659 NTSC-M and radio, hence we force the standard in those cases. */
655 if (state->radio) 660 if (state->radio)
656 std = 0x40; 661 std = 0x40;
657 else 662 else
@@ -695,23 +700,19 @@ int msp3410d_thread(void *data)
695 v4l_dbg(1, msp_debug, client, "autodetection failed," 700 v4l_dbg(1, msp_debug, client, "autodetection failed,"
696 " switching to backup standard: %s (0x%04x)\n", 701 " switching to backup standard: %s (0x%04x)\n",
697 msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val); 702 msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val);
698 val = 0x0009; 703 state->std = val = 0x0009;
699 msp_write_dem(client, 0x20, val); 704 msp_write_dem(client, 0x20, val);
700 } 705 }
701 706
702 /* set various prescales */
703 msp_write_dsp(client, 0x0d, 0x1900); /* scart */
704 msp_write_dsp(client, 0x0e, 0x2403); /* FM */
705 msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
706
707 /* set stereo */ 707 /* set stereo */
708 switch (val) { 708 switch (val) {
709 case 0x0008: /* B/G NICAM */ 709 case 0x0008: /* B/G NICAM */
710 case 0x000a: /* I NICAM */ 710 case 0x000a: /* I NICAM */
711 if (val == 0x0008) 711 case 0x000b: /* D/K NICAM */
712 state->mode = MSP_MODE_FM_NICAM1; 712 if (val == 0x000a)
713 else
714 state->mode = MSP_MODE_FM_NICAM2; 713 state->mode = MSP_MODE_FM_NICAM2;
714 else
715 state->mode = MSP_MODE_FM_NICAM1;
715 /* just turn on stereo */ 716 /* just turn on stereo */
716 state->rxsubchans = V4L2_TUNER_SUB_STEREO; 717 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
717 state->nicam_on = 1; 718 state->nicam_on = 1;
@@ -739,6 +740,7 @@ int msp3410d_thread(void *data)
739 /* scart routing (this doesn't belong here I think) */ 740 /* scart routing (this doesn't belong here I think) */
740 msp_set_scart(client,SCART_IN2,0); 741 msp_set_scart(client,SCART_IN2,0);
741 break; 742 break;
743 case 0x0002:
742 case 0x0003: 744 case 0x0003:
743 case 0x0004: 745 case 0x0004:
744 case 0x0005: 746 case 0x0005:
@@ -748,12 +750,19 @@ int msp3410d_thread(void *data)
748 break; 750 break;
749 } 751 }
750 752
751 /* unmute, restore misc registers */ 753 /* set various prescales */
752 msp_set_audio(client); 754 msp_write_dsp(client, 0x0d, 0x1900); /* scart */
753 msp_write_dsp(client, 0x13, state->acb); 755 msp_write_dsp(client, 0x0e, 0x3000); /* FM */
756 if (state->has_nicam)
757 msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
758
754 if (state->has_i2s_conf) 759 if (state->has_i2s_conf)
755 msp_write_dem(client, 0x40, state->i2s_mode); 760 msp_write_dem(client, 0x40, state->i2s_mode);
756 761
762 /* unmute, restore misc registers */
763 msp_set_audio(client);
764
765 msp_write_dsp(client, 0x13, state->acb);
757 msp3400c_set_audmode(client); 766 msp3400c_set_audmode(client);
758 767
759 /* monitor tv audio mode, the first time don't wait 768 /* monitor tv audio mode, the first time don't wait
@@ -772,97 +781,154 @@ int msp3410d_thread(void *data)
772 781
773/* ----------------------------------------------------------------------- */ 782/* ----------------------------------------------------------------------- */
774 783
775/* msp34xxG + (autoselect no-thread) */ 784/* msp34xxG + (autoselect no-thread)
776/* this one uses both automatic standard detection and automatic sound */ 785 * this one uses both automatic standard detection and automatic sound
777/* select which are available in the newer G versions */ 786 * select which are available in the newer G versions
778/* struct msp: only norm, acb and source are really used in this mode */ 787 * struct msp: only norm, acb and source are really used in this mode
779
780/* set the same 'source' for the loudspeaker, scart and quasi-peak detector
781 * the value for source is the same as bit 15:8 of DSP registers 0x08,
782 * 0x0a and 0x0c: 0=mono, 1=stereo or A|B, 2=SCART, 3=stereo or A, 4=stereo or B
783 *
784 * this function replaces msp3400c_set_audmode
785 */ 788 */
786static void msp34xxg_set_source(struct i2c_client *client, int source) 789
790static int msp34xxg_modus(struct i2c_client *client)
787{ 791{
788 struct msp_state *state = i2c_get_clientdata(client); 792 struct msp_state *state = i2c_get_clientdata(client);
789 793
790 /* fix matrix mode to stereo and let the msp choose what 794 if (state->radio) {
791 * to output according to 'source', as recommended 795 v4l_dbg(1, msp_debug, client, "selected radio modus\n");
792 * for MONO (source==0) downmixing set bit[7:0] to 0x30 796 return 0x0001;
793 */ 797 }
794 int value = (source & 0x07) << 8 | (source == 0 ? 0x30 : 0x20);
795 798
796 v4l_dbg(1, msp_debug, client, "set source to %d (0x%x)\n", source, value); 799 if (state->v4l2_std & V4L2_STD_PAL) {
797 msp_set_source(client, value); 800 v4l_dbg(1, msp_debug, client, "selected PAL modus\n");
798 /* 801 return 0x7001;
799 * set identification threshold. Personally, I 802 }
800 * I set it to a higher value that the default 803 if (state->v4l2_std == V4L2_STD_NTSC_M_JP) {
801 * of 0x190 to ignore noisy stereo signals. 804 v4l_dbg(1, msp_debug, client, "selected M (EIA-J) modus\n");
802 * this needs tuning. (recommended range 0x00a0-0x03c0) 805 return 0x4001;
803 * 0x7f0 = forced mono mode 806 }
804 */ 807 if (state->v4l2_std == V4L2_STD_NTSC_M_KR) {
805 /* a2 threshold for stereo/bilingual */ 808 v4l_dbg(1, msp_debug, client, "selected M (A2) modus\n");
806 msp_write_dem(client, 0x22, msp_stereo_thresh); 809 return 0x0001;
807 state->source = source; 810 }
811 if (state->v4l2_std & V4L2_STD_MN) {
812 v4l_dbg(1, msp_debug, client, "selected M (BTSC) modus\n");
813 return 0x2001;
814 }
815 if (state->v4l2_std & V4L2_STD_SECAM) {
816 v4l_dbg(1, msp_debug, client, "selected SECAM modus\n");
817 return 0x6001;
818 }
819 return 0x0001;
808} 820}
809 821
810/* (re-)initialize the msp34xxg, according to the current norm in state->norm 822static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
811 * return 0 if it worked, -1 if it failed 823 {
812 */ 824 struct msp_state *state = i2c_get_clientdata(client);
813static int msp34xxg_reset(struct i2c_client *client) 825 int source, matrix;
826
827 switch (state->audmode) {
828 case V4L2_TUNER_MODE_MONO:
829 source = 0; /* mono only */
830 matrix = 0x30;
831 break;
832 case V4L2_TUNER_MODE_LANG1:
833 source = 3; /* stereo or A */
834 matrix = 0x00;
835 break;
836 case V4L2_TUNER_MODE_LANG2:
837 source = 4; /* stereo or B */
838 matrix = 0x10;
839 break;
840 case V4L2_TUNER_MODE_STEREO:
841 case V4L2_TUNER_MODE_LANG1_LANG2:
842 default:
843 source = 1; /* stereo or A|B */
844 matrix = 0x20;
845 break;
846 }
847
848 if (in == MSP_DSP_OUT_TUNER)
849 source = (source << 8) | 0x20;
850 /* the msp34x2g puts the MAIN_AVC, MAIN and AUX sources in 12, 13, 14
851 instead of 11, 12, 13. So we add one for that msp version. */
852 else if (in >= MSP_DSP_OUT_MAIN_AVC && state->has_dolby_pro_logic)
853 source = ((in + 1) << 8) | matrix;
854 else
855 source = (in << 8) | matrix;
856
857 v4l_dbg(1, msp_debug, client, "set source to %d (0x%x) for output %02x\n",
858 in, source, reg);
859 msp_write_dsp(client, reg, source);
860}
861
862static void msp34xxg_set_sources(struct i2c_client *client)
863{
864 struct msp_state *state = i2c_get_clientdata(client);
865 u32 in = state->routing.input;
866
867 msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf);
868 /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */
869 msp34xxg_set_source(client, 0x000c, (in >> 4) & 0xf);
870 msp34xxg_set_source(client, 0x0009, (in >> 8) & 0xf);
871 msp34xxg_set_source(client, 0x000a, (in >> 12) & 0xf);
872 if (state->has_scart23_in_scart2_out)
873 msp34xxg_set_source(client, 0x0041, (in >> 16) & 0xf);
874 msp34xxg_set_source(client, 0x000b, (in >> 20) & 0xf);
875}
876
877/* (re-)initialize the msp34xxg */
878static void msp34xxg_reset(struct i2c_client *client)
814{ 879{
815 struct msp_state *state = i2c_get_clientdata(client); 880 struct msp_state *state = i2c_get_clientdata(client);
816 int modus, std; 881 int tuner = (state->routing.input >> 3) & 1;
882 int modus;
883
884 /* initialize std to 1 (autodetect) to signal that no standard is
885 selected yet. */
886 state->std = 1;
817 887
818 if (msp_reset(client)) 888 msp_reset(client);
819 return -1;
820 889
821 /* make sure that input/output is muted (paranoid mode) */ 890 /* make sure that input/output is muted (paranoid mode) */
822 /* ACB, mute DSP input, mute SCART 1 */ 891 /* ACB, mute DSP input, mute SCART 1 */
823 if (msp_write_dsp(client, 0x13, 0x0f20)) 892 msp_write_dsp(client, 0x13, 0x0f20);
824 return -1;
825 893
826 if (state->has_i2s_conf) 894 if (state->has_i2s_conf)
827 msp_write_dem(client, 0x40, state->i2s_mode); 895 msp_write_dem(client, 0x40, state->i2s_mode);
828 896
829 /* step-by-step initialisation, as described in the manual */ 897 /* step-by-step initialisation, as described in the manual */
830 modus = msp_modus(client); 898 modus = msp34xxg_modus(client);
831 if (state->radio) 899 modus |= tuner ? 0x100 : 0;
832 std = 0x40; 900 msp_write_dem(client, 0x30, modus);
833 else
834 std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1;
835 modus &= ~0x03; /* STATUS_CHANGE = 0 */
836 modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION = 1 */
837 if (msp_write_dem(client, 0x30, modus))
838 return -1;
839 if (msp_write_dem(client, 0x20, std))
840 return -1;
841 901
842 /* write the dsps that may have an influence on 902 /* write the dsps that may have an influence on
843 standard/audio autodetection right now */ 903 standard/audio autodetection right now */
844 msp34xxg_set_source(client, state->source); 904 msp34xxg_set_sources(client);
845
846 /* AM/FM Prescale [15:8] 75khz deviation */
847 if (msp_write_dsp(client, 0x0e, 0x3000))
848 return -1;
849 905
850 /* NICAM Prescale 9db gain (as recommended) */ 906 msp_write_dsp(client, 0x0d, 0x1900); /* scart */
851 if (msp_write_dsp(client, 0x10, 0x5a00)) 907 msp_write_dsp(client, 0x0e, 0x3000); /* FM */
852 return -1; 908 if (state->has_nicam)
909 msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
853 910
854 return 0; 911 /* set identification threshold. Personally, I
912 * I set it to a higher value than the default
913 * of 0x190 to ignore noisy stereo signals.
914 * this needs tuning. (recommended range 0x00a0-0x03c0)
915 * 0x7f0 = forced mono mode
916 *
917 * a2 threshold for stereo/bilingual.
918 * Note: this register is part of the Manual/Compatibility mode.
919 * It is supported by all 'G'-family chips.
920 */
921 msp_write_dem(client, 0x22, msp_stereo_thresh);
855} 922}
856 923
857int msp34xxg_thread(void *data) 924int msp34xxg_thread(void *data)
858{ 925{
859 struct i2c_client *client = data; 926 struct i2c_client *client = data;
860 struct msp_state *state = i2c_get_clientdata(client); 927 struct msp_state *state = i2c_get_clientdata(client);
861 int val, std, i; 928 int val, i;
862 929
863 v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n"); 930 v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
864 931
865 state->source = 1; /* default */
866 for (;;) { 932 for (;;) {
867 v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n"); 933 v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n");
868 msp_sleep(state, -1); 934 msp_sleep(state, -1);
@@ -876,12 +942,14 @@ int msp34xxg_thread(void *data)
876 942
877 /* setup the chip*/ 943 /* setup the chip*/
878 msp34xxg_reset(client); 944 msp34xxg_reset(client);
879 std = msp_standard; 945 state->std = state->radio ? 0x40 : msp_standard;
880 if (std != 0x01) 946 if (state->std != 1)
881 goto unmute; 947 goto unmute;
948 /* start autodetect */
949 msp_write_dem(client, 0x20, state->std);
882 950
883 /* watch autodetect */ 951 /* watch autodetect */
884 v4l_dbg(1, msp_debug, client, "triggered autodetect, waiting for result\n"); 952 v4l_dbg(1, msp_debug, client, "started autodetect, waiting for result\n");
885 for (i = 0; i < 10; i++) { 953 for (i = 0; i < 10; i++) {
886 if (msp_sleep(state, 100)) 954 if (msp_sleep(state, 100))
887 goto restart; 955 goto restart;
@@ -889,20 +957,19 @@ int msp34xxg_thread(void *data)
889 /* check results */ 957 /* check results */
890 val = msp_read_dem(client, 0x7e); 958 val = msp_read_dem(client, 0x7e);
891 if (val < 0x07ff) { 959 if (val < 0x07ff) {
892 std = val; 960 state->std = val;
893 break; 961 break;
894 } 962 }
895 v4l_dbg(2, msp_debug, client, "detection still in progress\n"); 963 v4l_dbg(2, msp_debug, client, "detection still in progress\n");
896 } 964 }
897 if (std == 1) { 965 if (state->std == 1) {
898 v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n"); 966 v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n");
899 continue; 967 continue;
900 } 968 }
901 969
902 unmute: 970 unmute:
903 state->std = std; 971 v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n",
904 v4l_dbg(1, msp_debug, client, "current standard: %s (0x%04x)\n", 972 msp_standard_std_name(state->std), state->std);
905 msp_standard_std_name(std), std);
906 973
907 /* unmute: dispatch sound to scart output, set scart volume */ 974 /* unmute: dispatch sound to scart output, set scart volume */
908 msp_set_audio(client); 975 msp_set_audio(client);
@@ -911,20 +978,33 @@ int msp34xxg_thread(void *data)
911 if (msp_write_dsp(client, 0x13, state->acb)) 978 if (msp_write_dsp(client, 0x13, state->acb))
912 return -1; 979 return -1;
913 980
914 if (state->has_i2s_conf) 981 /* the periodic stereo/SAP check is only relevant for
915 msp_write_dem(client, 0x40, state->i2s_mode); 982 the 0x20 standard (BTSC) */
983 if (state->std != 0x20)
984 continue;
985
986 state->watch_stereo = 1;
987
988 /* monitor tv audio mode, the first time don't wait
989 in order to get a quick stereo/SAP update */
990 watch_stereo(client);
991 while (state->watch_stereo) {
992 watch_stereo(client);
993 if (msp_sleep(state, 5000))
994 goto restart;
995 }
916 } 996 }
917 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 997 v4l_dbg(1, msp_debug, client, "thread: exit\n");
918 return 0; 998 return 0;
919} 999}
920 1000
921static void msp34xxg_detect_stereo(struct i2c_client *client) 1001static int msp34xxg_detect_stereo(struct i2c_client *client)
922{ 1002{
923 struct msp_state *state = i2c_get_clientdata(client); 1003 struct msp_state *state = i2c_get_clientdata(client);
924
925 int status = msp_read_dem(client, 0x0200); 1004 int status = msp_read_dem(client, 0x0200);
926 int is_bilingual = status & 0x100; 1005 int is_bilingual = status & 0x100;
927 int is_stereo = status & 0x40; 1006 int is_stereo = status & 0x40;
1007 int oldrx = state->rxsubchans;
928 1008
929 state->rxsubchans = 0; 1009 state->rxsubchans = 0;
930 if (is_stereo) 1010 if (is_stereo)
@@ -932,42 +1012,31 @@ static void msp34xxg_detect_stereo(struct i2c_client *client)
932 else 1012 else
933 state->rxsubchans = V4L2_TUNER_SUB_MONO; 1013 state->rxsubchans = V4L2_TUNER_SUB_MONO;
934 if (is_bilingual) { 1014 if (is_bilingual) {
935 state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 1015 if (state->std == 0x20)
936 /* I'm supposed to check whether it's SAP or not 1016 state->rxsubchans |= V4L2_TUNER_SUB_SAP;
937 * and set only LANG2/SAP in this case. Yet, the MSP 1017 else
938 * does a lot of work to hide this and handle everything 1018 state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
939 * the same way. I don't want to work around it so unless
940 * this is a problem, I'll handle SAP just like lang1/lang2.
941 */
942 } 1019 }
943 v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", 1020 v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
944 status, is_stereo, is_bilingual, state->rxsubchans); 1021 status, is_stereo, is_bilingual, state->rxsubchans);
1022 return (oldrx != state->rxsubchans);
945} 1023}
946 1024
947static void msp34xxg_set_audmode(struct i2c_client *client) 1025static void msp34xxg_set_audmode(struct i2c_client *client)
948{ 1026{
949 struct msp_state *state = i2c_get_clientdata(client); 1027 struct msp_state *state = i2c_get_clientdata(client);
950 int source;
951 1028
952 switch (state->audmode) { 1029 if (state->std == 0x20) {
953 case V4L2_TUNER_MODE_MONO: 1030 if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) &&
954 source = 0; /* mono only */ 1031 (state->audmode == V4L2_TUNER_MODE_STEREO ||
955 break; 1032 state->audmode == V4L2_TUNER_MODE_LANG2)) {
956 case V4L2_TUNER_MODE_STEREO: 1033 msp_write_dem(client, 0x20, 0x21);
957 source = 1; /* stereo or A|B, see comment in msp34xxg_get_v4l2_stereo() */ 1034 } else {
958 /* problem: that could also mean 2 (scart input) */ 1035 msp_write_dem(client, 0x20, 0x20);
959 break; 1036 }
960 case V4L2_TUNER_MODE_LANG1:
961 source = 3; /* stereo or A */
962 break;
963 case V4L2_TUNER_MODE_LANG2:
964 source = 4; /* stereo or B */
965 break;
966 default:
967 source = 1;
968 break;
969 } 1037 }
970 msp34xxg_set_source(client, source); 1038
1039 msp34xxg_set_sources(client);
971} 1040}
972 1041
973void msp_set_audmode(struct i2c_client *client) 1042void msp_set_audmode(struct i2c_client *client)
@@ -977,7 +1046,6 @@ void msp_set_audmode(struct i2c_client *client)
977 switch (state->opmode) { 1046 switch (state->opmode) {
978 case OPMODE_MANUAL: 1047 case OPMODE_MANUAL:
979 case OPMODE_AUTODETECT: 1048 case OPMODE_AUTODETECT:
980 state->watch_stereo = 0;
981 msp3400c_set_audmode(client); 1049 msp3400c_set_audmode(client);
982 break; 1050 break;
983 case OPMODE_AUTOSELECT: 1051 case OPMODE_AUTOSELECT:
@@ -986,18 +1054,17 @@ void msp_set_audmode(struct i2c_client *client)
986 } 1054 }
987} 1055}
988 1056
989void msp_detect_stereo(struct i2c_client *client) 1057int msp_detect_stereo(struct i2c_client *client)
990{ 1058{
991 struct msp_state *state = i2c_get_clientdata(client); 1059 struct msp_state *state = i2c_get_clientdata(client);
992 1060
993 switch (state->opmode) { 1061 switch (state->opmode) {
994 case OPMODE_MANUAL: 1062 case OPMODE_MANUAL:
995 case OPMODE_AUTODETECT: 1063 case OPMODE_AUTODETECT:
996 msp3400c_detect_stereo(client); 1064 return msp3400c_detect_stereo(client);
997 break;
998 case OPMODE_AUTOSELECT: 1065 case OPMODE_AUTOSELECT:
999 msp34xxg_detect_stereo(client); 1066 return msp34xxg_detect_stereo(client);
1000 break;
1001 } 1067 }
1068 return 0;
1002} 1069}
1003 1070
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index eb3b31867494..b0aea4002d11 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)
198 /* loop through all i2c-devices on the bus and look who is there */ 198 /* loop through all i2c-devices on the bus and look who is there */
199 list_for_each(item,&mxb->i2c_adapter.clients) { 199 list_for_each(item,&mxb->i2c_adapter.clients) {
200 client = list_entry(item, struct i2c_client, list); 200 client = list_entry(item, struct i2c_client, list);
201 if( I2C_TEA6420_1 == client->addr ) 201 if( I2C_ADDR_TEA6420_1 == client->addr )
202 mxb->tea6420_1 = client; 202 mxb->tea6420_1 = client;
203 if( I2C_TEA6420_2 == client->addr ) 203 if( I2C_ADDR_TEA6420_2 == client->addr )
204 mxb->tea6420_2 = client; 204 mxb->tea6420_2 = client;
205 if( I2C_TEA6415C_2 == client->addr ) 205 if( I2C_TEA6415C_2 == client->addr )
206 mxb->tea6415c = client; 206 mxb->tea6415c = client;
207 if( I2C_TDA9840 == client->addr ) 207 if( I2C_ADDR_TDA9840 == client->addr )
208 mxb->tda9840 = client; 208 mxb->tda9840 = client;
209 if( I2C_SAA7111 == client->addr ) 209 if( I2C_SAA7111 == client->addr )
210 mxb->saa7111a = client; 210 mxb->saa7111a = client;
@@ -790,6 +790,12 @@ static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
790 DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n")); 790 DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n"));
791 break; 791 break;
792 } 792 }
793 case V4L2_TUNER_MODE_LANG1_LANG2: {
794 mxb->cur_mode = V4L2_TUNER_MODE_LANG1_LANG2;
795 byte = TDA9840_SET_BOTH;
796 DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1_LANG2\n"));
797 break;
798 }
793 case V4L2_TUNER_MODE_LANG1: { 799 case V4L2_TUNER_MODE_LANG1: {
794 mxb->cur_mode = V4L2_TUNER_MODE_LANG1; 800 mxb->cur_mode = V4L2_TUNER_MODE_LANG1;
795 byte = TDA9840_SET_LANG1; 801 byte = TDA9840_SET_LANG1;
diff --git a/drivers/usb/media/ov511.c b/drivers/media/video/ov511.c
index da44579d6f29..fdc8e3f13937 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -15,7 +15,7 @@
15 * 15 *
16 * Based on the Linux CPiA driver written by Peter Pregler, 16 * Based on the Linux CPiA driver written by Peter Pregler,
17 * Scott J. Bertin and Johannes Erdfelt. 17 * Scott J. Bertin and Johannes Erdfelt.
18 * 18 *
19 * Please see the file: Documentation/usb/ov511.txt 19 * Please see the file: Documentation/usb/ov511.txt
20 * and the website at: http://alpha.dyndns.org/ov511 20 * and the website at: http://alpha.dyndns.org/ov511
21 * for more info. 21 * for more info.
@@ -433,7 +433,7 @@ reg_w_mask(struct usb_ov511 *ov,
433 return (reg_w(ov, reg, newval)); 433 return (reg_w(ov, reg, newval));
434} 434}
435 435
436/* 436/*
437 * Writes multiple (n) byte value to a single register. Only valid with certain 437 * Writes multiple (n) byte value to a single register. Only valid with certain
438 * registers (0x30 and 0xc4 - 0xce). 438 * registers (0x30 and 0xc4 - 0xce).
439 */ 439 */
@@ -629,7 +629,7 @@ ov511_i2c_write_internal(struct usb_ov511 *ov,
629 /* Retry until idle */ 629 /* Retry until idle */
630 do 630 do
631 rc = reg_r(ov, R511_I2C_CTL); 631 rc = reg_r(ov, R511_I2C_CTL);
632 while (rc > 0 && ((rc&1) == 0)); 632 while (rc > 0 && ((rc&1) == 0));
633 if (rc < 0) 633 if (rc < 0)
634 break; 634 break;
635 635
@@ -1752,7 +1752,7 @@ sensor_set_picture(struct usb_ov511 *ov, struct video_picture *p)
1752 ov->whiteness = p->whiteness; 1752 ov->whiteness = p->whiteness;
1753 1753
1754 /* Don't return error if a setting is unsupported, or rest of settings 1754 /* Don't return error if a setting is unsupported, or rest of settings
1755 * will not be performed */ 1755 * will not be performed */
1756 1756
1757 rc = sensor_set_contrast(ov, p->contrast); 1757 rc = sensor_set_contrast(ov, p->contrast);
1758 if (FATAL_ERROR(rc)) 1758 if (FATAL_ERROR(rc))
@@ -1781,7 +1781,7 @@ sensor_get_picture(struct usb_ov511 *ov, struct video_picture *p)
1781 PDEBUG(4, "sensor_get_picture"); 1781 PDEBUG(4, "sensor_get_picture");
1782 1782
1783 /* Don't return error if a setting is unsupported, or rest of settings 1783 /* Don't return error if a setting is unsupported, or rest of settings
1784 * will not be performed */ 1784 * will not be performed */
1785 1785
1786 rc = sensor_get_contrast(ov, &(p->contrast)); 1786 rc = sensor_get_contrast(ov, &(p->contrast));
1787 if (FATAL_ERROR(rc)) 1787 if (FATAL_ERROR(rc))
@@ -2251,7 +2251,7 @@ mode_init_ov_sensor_regs(struct usb_ov511 *ov, int width, int height,
2251 2251
2252 /******** Clock programming ********/ 2252 /******** Clock programming ********/
2253 2253
2254 /* The OV6620 needs special handling. This prevents the 2254 /* The OV6620 needs special handling. This prevents the
2255 * severe banding that normally occurs */ 2255 * severe banding that normally occurs */
2256 if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630) 2256 if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630)
2257 { 2257 {
@@ -2326,7 +2326,7 @@ set_ov_sensor_window(struct usb_ov511 *ov, int width, int height, int mode,
2326 int sub_flag) 2326 int sub_flag)
2327{ 2327{
2328 int ret; 2328 int ret;
2329 int hwsbase, hwebase, vwsbase, vwebase, hwsize, vwsize; 2329 int hwsbase, hwebase, vwsbase, vwebase, hwsize, vwsize;
2330 int hoffset, voffset, hwscale = 0, vwscale = 0; 2330 int hoffset, voffset, hwscale = 0, vwscale = 0;
2331 2331
2332 /* The different sensor ICs handle setting up of window differently. 2332 /* The different sensor ICs handle setting up of window differently.
@@ -2575,7 +2575,7 @@ ov518_mode_init_regs(struct usb_ov511 *ov,
2575 /* OV518 needs U and V swapped */ 2575 /* OV518 needs U and V swapped */
2576 i2c_w_mask(ov, 0x15, 0x00, 0x01); 2576 i2c_w_mask(ov, 0x15, 0x00, 0x01);
2577 2577
2578 if (mode == VIDEO_PALETTE_GREY) { 2578 if (mode == VIDEO_PALETTE_GREY) {
2579 /* Set 16-bit input format (UV data are ignored) */ 2579 /* Set 16-bit input format (UV data are ignored) */
2580 reg_w_mask(ov, 0x20, 0x00, 0x08); 2580 reg_w_mask(ov, 0x20, 0x00, 0x08);
2581 2581
@@ -2894,7 +2894,7 @@ make_8x8(unsigned char *pIn, unsigned char *pOut, int w)
2894 * ... ... ... 2894 * ... ... ...
2895 * 56 57 ... 63 120 121 ... 127 248 249 ... 255 2895 * 56 57 ... 63 120 121 ... 127 248 249 ... 255
2896 * 2896 *
2897 */ 2897 */
2898static void 2898static void
2899yuv400raw_to_yuv400p(struct ov511_frame *frame, 2899yuv400raw_to_yuv400p(struct ov511_frame *frame,
2900 unsigned char *pIn0, unsigned char *pOut0) 2900 unsigned char *pIn0, unsigned char *pOut0)
@@ -2923,7 +2923,7 @@ yuv400raw_to_yuv400p(struct ov511_frame *frame,
2923 * 2923 *
2924 * 0 1 ... 7 2924 * 0 1 ... 7
2925 * 8 9 ... 15 2925 * 8 9 ... 15
2926 * ... 2926 * ...
2927 * 56 57 ... 63 2927 * 56 57 ... 63
2928 * 2928 *
2929 * U and V are shipped at half resolution (1 U,V sample -> one 2x2 block). 2929 * 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,
3034 */ 3034 */
3035static void 3035static void
3036deinterlace(struct ov511_frame *frame, int rawformat, 3036deinterlace(struct ov511_frame *frame, int rawformat,
3037 unsigned char *pIn0, unsigned char *pOut0) 3037 unsigned char *pIn0, unsigned char *pOut0)
3038{ 3038{
3039 const int fieldheight = frame->rawheight / 2; 3039 const int fieldheight = frame->rawheight / 2;
3040 const int fieldpix = fieldheight * frame->rawwidth; 3040 const int fieldpix = fieldheight * frame->rawwidth;
@@ -3112,7 +3112,7 @@ ov51x_postprocess_grey(struct usb_ov511 *ov, struct ov511_frame *frame)
3112 frame->tempdata); 3112 frame->tempdata);
3113 3113
3114 deinterlace(frame, RAWFMT_YUV400, frame->tempdata, 3114 deinterlace(frame, RAWFMT_YUV400, frame->tempdata,
3115 frame->data); 3115 frame->data);
3116 } else { 3116 } else {
3117 if (frame->compressed) 3117 if (frame->compressed)
3118 decompress(ov, frame, frame->rawdata, 3118 decompress(ov, frame, frame->rawdata,
@@ -3136,7 +3136,7 @@ ov51x_postprocess_yuv420(struct usb_ov511 *ov, struct ov511_frame *frame)
3136 frame->tempdata); 3136 frame->tempdata);
3137 3137
3138 deinterlace(frame, RAWFMT_YUV420, frame->tempdata, 3138 deinterlace(frame, RAWFMT_YUV420, frame->tempdata,
3139 frame->data); 3139 frame->data);
3140 } else { 3140 } else {
3141 if (frame->compressed) 3141 if (frame->compressed)
3142 decompress(ov, frame, frame->rawdata, frame->data); 3142 decompress(ov, frame, frame->rawdata, frame->data);
@@ -3226,7 +3226,7 @@ ov511_move_data(struct usb_ov511 *ov, unsigned char *in, int n)
3226 frame->rawwidth = ((int)(in[9]) + 1) * 8; 3226 frame->rawwidth = ((int)(in[9]) + 1) * 8;
3227 frame->rawheight = ((int)(in[10]) + 1) * 8; 3227 frame->rawheight = ((int)(in[10]) + 1) * 8;
3228 3228
3229 PDEBUG(4, "Frame end, frame=%d, pnum=%d, w=%d, h=%d, recvd=%d", 3229 PDEBUG(4, "Frame end, frame=%d, pnum=%d, w=%d, h=%d, recvd=%d",
3230 ov->curframe, pnum, frame->rawwidth, frame->rawheight, 3230 ov->curframe, pnum, frame->rawwidth, frame->rawheight,
3231 frame->bytes_recvd); 3231 frame->bytes_recvd);
3232 3232
@@ -3527,10 +3527,10 @@ ov51x_isoc_irq(struct urb *urb, struct pt_regs *regs)
3527 return; 3527 return;
3528 } 3528 }
3529 3529
3530 if (urb->status == -ENOENT || urb->status == -ECONNRESET) { 3530 if (urb->status == -ENOENT || urb->status == -ECONNRESET) {
3531 PDEBUG(4, "URB unlinked"); 3531 PDEBUG(4, "URB unlinked");
3532 return; 3532 return;
3533 } 3533 }
3534 3534
3535 if (urb->status != -EINPROGRESS && urb->status != 0) { 3535 if (urb->status != -EINPROGRESS && urb->status != 0) {
3536 err("ERROR: urb->status=%d: %s", urb->status, 3536 err("ERROR: urb->status=%d: %s", urb->status,
@@ -4627,8 +4627,8 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
4627 PDEBUG(4, "mmap: %ld (%lX) bytes", size, size); 4627 PDEBUG(4, "mmap: %ld (%lX) bytes", size, size);
4628 4628
4629 if (size > (((OV511_NUMFRAMES 4629 if (size > (((OV511_NUMFRAMES
4630 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight) 4630 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight)
4631 + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))) 4631 + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))))
4632 return -EINVAL; 4632 return -EINVAL;
4633 4633
4634 if (mutex_lock_interruptible(&ov->lock)) 4634 if (mutex_lock_interruptible(&ov->lock))
@@ -5062,7 +5062,7 @@ ov6xx0_configure(struct usb_ov511 *ov)
5062} 5062}
5063 5063
5064/* This initializes the KS0127 and KS0127B video decoders. */ 5064/* This initializes the KS0127 and KS0127B video decoders. */
5065static int 5065static int
5066ks0127_configure(struct usb_ov511 *ov) 5066ks0127_configure(struct usb_ov511 *ov)
5067{ 5067{
5068 int rc; 5068 int rc;
@@ -5193,7 +5193,7 @@ saa7111a_configure(struct usb_ov511 *ov)
5193 return -1; 5193 return -1;
5194 5194
5195 /* Detect version of decoder. This must be done after writing the 5195 /* Detect version of decoder. This must be done after writing the
5196 * initial regs or the decoder will lock up. */ 5196 * initial regs or the decoder will lock up. */
5197 rc = i2c_r(ov, 0x00); 5197 rc = i2c_r(ov, 0x00);
5198 5198
5199 if (rc < 0) { 5199 if (rc < 0) {
@@ -5216,13 +5216,13 @@ saa7111a_configure(struct usb_ov511 *ov)
5216} 5216}
5217 5217
5218/* This initializes the OV511/OV511+ and the sensor */ 5218/* This initializes the OV511/OV511+ and the sensor */
5219static int 5219static int
5220ov511_configure(struct usb_ov511 *ov) 5220ov511_configure(struct usb_ov511 *ov)
5221{ 5221{
5222 static struct ov511_regvals aRegvalsInit511[] = { 5222 static struct ov511_regvals aRegvalsInit511[] = {
5223 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f }, 5223 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
5224 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 }, 5224 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
5225 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f }, 5225 { OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
5226 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 }, 5226 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
5227 { OV511_REG_BUS, R51x_SYS_RESET, 0x3f }, 5227 { OV511_REG_BUS, R51x_SYS_RESET, 0x3f },
5228 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 }, 5228 { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
@@ -5269,7 +5269,7 @@ ov511_configure(struct usb_ov511 *ov)
5269 err("Please notify " EMAIL " of the name,"); 5269 err("Please notify " EMAIL " of the name,");
5270 err("manufacturer, model, and this number of your camera."); 5270 err("manufacturer, model, and this number of your camera.");
5271 err("Also include the output of the detection process."); 5271 err("Also include the output of the detection process.");
5272 } 5272 }
5273 5273
5274 if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */ 5274 if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */
5275 ov->pal = 1; 5275 ov->pal = 1;
@@ -5336,17 +5336,17 @@ ov511_configure(struct usb_ov511 *ov)
5336 5336
5337 if (i2c_w(ov, 0x10, 0x00) < 0) { 5337 if (i2c_w(ov, 0x10, 0x00) < 0) {
5338 err("Can't determine sensor slave IDs"); 5338 err("Can't determine sensor slave IDs");
5339 goto error; 5339 goto error;
5340 } else { 5340 } else {
5341 if (ks0127_configure(ov) < 0) { 5341 if (ks0127_configure(ov) < 0) {
5342 err("Failed to configure KS0127"); 5342 err("Failed to configure KS0127");
5343 goto error; 5343 goto error;
5344 } 5344 }
5345 } 5345 }
5346 } else { 5346 } else {
5347 if (saa7111a_configure(ov) < 0) { 5347 if (saa7111a_configure(ov) < 0) {
5348 err("Failed to configure SAA7111A"); 5348 err("Failed to configure SAA7111A");
5349 goto error; 5349 goto error;
5350 } 5350 }
5351 } 5351 }
5352 } else { 5352 } else {
@@ -5356,13 +5356,13 @@ ov511_configure(struct usb_ov511 *ov)
5356 } else { 5356 } else {
5357 if (ov6xx0_configure(ov) < 0) { 5357 if (ov6xx0_configure(ov) < 0) {
5358 err("Failed to configure OV6xx0"); 5358 err("Failed to configure OV6xx0");
5359 goto error; 5359 goto error;
5360 } 5360 }
5361 } 5361 }
5362 } else { 5362 } else {
5363 if (ov7xx0_configure(ov) < 0) { 5363 if (ov7xx0_configure(ov) < 0) {
5364 err("Failed to configure OV7xx0"); 5364 err("Failed to configure OV7xx0");
5365 goto error; 5365 goto error;
5366 } 5366 }
5367 } 5367 }
5368 5368
@@ -5381,12 +5381,12 @@ ov518_configure(struct usb_ov511 *ov)
5381 /* For 518 and 518+ */ 5381 /* For 518 and 518+ */
5382 static struct ov511_regvals aRegvalsInit518[] = { 5382 static struct ov511_regvals aRegvalsInit518[] = {
5383 { OV511_REG_BUS, R51x_SYS_RESET, 0x40 }, 5383 { OV511_REG_BUS, R51x_SYS_RESET, 0x40 },
5384 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 }, 5384 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
5385 { OV511_REG_BUS, R51x_SYS_RESET, 0x3e }, 5385 { OV511_REG_BUS, R51x_SYS_RESET, 0x3e },
5386 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 }, 5386 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
5387 { OV511_REG_BUS, R51x_SYS_RESET, 0x00 }, 5387 { OV511_REG_BUS, R51x_SYS_RESET, 0x00 },
5388 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 }, 5388 { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
5389 { OV511_REG_BUS, 0x46, 0x00 }, 5389 { OV511_REG_BUS, 0x46, 0x00 },
5390 { OV511_REG_BUS, 0x5d, 0x03 }, 5390 { OV511_REG_BUS, 0x5d, 0x03 },
5391 { OV511_DONE_BUS, 0x0, 0x00}, 5391 { OV511_DONE_BUS, 0x0, 0x00},
5392 }; 5392 };
@@ -5517,7 +5517,7 @@ ov518_configure(struct usb_ov511 *ov)
5517 5517
5518 if (init_ov_sensor(ov) < 0) { 5518 if (init_ov_sensor(ov) < 0) {
5519 err("Can't determine sensor slave IDs"); 5519 err("Can't determine sensor slave IDs");
5520 goto error; 5520 goto error;
5521 } else { 5521 } else {
5522 err("Detected unsupported OV8xx0 sensor"); 5522 err("Detected unsupported OV8xx0 sensor");
5523 goto error; 5523 goto error;
@@ -5525,13 +5525,13 @@ ov518_configure(struct usb_ov511 *ov)
5525 } else { 5525 } else {
5526 if (ov6xx0_configure(ov) < 0) { 5526 if (ov6xx0_configure(ov) < 0) {
5527 err("Failed to configure OV6xx0"); 5527 err("Failed to configure OV6xx0");
5528 goto error; 5528 goto error;
5529 } 5529 }
5530 } 5530 }
5531 } else { 5531 } else {
5532 if (ov7xx0_configure(ov) < 0) { 5532 if (ov7xx0_configure(ov) < 0) {
5533 err("Failed to configure OV7xx0"); 5533 err("Failed to configure OV7xx0");
5534 goto error; 5534 goto error;
5535 } 5535 }
5536 } 5536 }
5537 5537
@@ -5564,28 +5564,28 @@ static ssize_t show_custom_id(struct class_device *cd, char *buf)
5564{ 5564{
5565 struct usb_ov511 *ov = cd_to_ov(cd); 5565 struct usb_ov511 *ov = cd_to_ov(cd);
5566 return sprintf(buf, "%d\n", ov->customid); 5566 return sprintf(buf, "%d\n", ov->customid);
5567} 5567}
5568static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL); 5568static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL);
5569 5569
5570static ssize_t show_model(struct class_device *cd, char *buf) 5570static ssize_t show_model(struct class_device *cd, char *buf)
5571{ 5571{
5572 struct usb_ov511 *ov = cd_to_ov(cd); 5572 struct usb_ov511 *ov = cd_to_ov(cd);
5573 return sprintf(buf, "%s\n", ov->desc); 5573 return sprintf(buf, "%s\n", ov->desc);
5574} 5574}
5575static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); 5575static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
5576 5576
5577static ssize_t show_bridge(struct class_device *cd, char *buf) 5577static ssize_t show_bridge(struct class_device *cd, char *buf)
5578{ 5578{
5579 struct usb_ov511 *ov = cd_to_ov(cd); 5579 struct usb_ov511 *ov = cd_to_ov(cd);
5580 return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge)); 5580 return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge));
5581} 5581}
5582static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL); 5582static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL);
5583 5583
5584static ssize_t show_sensor(struct class_device *cd, char *buf) 5584static ssize_t show_sensor(struct class_device *cd, char *buf)
5585{ 5585{
5586 struct usb_ov511 *ov = cd_to_ov(cd); 5586 struct usb_ov511 *ov = cd_to_ov(cd);
5587 return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor)); 5587 return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor));
5588} 5588}
5589static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL); 5589static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL);
5590 5590
5591static ssize_t show_brightness(struct class_device *cd, char *buf) 5591static 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)
5597 return -ENODEV; 5597 return -ENODEV;
5598 sensor_get_brightness(ov, &x); 5598 sensor_get_brightness(ov, &x);
5599 return sprintf(buf, "%d\n", x >> 8); 5599 return sprintf(buf, "%d\n", x >> 8);
5600} 5600}
5601static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); 5601static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
5602 5602
5603static ssize_t show_saturation(struct class_device *cd, char *buf) 5603static 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)
5609 return -ENODEV; 5609 return -ENODEV;
5610 sensor_get_saturation(ov, &x); 5610 sensor_get_saturation(ov, &x);
5611 return sprintf(buf, "%d\n", x >> 8); 5611 return sprintf(buf, "%d\n", x >> 8);
5612} 5612}
5613static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); 5613static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
5614 5614
5615static ssize_t show_contrast(struct class_device *cd, char *buf) 5615static 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)
5621 return -ENODEV; 5621 return -ENODEV;
5622 sensor_get_contrast(ov, &x); 5622 sensor_get_contrast(ov, &x);
5623 return sprintf(buf, "%d\n", x >> 8); 5623 return sprintf(buf, "%d\n", x >> 8);
5624} 5624}
5625static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); 5625static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
5626 5626
5627static ssize_t show_hue(struct class_device *cd, char *buf) 5627static 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)
5633 return -ENODEV; 5633 return -ENODEV;
5634 sensor_get_hue(ov, &x); 5634 sensor_get_hue(ov, &x);
5635 return sprintf(buf, "%d\n", x >> 8); 5635 return sprintf(buf, "%d\n", x >> 8);
5636} 5636}
5637static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); 5637static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
5638 5638
5639static ssize_t show_exposure(struct class_device *cd, char *buf) 5639static 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)
5645 return -ENODEV; 5645 return -ENODEV;
5646 sensor_get_exposure(ov, &exp); 5646 sensor_get_exposure(ov, &exp);
5647 return sprintf(buf, "%d\n", exp >> 8); 5647 return sprintf(buf, "%d\n", exp >> 8);
5648} 5648}
5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); 5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
5650 5650
5651static void ov_create_sysfs(struct video_device *vdev) 5651static void ov_create_sysfs(struct video_device *vdev)
diff --git a/drivers/usb/media/ov511.h b/drivers/media/video/ov511.h
index bce9b3633889..12b3d51e1c34 100644
--- a/drivers/usb/media/ov511.h
+++ b/drivers/media/video/ov511.h
@@ -130,7 +130,7 @@
130#define R511_COMP_QVY 0x76 130#define R511_COMP_QVY 0x76
131#define R511_COMP_QVUV 0x77 131#define R511_COMP_QVUV 0x77
132#define R511_COMP_EN 0x78 132#define R511_COMP_EN 0x78
133#define R511_COMP_LUT_EN 0x79 133#define R511_COMP_LUT_EN 0x79
134#define R511_COMP_LUT_BEGIN 0x80 134#define R511_COMP_LUT_BEGIN 0x80
135 135
136/* --------------------------------- */ 136/* --------------------------------- */
@@ -459,14 +459,14 @@ struct usb_ov511 {
459 int subh; /* Pix Array subcapture height */ 459 int subh; /* Pix Array subcapture height */
460 460
461 int curframe; /* Current receiving sbuf */ 461 int curframe; /* Current receiving sbuf */
462 struct ov511_frame frame[OV511_NUMFRAMES]; 462 struct ov511_frame frame[OV511_NUMFRAMES];
463 463
464 struct ov511_sbuf sbuf[OV511_NUMSBUF]; 464 struct ov511_sbuf sbuf[OV511_NUMSBUF];
465 465
466 wait_queue_head_t wq; /* Processes waiting */ 466 wait_queue_head_t wq; /* Processes waiting */
467 467
468 int snap_enabled; /* Snapshot mode enabled */ 468 int snap_enabled; /* Snapshot mode enabled */
469 469
470 int bridge; /* Type of bridge (BRG_*) */ 470 int bridge; /* Type of bridge (BRG_*) */
471 int bclass; /* Class of bridge (BCL_*) */ 471 int bclass; /* Class of bridge (BCL_*) */
472 int sensor; /* Type of image sensor chip (SEN_*) */ 472 int sensor; /* Type of image sensor chip (SEN_*) */
@@ -512,7 +512,7 @@ struct symbolic_list {
512/* Returns the name of the matching element in the symbolic_list array. The 512/* Returns the name of the matching element in the symbolic_list array. The
513 * end of the list must be marked with an element that has a NULL name. 513 * end of the list must be marked with an element that has a NULL name.
514 */ 514 */
515static inline char * 515static inline char *
516symbolic(struct symbolic_list list[], int num) 516symbolic(struct symbolic_list list[], int num)
517{ 517{
518 int i; 518 int i;
diff --git a/drivers/media/video/ovcamchip/Makefile b/drivers/media/video/ovcamchip/Makefile
index bca41ad93de8..cba4cdf20f49 100644
--- a/drivers/media/video/ovcamchip/Makefile
+++ b/drivers/media/video/ovcamchip/Makefile
@@ -1,4 +1,4 @@
1ovcamchip-objs := ovcamchip_core.o ov6x20.o ov6x30.o ov7x10.o ov7x20.o \ 1ovcamchip-objs := ovcamchip_core.o ov6x20.o ov6x30.o ov7x10.o ov7x20.o \
2 ov76be.o 2 ov76be.o
3 3
4obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip.o 4obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip.o
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index e76b53d5909c..3fe9fa04cd84 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)
266 PDEBUG(3, "Testing for 0V6xx0"); 266 PDEBUG(3, "Testing for 0V6xx0");
267 c->addr = OV6xx0_SID; 267 c->addr = OV6xx0_SID;
268 if (init_camchip(c) < 0) { 268 if (init_camchip(c) < 0) {
269 return -ENODEV; 269 return -ENODEV;
270 } else { 270 } else {
271 if (ov6xx0_detect(c) < 0) { 271 if (ov6xx0_detect(c) < 0) {
272 PERROR("Failed to init OV6xx0"); 272 PERROR("Failed to init OV6xx0");
273 return -EIO; 273 return -EIO;
274 } 274 }
275 } 275 }
276 } else { 276 } else {
277 if (ov7xx0_detect(c) < 0) { 277 if (ov7xx0_detect(c) < 0) {
278 PERROR("Failed to init OV7xx0"); 278 PERROR("Failed to init OV7xx0");
279 return -EIO; 279 return -EIO;
280 } 280 }
281 } 281 }
282 282
diff --git a/drivers/media/video/ovcamchip/ovcamchip_priv.h b/drivers/media/video/ovcamchip/ovcamchip_priv.h
index 575e612a5546..1231335a9f4a 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,
82 struct ovcamchip_regvals *rvals); 82 struct ovcamchip_regvals *rvals);
83 83
84extern int ov_write_mask(struct i2c_client *c, unsigned char reg, 84extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
85 unsigned char value, unsigned char mask); 85 unsigned char value, unsigned char mask);
86 86
87#endif 87#endif
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 15fd85acabda..522e9ddeb089 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -1,4 +1,4 @@
1/* 1/*
2 planb - PlanB frame grabber driver 2 planb - PlanB frame grabber driver
3 3
4 PlanB is used in the 7x00/8x00 series of PowerMacintosh 4 PlanB is used in the 7x00/8x00 series of PowerMacintosh
@@ -584,7 +584,7 @@ finish:
584 wake_up_interruptible(&pb->suspendq); 584 wake_up_interruptible(&pb->suspendq);
585} 585}
586 586
587static void add_clip(struct planb *pb, struct video_clip *clip) 587static void add_clip(struct planb *pb, struct video_clip *clip)
588{ 588{
589 volatile unsigned char *base; 589 volatile unsigned char *base;
590 int xc = clip->x, yc = clip->y; 590 int xc = clip->x, yc = clip->y;
@@ -758,7 +758,7 @@ static void cmd_buff(struct planb *pb)
758 PLANB_SET(CH_SYNC)); 758 PLANB_SET(CH_SYNC));
759 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), 759 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
760 PLANB_SET(DMA_ABORT)); 760 PLANB_SET(DMA_ABORT));
761 761
762 /* odd field data: */ 762 /* odd field data: */
763 jump = virt_to_bus(c1 + nlines / 2); 763 jump = virt_to_bus(c1 + nlines / 2);
764 for (i=1; i < nlines; i += stepsize, c1++) 764 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)
1247 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++; 1247 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++;
1248 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), 1248 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1249 PLANB_SET(DMA_ABORT)); 1249 PLANB_SET(DMA_ABORT));
1250 1250
1251 /* odd field data: */ 1251 /* odd field data: */
1252 jump_addr = c1 + TAB_FACTOR * nlines / 2; 1252 jump_addr = c1 + TAB_FACTOR * nlines / 2;
1253 jump = virt_to_bus(jump_addr); 1253 jump = virt_to_bus(jump_addr);
@@ -1383,7 +1383,7 @@ static int planb_open(struct video_device *dev, int mode)
1383 pb->user++; 1383 pb->user++;
1384 1384
1385 DEBUG("PlanB: device opened\n"); 1385 DEBUG("PlanB: device opened\n");
1386 return 0; 1386 return 0;
1387} 1387}
1388 1388
1389static void planb_close(struct video_device *dev) 1389static void planb_close(struct video_device *dev)
@@ -1424,9 +1424,9 @@ static long planb_write(struct video_device *v, const char *buf,
1424static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) 1424static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1425{ 1425{
1426 struct planb *pb=(struct planb *)dev; 1426 struct planb *pb=(struct planb *)dev;
1427 1427
1428 switch (cmd) 1428 switch (cmd)
1429 { 1429 {
1430 case VIDIOCGCAP: 1430 case VIDIOCGCAP:
1431 { 1431 {
1432 struct video_capability b; 1432 struct video_capability b;
@@ -1440,26 +1440,26 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1440 b.channels = 2; /* composite & svhs */ 1440 b.channels = 2; /* composite & svhs */
1441 b.audios = 0; 1441 b.audios = 0;
1442 b.maxwidth = PLANB_MAXPIXELS; 1442 b.maxwidth = PLANB_MAXPIXELS;
1443 b.maxheight = PLANB_MAXLINES; 1443 b.maxheight = PLANB_MAXLINES;
1444 b.minwidth = 32; /* wild guess */ 1444 b.minwidth = 32; /* wild guess */
1445 b.minheight = 32; 1445 b.minheight = 32;
1446 if (copy_to_user(arg,&b,sizeof(b))) 1446 if (copy_to_user(arg,&b,sizeof(b)))
1447 return -EFAULT; 1447 return -EFAULT;
1448 return 0; 1448 return 0;
1449 } 1449 }
1450 case VIDIOCSFBUF: 1450 case VIDIOCSFBUF:
1451 { 1451 {
1452 struct video_buffer v; 1452 struct video_buffer v;
1453 unsigned short bpp; 1453 unsigned short bpp;
1454 unsigned int fmt; 1454 unsigned int fmt;
1455 1455
1456 DEBUG("PlanB: IOCTL VIDIOCSFBUF\n"); 1456 DEBUG("PlanB: IOCTL VIDIOCSFBUF\n");
1457 1457
1458 if (!capable(CAP_SYS_ADMIN) 1458 if (!capable(CAP_SYS_ADMIN)
1459 || !capable(CAP_SYS_RAWIO)) 1459 || !capable(CAP_SYS_RAWIO))
1460 return -EPERM; 1460 return -EPERM;
1461 if (copy_from_user(&v, arg,sizeof(v))) 1461 if (copy_from_user(&v, arg,sizeof(v)))
1462 return -EFAULT; 1462 return -EFAULT;
1463 planb_lock(pb); 1463 planb_lock(pb);
1464 switch(v.depth) { 1464 switch(v.depth) {
1465 case 8: 1465 case 8:
@@ -1478,7 +1478,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1478 break; 1478 break;
1479 default: 1479 default:
1480 planb_unlock(pb); 1480 planb_unlock(pb);
1481 return -EINVAL; 1481 return -EINVAL;
1482 } 1482 }
1483 if (bpp * v.width > v.bytesperline) { 1483 if (bpp * v.width > v.bytesperline) {
1484 planb_unlock(pb); 1484 planb_unlock(pb);
@@ -1493,7 +1493,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1493 pb->win.bpl = pb->win.bpp * pb->win.swidth; 1493 pb->win.bpl = pb->win.bpp * pb->win.swidth;
1494 pb->win.pad = v.bytesperline - pb->win.bpl; 1494 pb->win.pad = v.bytesperline - pb->win.bpl;
1495 1495
1496 DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d," 1496 DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d,"
1497 " bpl %d (+ %d)\n", v.base, v.width,v.height, 1497 " bpl %d (+ %d)\n", v.base, v.width,v.height,
1498 pb->win.bpp, pb->win.bpl, pb->win.pad); 1498 pb->win.bpp, pb->win.bpl, pb->win.pad);
1499 1499
@@ -1504,11 +1504,11 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1504 resume_overlay(pb); 1504 resume_overlay(pb);
1505 } 1505 }
1506 planb_unlock(pb); 1506 planb_unlock(pb);
1507 return 0; 1507 return 0;
1508 } 1508 }
1509 case VIDIOCGFBUF: 1509 case VIDIOCGFBUF:
1510 { 1510 {
1511 struct video_buffer v; 1511 struct video_buffer v;
1512 1512
1513 DEBUG("PlanB: IOCTL VIDIOCGFBUF\n"); 1513 DEBUG("PlanB: IOCTL VIDIOCGFBUF\n");
1514 1514
@@ -1518,15 +1518,15 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1518 v.depth = pb->win.depth; 1518 v.depth = pb->win.depth;
1519 v.bytesperline = pb->win.bpl + pb->win.pad; 1519 v.bytesperline = pb->win.bpl + pb->win.pad;
1520 if (copy_to_user(arg, &v, sizeof(v))) 1520 if (copy_to_user(arg, &v, sizeof(v)))
1521 return -EFAULT; 1521 return -EFAULT;
1522 return 0; 1522 return 0;
1523 } 1523 }
1524 case VIDIOCCAPTURE: 1524 case VIDIOCCAPTURE:
1525 { 1525 {
1526 int i; 1526 int i;
1527 1527
1528 if(copy_from_user(&i, arg, sizeof(i))) 1528 if(copy_from_user(&i, arg, sizeof(i)))
1529 return -EFAULT; 1529 return -EFAULT;
1530 if(i==0) { 1530 if(i==0) {
1531 DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n"); 1531 DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n");
1532 1532
@@ -1695,7 +1695,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1695 struct video_window vw; 1695 struct video_window vw;
1696 struct video_clip clip; 1696 struct video_clip clip;
1697 int i; 1697 int i;
1698 1698
1699 DEBUG("PlanB: IOCTL VIDIOCSWIN\n"); 1699 DEBUG("PlanB: IOCTL VIDIOCSWIN\n");
1700 1700
1701 if(copy_from_user(&vw,arg,sizeof(vw))) 1701 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)
1749 return -EFAULT; 1749 return -EFAULT;
1750 return 0; 1750 return 0;
1751 } 1751 }
1752 case VIDIOCSYNC: { 1752 case VIDIOCSYNC: {
1753 int i; 1753 int i;
1754 1754
1755 IDEBUG("PlanB: IOCTL VIDIOCSYNC\n"); 1755 IDEBUG("PlanB: IOCTL VIDIOCSYNC\n");
@@ -1759,42 +1759,42 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1759 1759
1760 IDEBUG("PlanB: sync to frame %d\n", i); 1760 IDEBUG("PlanB: sync to frame %d\n", i);
1761 1761
1762 if(i > (MAX_GBUFFERS - 1) || i < 0) 1762 if(i > (MAX_GBUFFERS - 1) || i < 0)
1763 return -EINVAL; 1763 return -EINVAL;
1764chk_grab: 1764chk_grab:
1765 switch (pb->frame_stat[i]) { 1765 switch (pb->frame_stat[i]) {
1766 case GBUFFER_UNUSED: 1766 case GBUFFER_UNUSED:
1767 return -EINVAL; 1767 return -EINVAL;
1768 case GBUFFER_GRABBING: 1768 case GBUFFER_GRABBING:
1769 IDEBUG("PlanB: waiting for grab" 1769 IDEBUG("PlanB: waiting for grab"
1770 " done (%d)\n", i); 1770 " done (%d)\n", i);
1771 interruptible_sleep_on(&pb->capq); 1771 interruptible_sleep_on(&pb->capq);
1772 if(signal_pending(current)) 1772 if(signal_pending(current))
1773 return -EINTR; 1773 return -EINTR;
1774 goto chk_grab; 1774 goto chk_grab;
1775 case GBUFFER_DONE: 1775 case GBUFFER_DONE:
1776 pb->frame_stat[i] = GBUFFER_UNUSED; 1776 pb->frame_stat[i] = GBUFFER_UNUSED;
1777 break; 1777 break;
1778 } 1778 }
1779 return 0; 1779 return 0;
1780 } 1780 }
1781 1781
1782 case VIDIOCMCAPTURE: 1782 case VIDIOCMCAPTURE:
1783 { 1783 {
1784 struct video_mmap vm; 1784 struct video_mmap vm;
1785 volatile unsigned int status; 1785 volatile unsigned int status;
1786 1786
1787 IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n"); 1787 IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n");
1788 1788
1789 if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm))) 1789 if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm)))
1790 return -EFAULT; 1790 return -EFAULT;
1791 status = pb->frame_stat[vm.frame]; 1791 status = pb->frame_stat[vm.frame];
1792 if (status != GBUFFER_UNUSED) 1792 if (status != GBUFFER_UNUSED)
1793 return -EBUSY; 1793 return -EBUSY;
1794 1794
1795 return vgrab(pb, &vm); 1795 return vgrab(pb, &vm);
1796 } 1796 }
1797 1797
1798 case VIDIOCGMBUF: 1798 case VIDIOCGMBUF:
1799 { 1799 {
1800 int i; 1800 int i;
@@ -1811,7 +1811,7 @@ chk_grab:
1811 return -EFAULT; 1811 return -EFAULT;
1812 return 0; 1812 return 0;
1813 } 1813 }
1814 1814
1815 case PLANBIOCGSAAREGS: 1815 case PLANBIOCGSAAREGS:
1816 { 1816 {
1817 struct planb_saa_regs preg; 1817 struct planb_saa_regs preg;
@@ -1828,7 +1828,7 @@ chk_grab:
1828 return -EFAULT; 1828 return -EFAULT;
1829 return 0; 1829 return 0;
1830 } 1830 }
1831 1831
1832 case PLANBIOCSSAAREGS: 1832 case PLANBIOCSSAAREGS:
1833 { 1833 {
1834 struct planb_saa_regs preg; 1834 struct planb_saa_regs preg;
@@ -1842,7 +1842,7 @@ chk_grab:
1842 saa_set (preg.addr, preg.val, pb); 1842 saa_set (preg.addr, preg.val, pb);
1843 return 0; 1843 return 0;
1844 } 1844 }
1845 1845
1846 case PLANBIOCGSTAT: 1846 case PLANBIOCGSTAT:
1847 { 1847 {
1848 struct planb_stat_regs pstat; 1848 struct planb_stat_regs pstat;
@@ -1859,7 +1859,7 @@ chk_grab:
1859 return -EFAULT; 1859 return -EFAULT;
1860 return 0; 1860 return 0;
1861 } 1861 }
1862 1862
1863 case PLANBIOCSMODE: { 1863 case PLANBIOCSMODE: {
1864 int v; 1864 int v;
1865 1865
@@ -1985,10 +1985,10 @@ static int planb_mmap(struct vm_area_struct *vma, struct video_device *dev, cons
1985{ 1985{
1986 int i; 1986 int i;
1987 struct planb *pb = (struct planb *)dev; 1987 struct planb *pb = (struct planb *)dev;
1988 unsigned long start = (unsigned long)adr; 1988 unsigned long start = (unsigned long)adr;
1989 1989
1990 if (size > MAX_GBUFFERS * PLANB_MAX_FBUF) 1990 if (size > MAX_GBUFFERS * PLANB_MAX_FBUF)
1991 return -EINVAL; 1991 return -EINVAL;
1992 if (!pb->rawbuf) { 1992 if (!pb->rawbuf) {
1993 int err; 1993 int err;
1994 if((err=grabbuf_alloc(pb))) 1994 if((err=grabbuf_alloc(pb)))
@@ -2091,10 +2091,10 @@ static int init_planb(struct planb *pb)
2091 /* clear interrupt mask */ 2091 /* clear interrupt mask */
2092 pb->intr_mask = PLANB_CLR_IRQ; 2092 pb->intr_mask = PLANB_CLR_IRQ;
2093 2093
2094 result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb); 2094 result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb);
2095 if (result < 0) { 2095 if (result < 0) {
2096 if (result==-EINVAL) 2096 if (result==-EINVAL)
2097 printk(KERN_ERR "PlanB: Bad irq number (%d) " 2097 printk(KERN_ERR "PlanB: Bad irq number (%d) "
2098 "or handler\n", (int)pb->irq); 2098 "or handler\n", (int)pb->irq);
2099 else if (result==-EBUSY) 2099 else if (result==-EBUSY)
2100 printk(KERN_ERR "PlanB: I don't know why, " 2100 printk(KERN_ERR "PlanB: I don't know why, "
@@ -2102,7 +2102,7 @@ static int init_planb(struct planb *pb)
2102 return result; 2102 return result;
2103 } 2103 }
2104 disable_irq(pb->irq); 2104 disable_irq(pb->irq);
2105 2105
2106 /* Now add the template and register the device unit. */ 2106 /* Now add the template and register the device unit. */
2107 memcpy(&pb->video_dev,&planb_template,sizeof(planb_template)); 2107 memcpy(&pb->video_dev,&planb_template,sizeof(planb_template));
2108 2108
@@ -2143,7 +2143,7 @@ static int init_planb(struct planb *pb)
2143} 2143}
2144 2144
2145/* 2145/*
2146 * Scan for a PlanB controller, request the irq and map the io memory 2146 * Scan for a PlanB controller, request the irq and map the io memory
2147 */ 2147 */
2148 2148
2149static int find_planb(void) 2149static int find_planb(void)
@@ -2171,9 +2171,9 @@ static int find_planb(void)
2171 pb = &planbs[0]; 2171 pb = &planbs[0];
2172 planb_num = 1; 2172 planb_num = 1;
2173 2173
2174 if (planb_devices->n_addrs != 1) { 2174 if (planb_devices->n_addrs != 1) {
2175 printk (KERN_WARNING "PlanB: expecting 1 address for planb " 2175 printk (KERN_WARNING "PlanB: expecting 1 address for planb "
2176 "(got %d)", planb_devices->n_addrs); 2176 "(got %d)", planb_devices->n_addrs);
2177 return 0; 2177 return 0;
2178 } 2178 }
2179 2179
@@ -2236,7 +2236,7 @@ static int find_planb(void)
2236 pb->planb_base = planb_regs; 2236 pb->planb_base = planb_regs;
2237 pb->planb_base_phys = (struct planb_registers *)new_base; 2237 pb->planb_base_phys = (struct planb_registers *)new_base;
2238 pb->irq = irq; 2238 pb->irq = irq;
2239 2239
2240 return planb_num; 2240 return planb_num;
2241 2241
2242err_out_disable: 2242err_out_disable:
@@ -2251,7 +2251,7 @@ static void release_planb(void)
2251 int i; 2251 int i;
2252 struct planb *pb; 2252 struct planb *pb;
2253 2253
2254 for (i=0;i<planb_num; i++) 2254 for (i=0;i<planb_num; i++)
2255 { 2255 {
2256 pb=&planbs[i]; 2256 pb=&planbs[i];
2257 2257
@@ -2278,7 +2278,7 @@ static void release_planb(void)
2278static int __init init_planbs(void) 2278static int __init init_planbs(void)
2279{ 2279{
2280 int i; 2280 int i;
2281 2281
2282 if (find_planb()<=0) 2282 if (find_planb()<=0)
2283 return -EIO; 2283 return -EIO;
2284 2284
@@ -2288,9 +2288,9 @@ static int __init init_planbs(void)
2288 " with v4l\n", i); 2288 " with v4l\n", i);
2289 release_planb(); 2289 release_planb();
2290 return -EIO; 2290 return -EIO;
2291 } 2291 }
2292 printk(KERN_INFO "PlanB: registered device %d with v4l\n", i); 2292 printk(KERN_INFO "PlanB: registered device %d with v4l\n", i);
2293 } 2293 }
2294 return 0; 2294 return 0;
2295} 2295}
2296 2296
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h
index 79b6b561426e..92823211d0c5 100644
--- a/drivers/media/video/planb.h
+++ b/drivers/media/video/planb.h
@@ -1,4 +1,4 @@
1/* 1/*
2 planb - PlanB frame grabber driver 2 planb - PlanB frame grabber driver
3 3
4 PlanB is used in the 7x00/8x00 series of PowerMacintosh 4 PlanB is used in the 7x00/8x00 series of PowerMacintosh
@@ -167,7 +167,7 @@ struct planb {
167 struct video_device video_dev; 167 struct video_device video_dev;
168 struct video_picture picture; /* Current picture params */ 168 struct video_picture picture; /* Current picture params */
169 struct video_audio audio_dev; /* Current audio params */ 169 struct video_audio audio_dev; /* Current audio params */
170 170
171 volatile struct planb_registers *planb_base; /* virt base of planb */ 171 volatile struct planb_registers *planb_base; /* virt base of planb */
172 struct planb_registers *planb_base_phys; /* phys base of planb */ 172 struct planb_registers *planb_base_phys; /* phys base of planb */
173 void *priv_space; /* Org. alloc. mem for kfree */ 173 void *priv_space; /* Org. alloc. mem for kfree */
@@ -209,7 +209,7 @@ struct planb {
209 int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS]; 209 int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS];
210 unsigned int gfmt[MAX_GBUFFERS]; 210 unsigned int gfmt[MAX_GBUFFERS];
211 int gnorm_switch[MAX_GBUFFERS]; 211 int gnorm_switch[MAX_GBUFFERS];
212 volatile unsigned int *frame_stat; 212 volatile unsigned int *frame_stat;
213#define GBUFFER_UNUSED 0x00U 213#define GBUFFER_UNUSED 0x00U
214#define GBUFFER_GRABBING 0x01U 214#define GBUFFER_GRABBING 0x01U
215#define GBUFFER_DONE 0x02U 215#define GBUFFER_DONE 0x02U
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 05ca55939e77..09835ca098b1 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -12,10 +12,10 @@
12 * Most of this code is directly derived from his userspace driver. 12 * Most of this code is directly derived from his userspace driver.
13 * His driver works so send any reports to alan@redhat.com unless the 13 * His driver works so send any reports to alan@redhat.com unless the
14 * userspace driver also doesn't work for you... 14 * userspace driver also doesn't work for you...
15 * 15 *
16 * Changes: 16 * Changes:
17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it> 17 * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it>
18 * - pms_capture: report back -EFAULT 18 * - pms_capture: report back -EFAULT
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
@@ -66,14 +66,14 @@ static int standard = 0; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
66/* 66/*
67 * I/O ports and Shared Memory 67 * I/O ports and Shared Memory
68 */ 68 */
69 69
70static int io_port = 0x250; 70static int io_port = 0x250;
71static int data_port = 0x251; 71static int data_port = 0x251;
72static int mem_base = 0xC8000; 72static int mem_base = 0xC8000;
73static void __iomem *mem; 73static void __iomem *mem;
74static int video_nr = -1; 74static int video_nr = -1;
75 75
76 76
77 77
78static inline void mvv_write(u8 index, u8 value) 78static inline void mvv_write(u8 index, u8 value)
79{ 79{
@@ -90,9 +90,9 @@ static int pms_i2c_stat(u8 slave)
90{ 90{
91 int counter; 91 int counter;
92 int i; 92 int i;
93 93
94 outb(0x28, io_port); 94 outb(0x28, io_port);
95 95
96 counter=0; 96 counter=0;
97 while((inb(data_port)&0x01)==0) 97 while((inb(data_port)&0x01)==0)
98 if(counter++==256) 98 if(counter++==256)
@@ -101,9 +101,9 @@ static int pms_i2c_stat(u8 slave)
101 while((inb(data_port)&0x01)!=0) 101 while((inb(data_port)&0x01)!=0)
102 if(counter++==256) 102 if(counter++==256)
103 break; 103 break;
104 104
105 outb(slave, io_port); 105 outb(slave, io_port);
106 106
107 counter=0; 107 counter=0;
108 while((inb(data_port)&0x01)==0) 108 while((inb(data_port)&0x01)==0)
109 if(counter++==256) 109 if(counter++==256)
@@ -112,7 +112,7 @@ static int pms_i2c_stat(u8 slave)
112 while((inb(data_port)&0x01)!=0) 112 while((inb(data_port)&0x01)!=0)
113 if(counter++==256) 113 if(counter++==256)
114 break; 114 break;
115 115
116 for(i=0;i<12;i++) 116 for(i=0;i<12;i++)
117 { 117 {
118 char st=inb(data_port); 118 char st=inb(data_port);
@@ -122,7 +122,7 @@ static int pms_i2c_stat(u8 slave)
122 break; 122 break;
123 } 123 }
124 outb(0x29, io_port); 124 outb(0x29, io_port);
125 return inb(data_port); 125 return inb(data_port);
126} 126}
127 127
128static int pms_i2c_write(u16 slave, u16 sub, u16 data) 128static 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)
130 int skip=0; 130 int skip=0;
131 int count; 131 int count;
132 int i; 132 int i;
133 133
134 for(i=0;i<i2c_count;i++) 134 for(i=0;i<i2c_count;i++)
135 { 135 {
136 if((i2cinfo[i].slave==slave) && 136 if((i2cinfo[i].slave==slave) &&
137 (i2cinfo[i].sub == sub)) 137 (i2cinfo[i].sub == sub))
138 { 138 {
139 if(i2cinfo[i].data==data) 139 if(i2cinfo[i].data==data)
140 skip=1; 140 skip=1;
141 i2cinfo[i].data=data; 141 i2cinfo[i].data=data;
142 i=i2c_count+1; 142 i=i2c_count+1;
143 } 143 }
144 } 144 }
145 145
146 if(i==i2c_count && i2c_count<64) 146 if(i==i2c_count && i2c_count<64)
147 { 147 {
148 i2cinfo[i2c_count].slave=slave; 148 i2cinfo[i2c_count].slave=slave;
@@ -150,16 +150,16 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
150 i2cinfo[i2c_count].data=data; 150 i2cinfo[i2c_count].data=data;
151 i2c_count++; 151 i2c_count++;
152 } 152 }
153 153
154 if(skip) 154 if(skip)
155 return 0; 155 return 0;
156 156
157 mvv_write(0x29, sub); 157 mvv_write(0x29, sub);
158 mvv_write(0x2A, data); 158 mvv_write(0x2A, data);
159 mvv_write(0x28, slave); 159 mvv_write(0x28, slave);
160 160
161 outb(0x28, io_port); 161 outb(0x28, io_port);
162 162
163 count=0; 163 count=0;
164 while((inb(data_port)&1)==0) 164 while((inb(data_port)&1)==0)
165 if(count>255) 165 if(count>255)
@@ -167,9 +167,9 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
167 while((inb(data_port)&1)!=0) 167 while((inb(data_port)&1)!=0)
168 if(count>255) 168 if(count>255)
169 break; 169 break;
170 170
171 count=inb(data_port); 171 count=inb(data_port);
172 172
173 if(count&2) 173 if(count&2)
174 return -1; 174 return -1;
175 return count; 175 return count;
@@ -189,8 +189,8 @@ static int pms_i2c_read(int slave, int sub)
189 189
190static void pms_i2c_andor(int slave, int sub, int and, int or) 190static void pms_i2c_andor(int slave, int sub, int and, int or)
191{ 191{
192 u8 tmp; 192 u8 tmp;
193 193
194 tmp=pms_i2c_read(slave, sub); 194 tmp=pms_i2c_read(slave, sub);
195 tmp = (tmp&and)|or; 195 tmp = (tmp&and)|or;
196 pms_i2c_write(slave, sub, tmp); 196 pms_i2c_write(slave, sub, tmp);
@@ -199,7 +199,7 @@ static void pms_i2c_andor(int slave, int sub, int and, int or)
199/* 199/*
200 * Control functions 200 * Control functions
201 */ 201 */
202 202
203 203
204static void pms_videosource(short source) 204static void pms_videosource(short source)
205{ 205{
@@ -234,8 +234,8 @@ static void pms_colour(short colour)
234 break; 234 break;
235 } 235 }
236} 236}
237 237
238 238
239static void pms_contrast(short contrast) 239static void pms_contrast(short contrast)
240{ 240{
241 switch(decoder) 241 switch(decoder)
@@ -269,14 +269,14 @@ static void pms_format(short format)
269{ 269{
270 int target; 270 int target;
271 standard = format; 271 standard = format;
272 272
273 if(decoder==PHILIPS1) 273 if(decoder==PHILIPS1)
274 target=0x42; 274 target=0x42;
275 else if(decoder==PHILIPS2) 275 else if(decoder==PHILIPS2)
276 target=0x8A; 276 target=0x8A;
277 else 277 else
278 return; 278 return;
279 279
280 switch(format) 280 switch(format)
281 { 281 {
282 case 0: /* Auto */ 282 case 0: /* Auto */
@@ -302,7 +302,7 @@ static void pms_format(short format)
302 302
303/* 303/*
304 * These features of the PMS card are not currently exposes. They 304 * These features of the PMS card are not currently exposes. They
305 * could become a private v4l ioctl for PMSCONFIG or somesuch if 305 * could become a private v4l ioctl for PMSCONFIG or somesuch if
306 * people need it. We also don't yet use the PMS interrupt. 306 * people need it. We also don't yet use the PMS interrupt.
307 */ 307 */
308 308
@@ -324,7 +324,7 @@ static void pms_hstart(short start)
324/* 324/*
325 * Bandpass filters 325 * Bandpass filters
326 */ 326 */
327 327
328static void pms_bandpass(short pass) 328static void pms_bandpass(short pass)
329{ 329{
330 if(decoder==PHILIPS2) 330 if(decoder==PHILIPS2)
@@ -493,7 +493,7 @@ static void pms_vert(u8 deciden, u8 decinum)
493/* 493/*
494 * Turn 16bit ratios into best small ratio the chipset can grok 494 * Turn 16bit ratios into best small ratio the chipset can grok
495 */ 495 */
496 496
497static void pms_vertdeci(unsigned short decinum, unsigned short deciden) 497static void pms_vertdeci(unsigned short decinum, unsigned short deciden)
498{ 498{
499 /* Knock it down by /5 once */ 499 /* Knock it down by /5 once */
@@ -546,7 +546,7 @@ static void pms_horzdeci(short decinum, short deciden)
546 decinum=512; 546 decinum=512;
547 deciden=640; /* 768 would be ideal */ 547 deciden=640; /* 768 would be ideal */
548 } 548 }
549 549
550 while(((decinum|deciden)&1)==0) 550 while(((decinum|deciden)&1)==0)
551 { 551 {
552 decinum>>=1; 552 decinum>>=1;
@@ -559,7 +559,7 @@ static void pms_horzdeci(short decinum, short deciden)
559 } 559 }
560 if(deciden==32) 560 if(deciden==32)
561 deciden--; 561 deciden--;
562 562
563 mvv_write(0x24, 0x80|deciden); 563 mvv_write(0x24, 0x80|deciden);
564 mvv_write(0x25, decinum); 564 mvv_write(0x25, decinum);
565} 565}
@@ -567,14 +567,14 @@ static void pms_horzdeci(short decinum, short deciden)
567static void pms_resolution(short width, short height) 567static void pms_resolution(short width, short height)
568{ 568{
569 int fg_height; 569 int fg_height;
570 570
571 fg_height=height; 571 fg_height=height;
572 if(fg_height>280) 572 if(fg_height>280)
573 fg_height=280; 573 fg_height=280;
574 574
575 mvv_write(0x18, fg_height); 575 mvv_write(0x18, fg_height);
576 mvv_write(0x19, fg_height>>8); 576 mvv_write(0x19, fg_height>>8);
577 577
578 if(standard==1) 578 if(standard==1)
579 { 579 {
580 mvv_write(0x1A, 0xFC); 580 mvv_write(0x1A, 0xFC);
@@ -598,7 +598,7 @@ static void pms_resolution(short width, short height)
598 mvv_write(0x42, 0x00); 598 mvv_write(0x42, 0x00);
599 mvv_write(0x43, 0x00); 599 mvv_write(0x43, 0x00);
600 mvv_write(0x44, MVVMEMORYWIDTH); 600 mvv_write(0x44, MVVMEMORYWIDTH);
601 601
602 mvv_write(0x22, width+8); 602 mvv_write(0x22, width+8);
603 mvv_write(0x23, (width+8)>> 8); 603 mvv_write(0x23, (width+8)>> 8);
604 604
@@ -618,7 +618,7 @@ static void pms_resolution(short width, short height)
618/* 618/*
619 * Set Input 619 * Set Input
620 */ 620 */
621 621
622static void pms_vcrinput(short input) 622static void pms_vcrinput(short input)
623{ 623{
624 if(decoder==PHILIPS2) 624 if(decoder==PHILIPS2)
@@ -643,20 +643,20 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
643 mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */ 643 mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */
644 644
645/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */ 645/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */
646 646
647 for (y = 0; y < dev->height; y++ ) 647 for (y = 0; y < dev->height; y++ )
648 { 648 {
649 writeb(0, mem); /* synchronisiert neue Zeile */ 649 writeb(0, mem); /* synchronisiert neue Zeile */
650 650
651 /* 651 /*
652 * This is in truth a fifo, be very careful as if you 652 * This is in truth a fifo, be very careful as if you
653 * forgot this odd things will occur 8) 653 * forgot this odd things will occur 8)
654 */ 654 */
655 655
656 memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */ 656 memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */
657 cnt -= dev->height; 657 cnt -= dev->height;
658 while (cnt <= 0) 658 while (cnt <= 0)
659 { 659 {
660 /* 660 /*
661 * Don't copy too far 661 * Don't copy too far
662 */ 662 */
@@ -666,7 +666,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
666 cnt += dev->height; 666 cnt += dev->height;
667 if (copy_to_user(buf, tmp+32, dt)) 667 if (copy_to_user(buf, tmp+32, dt))
668 return len ? len : -EFAULT; 668 return len ? len : -EFAULT;
669 buf += dt; 669 buf += dt;
670 len += dt; 670 len += dt;
671 } 671 }
672 } 672 }
@@ -683,7 +683,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
683{ 683{
684 struct video_device *dev = video_devdata(file); 684 struct video_device *dev = video_devdata(file);
685 struct pms_device *pd=(struct pms_device *)dev; 685 struct pms_device *pd=(struct pms_device *)dev;
686 686
687 switch(cmd) 687 switch(cmd)
688 { 688 {
689 case VIDIOCGCAP: 689 case VIDIOCGCAP:
@@ -806,7 +806,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
806 ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15))) 806 ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15)))
807 return -EINVAL; 807 return -EINVAL;
808 pd->picture= *p; 808 pd->picture= *p;
809 809
810 /* 810 /*
811 * Now load the card. 811 * Now load the card.
812 */ 812 */
@@ -815,7 +815,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
815 pms_brightness(p->brightness>>8); 815 pms_brightness(p->brightness>>8);
816 pms_hue(p->hue>>8); 816 pms_hue(p->hue>>8);
817 pms_colour(p->colour>>8); 817 pms_colour(p->colour>>8);
818 pms_contrast(p->contrast>>8); 818 pms_contrast(p->contrast>>8);
819 mutex_unlock(&pd->lock); 819 mutex_unlock(&pd->lock);
820 return 0; 820 return 0;
821 } 821 }
@@ -873,7 +873,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
873 struct video_device *v = video_devdata(file); 873 struct video_device *v = video_devdata(file);
874 struct pms_device *pd=(struct pms_device *)v; 874 struct pms_device *pd=(struct pms_device *)v;
875 int len; 875 int len;
876 876
877 mutex_lock(&pd->lock); 877 mutex_lock(&pd->lock);
878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count); 878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count);
879 mutex_unlock(&pd->lock); 879 mutex_unlock(&pd->lock);
@@ -905,13 +905,13 @@ static struct pms_device pms_device;
905/* 905/*
906 * Probe for and initialise the Mediavision PMS 906 * Probe for and initialise the Mediavision PMS
907 */ 907 */
908 908
909static int init_mediavision(void) 909static int init_mediavision(void)
910{ 910{
911 int id; 911 int id;
912 int idec, decst; 912 int idec, decst;
913 int i; 913 int i;
914 914
915 unsigned char i2c_defs[]={ 915 unsigned char i2c_defs[]={
916 0x4C,0x30,0x00,0xE8, 916 0x4C,0x30,0x00,0xE8,
917 0xB6,0xE2,0x00,0x00, 917 0xB6,0xE2,0x00,0x00,
@@ -925,7 +925,7 @@ static int init_mediavision(void)
925 mem = ioremap(mem_base, 0x800); 925 mem = ioremap(mem_base, 0x800);
926 if (!mem) 926 if (!mem)
927 return -ENOMEM; 927 return -ENOMEM;
928 928
929 if (!request_region(0x9A01, 1, "Mediavision PMS config")) 929 if (!request_region(0x9A01, 1, "Mediavision PMS config"))
930 { 930 {
931 printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n"); 931 printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n");
@@ -941,18 +941,18 @@ static int init_mediavision(void)
941 } 941 }
942 outb(0xB8, 0x9A01); /* Unlock */ 942 outb(0xB8, 0x9A01); /* Unlock */
943 outb(io_port>>4, 0x9A01); /* Set IO port */ 943 outb(io_port>>4, 0x9A01); /* Set IO port */
944 944
945 945
946 id=mvv_read(3); 946 id=mvv_read(3);
947 decst=pms_i2c_stat(0x43); 947 decst=pms_i2c_stat(0x43);
948 948
949 if(decst!=-1) 949 if(decst!=-1)
950 idec=2; 950 idec=2;
951 else if(pms_i2c_stat(0xb9)!=-1) 951 else if(pms_i2c_stat(0xb9)!=-1)
952 idec=3; 952 idec=3;
953 else if(pms_i2c_stat(0x8b)!=-1) 953 else if(pms_i2c_stat(0x8b)!=-1)
954 idec=1; 954 idec=1;
955 else 955 else
956 idec=0; 956 idec=0;
957 957
958 printk(KERN_INFO "PMS type is %d\n", idec); 958 printk(KERN_INFO "PMS type is %d\n", idec);
@@ -966,11 +966,11 @@ static int init_mediavision(void)
966 /* 966 /*
967 * Ok we have a PMS of some sort 967 * Ok we have a PMS of some sort
968 */ 968 */
969 969
970 mvv_write(0x04, mem_base>>12); /* Set the memory area */ 970 mvv_write(0x04, mem_base>>12); /* Set the memory area */
971 971
972 /* Ok now load the defaults */ 972 /* Ok now load the defaults */
973 973
974 for(i=0;i<0x19;i++) 974 for(i=0;i<0x19;i++)
975 { 975 {
976 if(i2c_defs[i]==0xFF) 976 if(i2c_defs[i]==0xFF)
@@ -978,7 +978,7 @@ static int init_mediavision(void)
978 else 978 else
979 pms_i2c_write(0x8A, i, i2c_defs[i]); 979 pms_i2c_write(0x8A, i, i2c_defs[i]);
980 } 980 }
981 981
982 pms_i2c_write(0xB8,0x00,0x12); 982 pms_i2c_write(0xB8,0x00,0x12);
983 pms_i2c_write(0xB8,0x04,0x00); 983 pms_i2c_write(0xB8,0x04,0x00);
984 pms_i2c_write(0xB8,0x07,0x00); 984 pms_i2c_write(0xB8,0x07,0x00);
@@ -987,18 +987,18 @@ static int init_mediavision(void)
987 pms_i2c_write(0xB8,0x0A,0x00); 987 pms_i2c_write(0xB8,0x0A,0x00);
988 pms_i2c_write(0xB8,0x0B,0x10); 988 pms_i2c_write(0xB8,0x0B,0x10);
989 pms_i2c_write(0xB8,0x10,0x03); 989 pms_i2c_write(0xB8,0x10,0x03);
990 990
991 mvv_write(0x01, 0x00); 991 mvv_write(0x01, 0x00);
992 mvv_write(0x05, 0xA0); 992 mvv_write(0x05, 0xA0);
993 mvv_write(0x08, 0x25); 993 mvv_write(0x08, 0x25);
994 mvv_write(0x09, 0x00); 994 mvv_write(0x09, 0x00);
995 mvv_write(0x0A, 0x20|MVVMEMORYWIDTH); 995 mvv_write(0x0A, 0x20|MVVMEMORYWIDTH);
996 996
997 mvv_write(0x10, 0x02); 997 mvv_write(0x10, 0x02);
998 mvv_write(0x1E, 0x0C); 998 mvv_write(0x1E, 0x0C);
999 mvv_write(0x1F, 0x03); 999 mvv_write(0x1F, 0x03);
1000 mvv_write(0x26, 0x06); 1000 mvv_write(0x26, 0x06);
1001 1001
1002 mvv_write(0x2B, 0x00); 1002 mvv_write(0x2B, 0x00);
1003 mvv_write(0x2C, 0x20); 1003 mvv_write(0x2C, 0x20);
1004 mvv_write(0x2D, 0x00); 1004 mvv_write(0x2D, 0x00);
@@ -1018,13 +1018,13 @@ static int init_mediavision(void)
1018/* 1018/*
1019 * Initialization and module stuff 1019 * Initialization and module stuff
1020 */ 1020 */
1021 1021
1022static int __init init_pms_cards(void) 1022static int __init init_pms_cards(void)
1023{ 1023{
1024 printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n"); 1024 printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n");
1025 1025
1026 data_port = io_port +1; 1026 data_port = io_port +1;
1027 1027
1028 if(init_mediavision()) 1028 if(init_mediavision())
1029 { 1029 {
1030 printk(KERN_INFO "Board not found.\n"); 1030 printk(KERN_INFO "Board not found.\n");
diff --git a/drivers/usb/media/pwc/Makefile b/drivers/media/video/pwc/Makefile
index 2d93a775011a..8326684f49f3 100644
--- a/drivers/usb/media/pwc/Makefile
+++ b/drivers/media/video/pwc/Makefile
@@ -15,6 +15,6 @@ default:
15endif 15endif
16 16
17clean: 17clean:
18 rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c 18 rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c
19 rm -rf .tmp_versions 19 rm -rf .tmp_versions
20 20
diff --git a/drivers/usb/media/pwc/philips.txt b/drivers/media/video/pwc/philips.txt
index 04a640d723ed..11f751a6bda5 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:
47size 47size
48 Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or 48 Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or
49 'vga', for an image size of resp. 128x96, 160x120, 176x144, 49 'vga', for an image size of resp. 128x96, 160x120, 176x144,
50 320x240, 352x288 and 640x480 (of course, only for those cameras that 50 320x240, 352x288 and 640x480 (of course, only for those cameras that
51 support these resolutions). 51 support these resolutions).
52 52
53fps 53fps
54 Specifies the desired framerate. Is an integer in the range of 4-30. 54 Specifies the desired framerate. Is an integer in the range of 4-30.
55 55
56fbufs 56fbufs
57 This paramter specifies the number of internal buffers to use for storing 57 This paramter specifies the number of internal buffers to use for storing
58 frames from the cam. This will help if the process that reads images from 58 frames from the cam. This will help if the process that reads images from
59 the cam is a bit slow or momentarely busy. However, on slow machines it 59 the cam is a bit slow or momentarely busy. However, on slow machines it
60 only introduces lag, so choose carefully. The default is 3, which is 60 only introduces lag, so choose carefully. The default is 3, which is
61 reasonable. You can set it between 2 and 5. 61 reasonable. You can set it between 2 and 5.
62 62
63mbufs 63mbufs
@@ -65,9 +65,9 @@ mbufs
65 buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends. 65 buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends.
66 The default is 2, which is adequate for most applications (double 66 The default is 2, which is adequate for most applications (double
67 buffering). 67 buffering).
68 68
69 Should you experience a lot of 'Dumping frame...' messages during 69 Should you experience a lot of 'Dumping frame...' messages during
70 grabbing with a tool that uses mmap(), you might want to increase if. 70 grabbing with a tool that uses mmap(), you might want to increase if.
71 However, it doesn't really buffer images, it just gives you a bit more 71 However, it doesn't really buffer images, it just gives you a bit more
72 slack when your program is behind. But you need a multi-threaded or 72 slack when your program is behind. But you need a multi-threaded or
73 forked program to really take advantage of these buffers. 73 forked program to really take advantage of these buffers.
@@ -88,15 +88,15 @@ power_save
88 88
89compression (only useful with the plugin) 89compression (only useful with the plugin)
90 With this option you can control the compression factor that the camera 90 With this option you can control the compression factor that the camera
91 uses to squeeze the image through the USB bus. You can set the 91 uses to squeeze the image through the USB bus. You can set the
92 parameter between 0 and 3: 92 parameter between 0 and 3:
93 0 = prefer uncompressed images; if the requested mode is not available 93 0 = prefer uncompressed images; if the requested mode is not available
94 in an uncompressed format, the driver will silently switch to low 94 in an uncompressed format, the driver will silently switch to low
95 compression. 95 compression.
96 1 = low compression. 96 1 = low compression.
97 2 = medium compression. 97 2 = medium compression.
98 3 = high compression. 98 3 = high compression.
99 99
100 High compression takes less bandwidth of course, but it could also 100 High compression takes less bandwidth of course, but it could also
101 introduce some unwanted artefacts. The default is 2, medium compression. 101 introduce some unwanted artefacts. The default is 2, medium compression.
102 See the FAQ on the website for an overview of which modes require 102 See the FAQ on the website for an overview of which modes require
@@ -112,7 +112,7 @@ leds
112 this is let the LED blink while the camera is in use. This: 112 this is let the LED blink while the camera is in use. This:
113 113
114 leds=500,500 114 leds=500,500
115 115
116 will blink the LED once every second. But with: 116 will blink the LED once every second. But with:
117 117
118 leds=0,0 118 leds=0,0
@@ -123,7 +123,7 @@ leds
123 when the camera is not used anymore. 123 when the camera is not used anymore.
124 124
125 This parameter works only with the ToUCam range of cameras (720, 730, 740, 125 This parameter works only with the ToUCam range of cameras (720, 730, 740,
126 750) and OEMs. For other cameras this command is silently ignored, and 126 750) and OEMs. For other cameras this command is silently ignored, and
127 the LED cannot be controlled. 127 the LED cannot be controlled.
128 128
129 Finally: this parameters does not take effect UNTIL the first time you 129 Finally: this parameters does not take effect UNTIL the first time you
@@ -144,35 +144,35 @@ dev_hint
144 format: 144 format:
145 145
146 [type[.serialnumber]:]node 146 [type[.serialnumber]:]node
147 147
148 The square brackets mean that both the type and the serialnumber are 148 The square brackets mean that both the type and the serialnumber are
149 optional, but a serialnumber cannot be specified without a type (which 149 optional, but a serialnumber cannot be specified without a type (which
150 would be rather pointless). The serialnumber is separated from the type 150 would be rather pointless). The serialnumber is separated from the type
151 by a '.'; the node number by a ':'. 151 by a '.'; the node number by a ':'.
152 152
153 This somewhat cryptic syntax is best explained by a few examples: 153 This somewhat cryptic syntax is best explained by a few examples:
154 154
155 dev_hint=3,5 The first detected cam gets assigned 155 dev_hint=3,5 The first detected cam gets assigned
156 /dev/video3, the second /dev/video5. Any 156 /dev/video3, the second /dev/video5. Any
157 other cameras will get the first free 157 other cameras will get the first free
158 available slot (see below). 158 available slot (see below).
159 159
160 dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1, 160 dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1,
161 and a PCVC680 /dev/video2. 161 and a PCVC680 /dev/video2.
162 162
163 dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber 163 dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
164 0123 goes to /dev/video3, the same 164 0123 goes to /dev/video3, the same
165 camera model with the 4567 serial 165 camera model with the 4567 serial
166 gets /dev/video0. 166 gets /dev/video0.
167 167
168 dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the 168 dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the
169 next 3 Philips cams will use /dev/video4 169 next 3 Philips cams will use /dev/video4
170 through /dev/video6. 170 through /dev/video6.
171 171
172 Some points worth knowing: 172 Some points worth knowing:
173 - Serialnumbers are case sensitive and must be written full, including 173 - Serialnumbers are case sensitive and must be written full, including
174 leading zeroes (it's treated as a string). 174 leading zeroes (it's treated as a string).
175 - If a device node is already occupied, registration will fail and 175 - If a device node is already occupied, registration will fail and
176 the webcam is not available. 176 the webcam is not available.
177 - You can have up to 64 video devices; be sure to make enough device 177 - You can have up to 64 video devices; be sure to make enough device
178 nodes in /dev if you want to spread the numbers (this does not apply 178 nodes in /dev if you want to spread the numbers (this does not apply
@@ -186,13 +186,13 @@ trace
186 kernel log at debug level. 186 kernel log at debug level.
187 187
188 The trace variable is a bitmask; each bit represents a certain feature. 188 The trace variable is a bitmask; each bit represents a certain feature.
189 If you want to trace something, look up the bit value(s) in the table 189 If you want to trace something, look up the bit value(s) in the table
190 below, add the values together and supply that to the trace variable. 190 below, add the values together and supply that to the trace variable.
191 191
192 Value Value Description Default 192 Value Value Description Default
193 (dec) (hex) 193 (dec) (hex)
194 1 0x1 Module initialization; this will log messages On 194 1 0x1 Module initialization; this will log messages On
195 while loading and unloading the module 195 while loading and unloading the module
196 196
197 2 0x2 probe() and disconnect() traces On 197 2 0x2 probe() and disconnect() traces On
198 198
@@ -203,7 +203,7 @@ trace
203 16 0x10 Memory allocation of buffers, etc. Off 203 16 0x10 Memory allocation of buffers, etc. Off
204 204
205 32 0x20 Showing underflow, overflow and Dumping frame On 205 32 0x20 Showing underflow, overflow and Dumping frame On
206 messages 206 messages
207 207
208 64 0x40 Show viewport and image sizes Off 208 64 0x40 Show viewport and image sizes Off
209 209
@@ -217,7 +217,7 @@ trace
217 217
218 218
219Example: 219Example:
220 220
221 # modprobe pwc size=cif fps=15 power_save=1 221 # modprobe pwc size=cif fps=15 power_save=1
222 222
223The fbufs, mbufs and trace parameters are global and apply to all connected 223The 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 0398b812e0ce..4ba549bfa0e0 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -31,17 +31,17 @@
31 31
32/* 32/*
33 Changes 33 Changes
34 2001/08/03 Alvarado Added methods for changing white balance and 34 2001/08/03 Alvarado Added methods for changing white balance and
35 red/green gains 35 red/green gains
36 */ 36 */
37 37
38/* Control functions for the cam; brightness, contrast, video mode, etc. */ 38/* Control functions for the cam; brightness, contrast, video mode, etc. */
39 39
40#ifdef __KERNEL__ 40#ifdef __KERNEL__
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42#endif 42#endif
43#include <asm/errno.h> 43#include <asm/errno.h>
44 44
45#include "pwc.h" 45#include "pwc.h"
46#include "pwc-ioctl.h" 46#include "pwc-ioctl.h"
47#include "pwc-uncompress.h" 47#include "pwc-uncompress.h"
@@ -116,13 +116,13 @@ static const char *size2name[PSZ_MAX] =
116 "SIF", 116 "SIF",
117 "CIF", 117 "CIF",
118 "VGA", 118 "VGA",
119}; 119};
120 120
121/********/ 121/********/
122 122
123/* Entries for the Nala (645/646) camera; the Nala doesn't have compression 123/* Entries for the Nala (645/646) camera; the Nala doesn't have compression
124 preferences, so you either get compressed or non-compressed streams. 124 preferences, so you either get compressed or non-compressed streams.
125 125
126 An alternate value of 0 means this mode is not available at all. 126 An alternate value of 0 means this mode is not available at all.
127 */ 127 */
128 128
@@ -205,13 +205,13 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
205 { /* closest match of framerate */ 205 { /* closest match of framerate */
206 0, 0, 0, 0, 4, /* 0-4 */ 206 0, 0, 0, 0, 4, /* 0-4 */
207 5, 5, 7, 7, 10, /* 5-9 */ 207 5, 5, 7, 7, 10, /* 5-9 */
208 10, 10, 12, 12, 15, /* 10-14 */ 208 10, 10, 12, 12, 15, /* 10-14 */
209 15, 15, 15, 20, 20, /* 15-19 */ 209 15, 15, 15, 20, 20, /* 15-19 */
210 20, 20, 20, 24, 24, /* 20-24 */ 210 20, 20, 20, 24, 24, /* 20-24 */
211 24, 24, 24, 24, 24, /* 25-29 */ 211 24, 24, 24, 24, 24, /* 25-29 */
212 24 /* 30 */ 212 24 /* 30 */
213 }; 213 };
214 int frames2table[31] = 214 int frames2table[31] =
215 { 0, 0, 0, 0, 0, /* 0-4 */ 215 { 0, 0, 0, 0, 0, /* 0-4 */
216 1, 1, 1, 2, 2, /* 5-9 */ 216 1, 1, 1, 2, 2, /* 5-9 */
217 3, 3, 4, 4, 4, /* 10-14 */ 217 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
220 7, 7, 7, 7, 7, /* 25-29 */ 220 7, 7, 7, 7, 7, /* 25-29 */
221 7 /* 30 */ 221 7 /* 30 */
222 }; 222 };
223 223
224 if (size < 0 || size > PSZ_CIF || frames < 4 || frames > 25) 224 if (size < 0 || size > PSZ_CIF || frames < 4 || frames > 25)
225 return -EINVAL; 225 return -EINVAL;
226 frames = frames2frames[frames]; 226 frames = frames2frames[frames];
@@ -232,7 +232,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
232 if (pEntry->compressed) 232 if (pEntry->compressed)
233 return -ENOENT; /* Not supported. */ 233 return -ENOENT; /* Not supported. */
234 234
235 memcpy(buf, pEntry->mode, 3); 235 memcpy(buf, pEntry->mode, 3);
236 ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3); 236 ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3);
237 if (ret < 0) { 237 if (ret < 0) {
238 Debug("Failed to send video command... %d\n", ret); 238 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
257 break; 257 break;
258 } 258 }
259 } 259 }
260 260
261 pdev->cmd_len = 3; 261 pdev->cmd_len = 3;
262 memcpy(pdev->cmd_buf, buf, 3); 262 memcpy(pdev->cmd_buf, buf, 3);
263 263
@@ -352,13 +352,13 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
352 /* special case: VGA @ 5 fps and snapshot is raw bayer mode */ 352 /* special case: VGA @ 5 fps and snapshot is raw bayer mode */
353 if (size == PSZ_VGA && frames == 5 && snapshot) 353 if (size == PSZ_VGA && frames == 5 && snapshot)
354 { 354 {
355 /* Only available in case the raw palette is selected or 355 /* Only available in case the raw palette is selected or
356 we have the decompressor available. This mode is 356 we have the decompressor available. This mode is
357 only available in compressed form 357 only available in compressed form
358 */ 358 */
359 if (pdev->vpalette == VIDEO_PALETTE_RAW) 359 if (pdev->vpalette == VIDEO_PALETTE_RAW)
360 { 360 {
361 Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette); 361 Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette);
362 pChoose = &RawEntry; 362 pChoose = &RawEntry;
363 } 363 }
364 else 364 else
@@ -368,9 +368,9 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
368 } 368 }
369 else 369 else
370 { 370 {
371 /* Find a supported framerate with progressively higher compression ratios 371 /* Find a supported framerate with progressively higher compression ratios
372 if the preferred ratio is not available. 372 if the preferred ratio is not available.
373 Skip this step when using RAW modes. 373 Skip this step when using RAW modes.
374 */ 374 */
375 while (compression <= 3) { 375 while (compression <= 3) {
376 pChoose = &Kiara_table[size][fps][compression]; 376 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
383 return -ENOENT; /* Not supported. */ 383 return -ENOENT; /* Not supported. */
384 384
385 Debug("Using alternate setting %d.\n", pChoose->alternate); 385 Debug("Using alternate setting %d.\n", pChoose->alternate);
386 386
387 /* usb_control_msg won't take staticly allocated arrays as argument?? */ 387 /* usb_control_msg won't take staticly allocated arrays as argument?? */
388 memcpy(buf, pChoose->mode, 12); 388 memcpy(buf, pChoose->mode, 12);
389 if (snapshot) 389 if (snapshot)
@@ -463,9 +463,9 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev)
463 */ 463 */
464int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot) 464int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot)
465{ 465{
466 int ret, size; 466 int ret, size;
467 467
468 Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette); 468 Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette);
469 size = pwc_decode_size(pdev, width, height); 469 size = pwc_decode_size(pdev, width, height);
470 if (size < 0) { 470 if (size < 0) {
471 Debug("Could not find suitable size.\n"); 471 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
473 } 473 }
474 Debug("decode_size = %d.\n", size); 474 Debug("decode_size = %d.\n", size);
475 475
476 ret = -EINVAL; 476 ret = -EINVAL;
477 switch(pdev->type) { 477 switch(pdev->type) {
478 case 645: 478 case 645:
479 case 646: 479 case 646:
@@ -485,7 +485,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
485 case 690: 485 case 690:
486 ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot); 486 ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot);
487 break; 487 break;
488 488
489 case 720: 489 case 720:
490 case 730: 490 case 730:
491 case 740: 491 case 740:
@@ -517,7 +517,7 @@ int pwc_get_brightness(struct pwc_device *pdev)
517 char buf; 517 char buf;
518 int ret; 518 int ret;
519 519
520 ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1); 520 ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
521 if (ret < 0) 521 if (ret < 0)
522 return ret; 522 return ret;
523 return buf << 9; 523 return buf << 9;
@@ -566,7 +566,7 @@ int pwc_get_gamma(struct pwc_device *pdev)
566{ 566{
567 char buf; 567 char buf;
568 int ret; 568 int ret;
569 569
570 ret = RecvControlMsg(GET_LUM_CTL, GAMMA_FORMATTER, 1); 570 ret = RecvControlMsg(GET_LUM_CTL, GAMMA_FORMATTER, 1);
571 if (ret < 0) 571 if (ret < 0)
572 return ret; 572 return ret;
@@ -622,14 +622,14 @@ static inline int pwc_set_agc(struct pwc_device *pdev, int mode, int value)
622{ 622{
623 char buf; 623 char buf;
624 int ret; 624 int ret;
625 625
626 if (mode) 626 if (mode)
627 buf = 0x0; /* auto */ 627 buf = 0x0; /* auto */
628 else 628 else
629 buf = 0xff; /* fixed */ 629 buf = 0xff; /* fixed */
630 630
631 ret = SendControlMsg(SET_LUM_CTL, AGC_MODE_FORMATTER, 1); 631 ret = SendControlMsg(SET_LUM_CTL, AGC_MODE_FORMATTER, 1);
632 632
633 if (!mode && ret >= 0) { 633 if (!mode && ret >= 0) {
634 if (value < 0) 634 if (value < 0)
635 value = 0; 635 value = 0;
@@ -647,7 +647,7 @@ static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
647{ 647{
648 unsigned char buf; 648 unsigned char buf;
649 int ret; 649 int ret;
650 650
651 ret = RecvControlMsg(GET_LUM_CTL, AGC_MODE_FORMATTER, 1); 651 ret = RecvControlMsg(GET_LUM_CTL, AGC_MODE_FORMATTER, 1);
652 if (ret < 0) 652 if (ret < 0)
653 return ret; 653 return ret;
@@ -658,7 +658,7 @@ static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
658 return ret; 658 return ret;
659 if (buf > 0x3F) 659 if (buf > 0x3F)
660 buf = 0x3F; 660 buf = 0x3F;
661 *value = (buf << 10); 661 *value = (buf << 10);
662 } 662 }
663 else { /* auto */ 663 else { /* auto */
664 ret = RecvControlMsg(GET_STATUS_CTL, READ_AGC_FORMATTER, 1); 664 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
683 buf[0] = 0x0; /* auto */ 683 buf[0] = 0x0; /* auto */
684 else 684 else
685 buf[0] = 0xff; /* fixed */ 685 buf[0] = 0xff; /* fixed */
686 686
687 ret = SendControlMsg(SET_LUM_CTL, SHUTTER_MODE_FORMATTER, 1); 687 ret = SendControlMsg(SET_LUM_CTL, SHUTTER_MODE_FORMATTER, 1);
688 688
689 if (!mode && ret >= 0) { 689 if (!mode && ret >= 0) {
@@ -713,7 +713,7 @@ static inline int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int v
713 ret = SendControlMsg(SET_LUM_CTL, PRESET_SHUTTER_FORMATTER, 2); 713 ret = SendControlMsg(SET_LUM_CTL, PRESET_SHUTTER_FORMATTER, 2);
714 } 714 }
715 return ret; 715 return ret;
716} 716}
717 717
718 718
719/* POWER */ 719/* POWER */
@@ -765,22 +765,22 @@ static inline int pwc_restore_factory(struct pwc_device *pdev)
765 * 02: fluorescent lighting 765 * 02: fluorescent lighting
766 * 03: manual 766 * 03: manual
767 * 04: auto 767 * 04: auto
768 */ 768 */
769static inline int pwc_set_awb(struct pwc_device *pdev, int mode) 769static inline int pwc_set_awb(struct pwc_device *pdev, int mode)
770{ 770{
771 char buf; 771 char buf;
772 int ret; 772 int ret;
773 773
774 if (mode < 0) 774 if (mode < 0)
775 mode = 0; 775 mode = 0;
776 776
777 if (mode > 4) 777 if (mode > 4)
778 mode = 4; 778 mode = 4;
779 779
780 buf = mode & 0x07; /* just the lowest three bits */ 780 buf = mode & 0x07; /* just the lowest three bits */
781 781
782 ret = SendControlMsg(SET_CHROM_CTL, WB_MODE_FORMATTER, 1); 782 ret = SendControlMsg(SET_CHROM_CTL, WB_MODE_FORMATTER, 1);
783 783
784 if (ret < 0) 784 if (ret < 0)
785 return ret; 785 return ret;
786 return 0; 786 return 0;
@@ -790,17 +790,17 @@ static inline int pwc_get_awb(struct pwc_device *pdev)
790{ 790{
791 unsigned char buf; 791 unsigned char buf;
792 int ret; 792 int ret;
793 793
794 ret = RecvControlMsg(GET_CHROM_CTL, WB_MODE_FORMATTER, 1); 794 ret = RecvControlMsg(GET_CHROM_CTL, WB_MODE_FORMATTER, 1);
795 795
796 if (ret < 0) 796 if (ret < 0)
797 return ret; 797 return ret;
798 return buf; 798 return buf;
799} 799}
800 800
801static inline int pwc_set_red_gain(struct pwc_device *pdev, int value) 801static inline int pwc_set_red_gain(struct pwc_device *pdev, int value)
802{ 802{
803 unsigned char buf; 803 unsigned char buf;
804 804
805 if (value < 0) 805 if (value < 0)
806 value = 0; 806 value = 0;
@@ -815,7 +815,7 @@ static inline int pwc_get_red_gain(struct pwc_device *pdev, int *value)
815{ 815{
816 unsigned char buf; 816 unsigned char buf;
817 int ret; 817 int ret;
818 818
819 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1); 819 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1);
820 if (ret < 0) 820 if (ret < 0)
821 return ret; 821 return ret;
@@ -841,7 +841,7 @@ static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
841{ 841{
842 unsigned char buf; 842 unsigned char buf;
843 int ret; 843 int ret;
844 844
845 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1); 845 ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1);
846 if (ret < 0) 846 if (ret < 0)
847 return ret; 847 return ret;
@@ -851,14 +851,14 @@ static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
851 851
852 852
853/* The following two functions are different, since they only read the 853/* The following two functions are different, since they only read the
854 internal red/blue gains, which may be different from the manual 854 internal red/blue gains, which may be different from the manual
855 gains set or read above. 855 gains set or read above.
856 */ 856 */
857static inline int pwc_read_red_gain(struct pwc_device *pdev, int *value) 857static inline int pwc_read_red_gain(struct pwc_device *pdev, int *value)
858{ 858{
859 unsigned char buf; 859 unsigned char buf;
860 int ret; 860 int ret;
861 861
862 ret = RecvControlMsg(GET_STATUS_CTL, READ_RED_GAIN_FORMATTER, 1); 862 ret = RecvControlMsg(GET_STATUS_CTL, READ_RED_GAIN_FORMATTER, 1);
863 if (ret < 0) 863 if (ret < 0)
864 return ret; 864 return ret;
@@ -870,7 +870,7 @@ static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
870{ 870{
871 unsigned char buf; 871 unsigned char buf;
872 int ret; 872 int ret;
873 873
874 ret = RecvControlMsg(GET_STATUS_CTL, READ_BLUE_GAIN_FORMATTER, 1); 874 ret = RecvControlMsg(GET_STATUS_CTL, READ_BLUE_GAIN_FORMATTER, 1);
875 if (ret < 0) 875 if (ret < 0)
876 return ret; 876 return ret;
@@ -882,7 +882,7 @@ static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
882static inline int pwc_set_wb_speed(struct pwc_device *pdev, int speed) 882static inline int pwc_set_wb_speed(struct pwc_device *pdev, int speed)
883{ 883{
884 unsigned char buf; 884 unsigned char buf;
885 885
886 /* useful range is 0x01..0x20 */ 886 /* useful range is 0x01..0x20 */
887 buf = speed / 0x7f0; 887 buf = speed / 0x7f0;
888 return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1); 888 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)
892{ 892{
893 unsigned char buf; 893 unsigned char buf;
894 int ret; 894 int ret;
895 895
896 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1); 896 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
897 if (ret < 0) 897 if (ret < 0)
898 return ret; 898 return ret;
@@ -904,7 +904,7 @@ static inline int pwc_get_wb_speed(struct pwc_device *pdev, int *value)
904static inline int pwc_set_wb_delay(struct pwc_device *pdev, int delay) 904static inline int pwc_set_wb_delay(struct pwc_device *pdev, int delay)
905{ 905{
906 unsigned char buf; 906 unsigned char buf;
907 907
908 /* useful range is 0x01..0x3F */ 908 /* useful range is 0x01..0x3F */
909 buf = (delay >> 10); 909 buf = (delay >> 10);
910 return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1); 910 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)
914{ 914{
915 unsigned char buf; 915 unsigned char buf;
916 int ret; 916 int ret;
917 917
918 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1); 918 ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
919 if (ret < 0) 919 if (ret < 0)
920 return ret; 920 return ret;
@@ -950,7 +950,7 @@ static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
950{ 950{
951 unsigned char buf[2]; 951 unsigned char buf[2];
952 int ret; 952 int ret;
953 953
954 if (pdev->type < 730) { 954 if (pdev->type < 730) {
955 *on_value = -1; 955 *on_value = -1;
956 *off_value = -1; 956 *off_value = -1;
@@ -969,7 +969,7 @@ static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
969{ 969{
970 unsigned char buf; 970 unsigned char buf;
971 int ret; 971 int ret;
972 972
973 if (contour < 0) 973 if (contour < 0)
974 buf = 0xff; /* auto contour on */ 974 buf = 0xff; /* auto contour on */
975 else 975 else
@@ -977,16 +977,16 @@ static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
977 ret = SendControlMsg(SET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1); 977 ret = SendControlMsg(SET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
978 if (ret < 0) 978 if (ret < 0)
979 return ret; 979 return ret;
980 980
981 if (contour < 0) 981 if (contour < 0)
982 return 0; 982 return 0;
983 if (contour > 0xffff) 983 if (contour > 0xffff)
984 contour = 0xffff; 984 contour = 0xffff;
985 985
986 buf = (contour >> 10); /* contour preset is [0..3f] */ 986 buf = (contour >> 10); /* contour preset is [0..3f] */
987 ret = SendControlMsg(SET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1); 987 ret = SendControlMsg(SET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
988 if (ret < 0) 988 if (ret < 0)
989 return ret; 989 return ret;
990 return 0; 990 return 0;
991} 991}
992 992
@@ -994,7 +994,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
994{ 994{
995 unsigned char buf; 995 unsigned char buf;
996 int ret; 996 int ret;
997 997
998 ret = RecvControlMsg(GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1); 998 ret = RecvControlMsg(GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
999 if (ret < 0) 999 if (ret < 0)
1000 return ret; 1000 return ret;
@@ -1002,7 +1002,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
1002 if (buf == 0) { 1002 if (buf == 0) {
1003 /* auto mode off, query current preset value */ 1003 /* auto mode off, query current preset value */
1004 ret = RecvControlMsg(GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1); 1004 ret = RecvControlMsg(GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
1005 if (ret < 0) 1005 if (ret < 0)
1006 return ret; 1006 return ret;
1007 *contour = buf << 10; 1007 *contour = buf << 10;
1008 } 1008 }
@@ -1015,7 +1015,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
1015static inline int pwc_set_backlight(struct pwc_device *pdev, int backlight) 1015static inline int pwc_set_backlight(struct pwc_device *pdev, int backlight)
1016{ 1016{
1017 unsigned char buf; 1017 unsigned char buf;
1018 1018
1019 if (backlight) 1019 if (backlight)
1020 buf = 0xff; 1020 buf = 0xff;
1021 else 1021 else
@@ -1027,7 +1027,7 @@ static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
1027{ 1027{
1028 int ret; 1028 int ret;
1029 unsigned char buf; 1029 unsigned char buf;
1030 1030
1031 ret = RecvControlMsg(GET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1); 1031 ret = RecvControlMsg(GET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1);
1032 if (ret < 0) 1032 if (ret < 0)
1033 return ret; 1033 return ret;
@@ -1039,7 +1039,7 @@ static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
1039static inline int pwc_set_flicker(struct pwc_device *pdev, int flicker) 1039static inline int pwc_set_flicker(struct pwc_device *pdev, int flicker)
1040{ 1040{
1041 unsigned char buf; 1041 unsigned char buf;
1042 1042
1043 if (flicker) 1043 if (flicker)
1044 buf = 0xff; 1044 buf = 0xff;
1045 else 1045 else
@@ -1051,7 +1051,7 @@ static inline int pwc_get_flicker(struct pwc_device *pdev, int *flicker)
1051{ 1051{
1052 int ret; 1052 int ret;
1053 unsigned char buf; 1053 unsigned char buf;
1054 1054
1055 ret = RecvControlMsg(GET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1); 1055 ret = RecvControlMsg(GET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1);
1056 if (ret < 0) 1056 if (ret < 0)
1057 return ret; 1057 return ret;
@@ -1076,7 +1076,7 @@ static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
1076{ 1076{
1077 int ret; 1077 int ret;
1078 unsigned char buf; 1078 unsigned char buf;
1079 1079
1080 ret = RecvControlMsg(GET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1); 1080 ret = RecvControlMsg(GET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1);
1081 if (ret < 0) 1081 if (ret < 0)
1082 return ret; 1082 return ret;
@@ -1087,7 +1087,7 @@ static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
1087static int pwc_mpt_reset(struct pwc_device *pdev, int flags) 1087static int pwc_mpt_reset(struct pwc_device *pdev, int flags)
1088{ 1088{
1089 unsigned char buf; 1089 unsigned char buf;
1090 1090
1091 buf = flags & 0x03; // only lower two bits are currently used 1091 buf = flags & 0x03; // only lower two bits are currently used
1092 return SendControlMsg(SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, 1); 1092 return SendControlMsg(SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, 1);
1093} 1093}
@@ -1095,7 +1095,7 @@ static int pwc_mpt_reset(struct pwc_device *pdev, int flags)
1095static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt) 1095static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
1096{ 1096{
1097 unsigned char buf[4]; 1097 unsigned char buf[4];
1098 1098
1099 /* set new relative angle; angles are expressed in degrees * 100, 1099 /* set new relative angle; angles are expressed in degrees * 100,
1100 but cam as .5 degree resolution, hence divide by 200. Also 1100 but cam as .5 degree resolution, hence divide by 200. Also
1101 the angle must be multiplied by 64 before it's send to 1101 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
1114{ 1114{
1115 int ret; 1115 int ret;
1116 unsigned char buf[5]; 1116 unsigned char buf[5];
1117 1117
1118 ret = RecvControlMsg(GET_MPT_CTL, PT_STATUS_FORMATTER, 5); 1118 ret = RecvControlMsg(GET_MPT_CTL, PT_STATUS_FORMATTER, 5);
1119 if (ret < 0) 1119 if (ret < 0)
1120 return ret; 1120 return ret;
@@ -1129,14 +1129,14 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
1129{ 1129{
1130 unsigned char buf; 1130 unsigned char buf;
1131 int ret = -1, request; 1131 int ret = -1, request;
1132 1132
1133 if (pdev->type < 675) 1133 if (pdev->type < 675)
1134 request = SENSOR_TYPE_FORMATTER1; 1134 request = SENSOR_TYPE_FORMATTER1;
1135 else if (pdev->type < 730) 1135 else if (pdev->type < 730)
1136 return -1; /* The Vesta series doesn't have this call */ 1136 return -1; /* The Vesta series doesn't have this call */
1137 else 1137 else
1138 request = SENSOR_TYPE_FORMATTER2; 1138 request = SENSOR_TYPE_FORMATTER2;
1139 1139
1140 ret = RecvControlMsg(GET_STATUS_CTL, request, 1); 1140 ret = RecvControlMsg(GET_STATUS_CTL, request, 1);
1141 if (ret < 0) 1141 if (ret < 0)
1142 return ret; 1142 return ret;
@@ -1163,23 +1163,23 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1163 ret = -EINVAL; 1163 ret = -EINVAL;
1164 break; 1164 break;
1165 } 1165 }
1166 1166
1167 case VIDIOCPWCSUSER: 1167 case VIDIOCPWCSUSER:
1168 { 1168 {
1169 if (pwc_save_user(pdev)) 1169 if (pwc_save_user(pdev))
1170 ret = -EINVAL; 1170 ret = -EINVAL;
1171 break; 1171 break;
1172 } 1172 }
1173 1173
1174 case VIDIOCPWCFACTORY: 1174 case VIDIOCPWCFACTORY:
1175 { 1175 {
1176 if (pwc_restore_factory(pdev)) 1176 if (pwc_restore_factory(pdev))
1177 ret = -EINVAL; 1177 ret = -EINVAL;
1178 break; 1178 break;
1179 } 1179 }
1180 1180
1181 case VIDIOCPWCSCQUAL: 1181 case VIDIOCPWCSCQUAL:
1182 { 1182 {
1183 int *qual = arg; 1183 int *qual = arg;
1184 1184
1185 if (*qual < 0 || *qual > 3) 1185 if (*qual < 0 || *qual > 3)
@@ -1190,14 +1190,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1190 pdev->vcompression = *qual; 1190 pdev->vcompression = *qual;
1191 break; 1191 break;
1192 } 1192 }
1193 1193
1194 case VIDIOCPWCGCQUAL: 1194 case VIDIOCPWCGCQUAL:
1195 { 1195 {
1196 int *qual = arg; 1196 int *qual = arg;
1197 *qual = pdev->vcompression; 1197 *qual = pdev->vcompression;
1198 break; 1198 break;
1199 } 1199 }
1200 1200
1201 case VIDIOCPWCPROBE: 1201 case VIDIOCPWCPROBE:
1202 { 1202 {
1203 struct pwc_probe *probe = arg; 1203 struct pwc_probe *probe = arg;
@@ -1220,27 +1220,27 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1220 ret = -EINVAL; 1220 ret = -EINVAL;
1221 break; 1221 break;
1222 } 1222 }
1223 1223
1224 case VIDIOCPWCGAGC: 1224 case VIDIOCPWCGAGC:
1225 { 1225 {
1226 int *agc = arg; 1226 int *agc = arg;
1227 1227
1228 if (pwc_get_agc(pdev, agc)) 1228 if (pwc_get_agc(pdev, agc))
1229 ret = -EINVAL; 1229 ret = -EINVAL;
1230 break; 1230 break;
1231 } 1231 }
1232 1232
1233 case VIDIOCPWCSSHUTTER: 1233 case VIDIOCPWCSSHUTTER:
1234 { 1234 {
1235 int *shutter_speed = arg; 1235 int *shutter_speed = arg;
1236 ret = pwc_set_shutter_speed(pdev, *shutter_speed < 0 ? 1 : 0, *shutter_speed); 1236 ret = pwc_set_shutter_speed(pdev, *shutter_speed < 0 ? 1 : 0, *shutter_speed);
1237 break; 1237 break;
1238 } 1238 }
1239 1239
1240 case VIDIOCPWCSAWB: 1240 case VIDIOCPWCSAWB:
1241 { 1241 {
1242 struct pwc_whitebalance *wb = arg; 1242 struct pwc_whitebalance *wb = arg;
1243 1243
1244 ret = pwc_set_awb(pdev, wb->mode); 1244 ret = pwc_set_awb(pdev, wb->mode);
1245 if (ret >= 0 && wb->mode == PWC_WB_MANUAL) { 1245 if (ret >= 0 && wb->mode == PWC_WB_MANUAL) {
1246 pwc_set_red_gain(pdev, wb->manual_red); 1246 pwc_set_red_gain(pdev, wb->manual_red);
@@ -1270,18 +1270,18 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1270 ret = pwc_read_red_gain(pdev, &wb->read_red); 1270 ret = pwc_read_red_gain(pdev, &wb->read_red);
1271 if (ret < 0) 1271 if (ret < 0)
1272 break; 1272 break;
1273 ret = pwc_read_blue_gain(pdev, &wb->read_blue); 1273 ret = pwc_read_blue_gain(pdev, &wb->read_blue);
1274 if (ret < 0) 1274 if (ret < 0)
1275 break; 1275 break;
1276 } 1276 }
1277 } 1277 }
1278 break; 1278 break;
1279 } 1279 }
1280 1280
1281 case VIDIOCPWCSAWBSPEED: 1281 case VIDIOCPWCSAWBSPEED:
1282 { 1282 {
1283 struct pwc_wb_speed *wbs = arg; 1283 struct pwc_wb_speed *wbs = arg;
1284 1284
1285 if (wbs->control_speed > 0) { 1285 if (wbs->control_speed > 0) {
1286 ret = pwc_set_wb_speed(pdev, wbs->control_speed); 1286 ret = pwc_set_wb_speed(pdev, wbs->control_speed);
1287 } 1287 }
@@ -1290,11 +1290,11 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1290 } 1290 }
1291 break; 1291 break;
1292 } 1292 }
1293 1293
1294 case VIDIOCPWCGAWBSPEED: 1294 case VIDIOCPWCGAWBSPEED:
1295 { 1295 {
1296 struct pwc_wb_speed *wbs = arg; 1296 struct pwc_wb_speed *wbs = arg;
1297 1297
1298 ret = pwc_get_wb_speed(pdev, &wbs->control_speed); 1298 ret = pwc_get_wb_speed(pdev, &wbs->control_speed);
1299 if (ret < 0) 1299 if (ret < 0)
1300 break; 1300 break;
@@ -1304,7 +1304,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1304 break; 1304 break;
1305 } 1305 }
1306 1306
1307 case VIDIOCPWCSLED: 1307 case VIDIOCPWCSLED:
1308 { 1308 {
1309 struct pwc_leds *leds = arg; 1309 struct pwc_leds *leds = arg;
1310 ret = pwc_set_leds(pdev, leds->led_on, leds->led_off); 1310 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)
1325 ret = pwc_set_contour(pdev, *contour); 1325 ret = pwc_set_contour(pdev, *contour);
1326 break; 1326 break;
1327 } 1327 }
1328 1328
1329 case VIDIOCPWCGCONTOUR: 1329 case VIDIOCPWCGCONTOUR:
1330 { 1330 {
1331 int *contour = arg; 1331 int *contour = arg;
1332 ret = pwc_get_contour(pdev, contour); 1332 ret = pwc_get_contour(pdev, contour);
1333 break; 1333 break;
1334 } 1334 }
1335 1335
1336 case VIDIOCPWCSBACKLIGHT: 1336 case VIDIOCPWCSBACKLIGHT:
1337 { 1337 {
1338 int *backlight = arg; 1338 int *backlight = arg;
@@ -1346,7 +1346,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1346 ret = pwc_get_backlight(pdev, backlight); 1346 ret = pwc_get_backlight(pdev, backlight);
1347 break; 1347 break;
1348 } 1348 }
1349 1349
1350 case VIDIOCPWCSFLICKER: 1350 case VIDIOCPWCSFLICKER:
1351 { 1351 {
1352 int *flicker = arg; 1352 int *flicker = arg;
@@ -1360,14 +1360,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1360 ret = pwc_get_flicker(pdev, flicker); 1360 ret = pwc_get_flicker(pdev, flicker);
1361 break; 1361 break;
1362 } 1362 }
1363 1363
1364 case VIDIOCPWCSDYNNOISE: 1364 case VIDIOCPWCSDYNNOISE:
1365 { 1365 {
1366 int *dynnoise = arg; 1366 int *dynnoise = arg;
1367 ret = pwc_set_dynamic_noise(pdev, *dynnoise); 1367 ret = pwc_set_dynamic_noise(pdev, *dynnoise);
1368 break; 1368 break;
1369 } 1369 }
1370 1370
1371 case VIDIOCPWCGDYNNOISE: 1371 case VIDIOCPWCGDYNNOISE:
1372 { 1372 {
1373 int *dynnoise = arg; 1373 int *dynnoise = arg;
@@ -1381,61 +1381,61 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1381 size->width = pdev->image.x; 1381 size->width = pdev->image.x;
1382 size->height = pdev->image.y; 1382 size->height = pdev->image.y;
1383 break; 1383 break;
1384 } 1384 }
1385 1385
1386 case VIDIOCPWCMPTRESET: 1386 case VIDIOCPWCMPTRESET:
1387 { 1387 {
1388 if (pdev->features & FEATURE_MOTOR_PANTILT) 1388 if (pdev->features & FEATURE_MOTOR_PANTILT)
1389 { 1389 {
1390 int *flags = arg; 1390 int *flags = arg;
1391 1391
1392 ret = pwc_mpt_reset(pdev, *flags); 1392 ret = pwc_mpt_reset(pdev, *flags);
1393 if (ret >= 0) 1393 if (ret >= 0)
1394 { 1394 {
1395 pdev->pan_angle = 0; 1395 pdev->pan_angle = 0;
1396 pdev->tilt_angle = 0; 1396 pdev->tilt_angle = 0;
1397 } 1397 }
1398 } 1398 }
1399 else 1399 else
1400 { 1400 {
1401 ret = -ENXIO; 1401 ret = -ENXIO;
1402 } 1402 }
1403 break; 1403 break;
1404 } 1404 }
1405 1405
1406 case VIDIOCPWCMPTGRANGE: 1406 case VIDIOCPWCMPTGRANGE:
1407 { 1407 {
1408 if (pdev->features & FEATURE_MOTOR_PANTILT) 1408 if (pdev->features & FEATURE_MOTOR_PANTILT)
1409 { 1409 {
1410 struct pwc_mpt_range *range = arg; 1410 struct pwc_mpt_range *range = arg;
1411 *range = pdev->angle_range; 1411 *range = pdev->angle_range;
1412 } 1412 }
1413 else 1413 else
1414 { 1414 {
1415 ret = -ENXIO; 1415 ret = -ENXIO;
1416 } 1416 }
1417 break; 1417 break;
1418 } 1418 }
1419 1419
1420 case VIDIOCPWCMPTSANGLE: 1420 case VIDIOCPWCMPTSANGLE:
1421 { 1421 {
1422 int new_pan, new_tilt; 1422 int new_pan, new_tilt;
1423 1423
1424 if (pdev->features & FEATURE_MOTOR_PANTILT) 1424 if (pdev->features & FEATURE_MOTOR_PANTILT)
1425 { 1425 {
1426 struct pwc_mpt_angles *angles = arg; 1426 struct pwc_mpt_angles *angles = arg;
1427 /* The camera can only set relative angles, so 1427 /* The camera can only set relative angles, so
1428 do some calculations when getting an absolute angle . 1428 do some calculations when getting an absolute angle .
1429 */ 1429 */
1430 if (angles->absolute) 1430 if (angles->absolute)
1431 { 1431 {
1432 new_pan = angles->pan; 1432 new_pan = angles->pan;
1433 new_tilt = angles->tilt; 1433 new_tilt = angles->tilt;
1434 } 1434 }
1435 else 1435 else
1436 { 1436 {
1437 new_pan = pdev->pan_angle + angles->pan; 1437 new_pan = pdev->pan_angle + angles->pan;
1438 new_tilt = pdev->tilt_angle + angles->tilt; 1438 new_tilt = pdev->tilt_angle + angles->tilt;
1439 } 1439 }
1440 /* check absolute ranges */ 1440 /* check absolute ranges */
1441 if (new_pan < pdev->angle_range.pan_min || 1441 if (new_pan < pdev->angle_range.pan_min ||
@@ -1463,53 +1463,53 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1463 pdev->tilt_angle += new_tilt; 1463 pdev->tilt_angle += new_tilt;
1464 } 1464 }
1465 if (ret == -EPIPE) /* stall -> out of range */ 1465 if (ret == -EPIPE) /* stall -> out of range */
1466 ret = -ERANGE; 1466 ret = -ERANGE;
1467 } 1467 }
1468 } 1468 }
1469 else 1469 else
1470 { 1470 {
1471 ret = -ENXIO; 1471 ret = -ENXIO;
1472 } 1472 }
1473 break; 1473 break;
1474 } 1474 }
1475 1475
1476 case VIDIOCPWCMPTGANGLE: 1476 case VIDIOCPWCMPTGANGLE:
1477 { 1477 {
1478 1478
1479 if (pdev->features & FEATURE_MOTOR_PANTILT) 1479 if (pdev->features & FEATURE_MOTOR_PANTILT)
1480 { 1480 {
1481 struct pwc_mpt_angles *angles = arg; 1481 struct pwc_mpt_angles *angles = arg;
1482 1482
1483 angles->absolute = 1; 1483 angles->absolute = 1;
1484 angles->pan = pdev->pan_angle; 1484 angles->pan = pdev->pan_angle;
1485 angles->tilt = pdev->tilt_angle; 1485 angles->tilt = pdev->tilt_angle;
1486 } 1486 }
1487 else 1487 else
1488 { 1488 {
1489 ret = -ENXIO; 1489 ret = -ENXIO;
1490 } 1490 }
1491 break; 1491 break;
1492 } 1492 }
1493 1493
1494 case VIDIOCPWCMPTSTATUS: 1494 case VIDIOCPWCMPTSTATUS:
1495 { 1495 {
1496 if (pdev->features & FEATURE_MOTOR_PANTILT) 1496 if (pdev->features & FEATURE_MOTOR_PANTILT)
1497 { 1497 {
1498 struct pwc_mpt_status *status = arg; 1498 struct pwc_mpt_status *status = arg;
1499 ret = pwc_mpt_get_status(pdev, status); 1499 ret = pwc_mpt_get_status(pdev, status);
1500 } 1500 }
1501 else 1501 else
1502 { 1502 {
1503 ret = -ENXIO; 1503 ret = -ENXIO;
1504 } 1504 }
1505 break; 1505 break;
1506 } 1506 }
1507 1507
1508 case VIDIOCPWCGVIDCMD: 1508 case VIDIOCPWCGVIDCMD:
1509 { 1509 {
1510 struct pwc_video_command *cmd = arg; 1510 struct pwc_video_command *cmd = arg;
1511 1511
1512 cmd->type = pdev->type; 1512 cmd->type = pdev->type;
1513 cmd->release = pdev->release; 1513 cmd->release = pdev->release;
1514 cmd->command_len = pdev->cmd_len; 1514 cmd->command_len = pdev->cmd_len;
1515 memcpy(&cmd->command_buf, pdev->cmd_buf, pdev->cmd_len); 1515 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)
1531 ret = -ENOIOCTLCMD; 1531 ret = -ENOIOCTLCMD;
1532 break; 1532 break;
1533 } 1533 }
1534 1534
1535 if (ret > 0) 1535 if (ret > 0)
1536 return 0; 1536 return 0;
1537 return ret; 1537 return ret;
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 90eb26042817..41418294a32b 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -25,18 +25,18 @@
25 25
26*/ 26*/
27 27
28/* 28/*
29 This code forms the interface between the USB layers and the Philips 29 This code forms the interface between the USB layers and the Philips
30 specific stuff. Some adanved stuff of the driver falls under an 30 specific stuff. Some adanved stuff of the driver falls under an
31 NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and 31 NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and
32 is thus not distributed in source form. The binary pwcx.o module 32 is thus not distributed in source form. The binary pwcx.o module
33 contains the code that falls under the NDA. 33 contains the code that falls under the NDA.
34 34
35 In case you're wondering: 'pwc' stands for "Philips WebCam", but 35 In case you're wondering: 'pwc' stands for "Philips WebCam", but
36 I really didn't want to type 'philips_web_cam' every time (I'm lazy as 36 I really didn't want to type 'philips_web_cam' every time (I'm lazy as
37 any Linux kernel hacker, but I don't like uncomprehensible abbreviations 37 any Linux kernel hacker, but I don't like uncomprehensible abbreviations
38 without explanation). 38 without explanation).
39 39
40 Oh yes, convention: to disctinguish between all the various pointers to 40 Oh yes, convention: to disctinguish between all the various pointers to
41 device-structures, I use these names for the pointer variables: 41 device-structures, I use these names for the pointer variables:
42 udev: struct usb_device * 42 udev: struct usb_device *
@@ -170,14 +170,14 @@ static struct video_device pwc_template = {
170 170
171/* Okay, this is some magic that I worked out and the reasoning behind it... 171/* Okay, this is some magic that I worked out and the reasoning behind it...
172 172
173 The biggest problem with any USB device is of course: "what to do 173 The biggest problem with any USB device is of course: "what to do
174 when the user unplugs the device while it is in use by an application?" 174 when the user unplugs the device while it is in use by an application?"
175 We have several options: 175 We have several options:
176 1) Curse them with the 7 plagues when they do (requires divine intervention) 176 1) Curse them with the 7 plagues when they do (requires divine intervention)
177 2) Tell them not to (won't work: they'll do it anyway) 177 2) Tell them not to (won't work: they'll do it anyway)
178 3) Oops the kernel (this will have a negative effect on a user's uptime) 178 3) Oops the kernel (this will have a negative effect on a user's uptime)
179 4) Do something sensible. 179 4) Do something sensible.
180 180
181 Of course, we go for option 4. 181 Of course, we go for option 4.
182 182
183 It happens that this device will be linked to two times, once from 183 It happens that this device will be linked to two times, once from
@@ -185,15 +185,15 @@ static struct video_device pwc_template = {
185 pointers. This is done when the device is probed() and all initialization 185 pointers. This is done when the device is probed() and all initialization
186 succeeded. The pwc_device struct links back to both structures. 186 succeeded. The pwc_device struct links back to both structures.
187 187
188 When a device is unplugged while in use it will be removed from the 188 When a device is unplugged while in use it will be removed from the
189 list of known USB devices; I also de-register it as a V4L device, but 189 list of known USB devices; I also de-register it as a V4L device, but
190 unfortunately I can't free the memory since the struct is still in use 190 unfortunately I can't free the memory since the struct is still in use
191 by the file descriptor. This free-ing is then deferend until the first 191 by the file descriptor. This free-ing is then deferend until the first
192 opportunity. Crude, but it works. 192 opportunity. Crude, but it works.
193 193
194 A small 'advantage' is that if a user unplugs the cam and plugs it back 194 A small 'advantage' is that if a user unplugs the cam and plugs it back
195 in, it should get assigned the same video device minor, but unfortunately 195 in, it should get assigned the same video device minor, but unfortunately
196 it's non-trivial to re-link the cam back to the video device... (that 196 it's non-trivial to re-link the cam back to the video device... (that
197 would surely be magic! :)) 197 would surely be magic! :))
198*/ 198*/
199 199
@@ -203,14 +203,14 @@ static struct video_device pwc_template = {
203/* Here we want the physical address of the memory. 203/* Here we want the physical address of the memory.
204 * This is used when initializing the contents of the area. 204 * This is used when initializing the contents of the area.
205 */ 205 */
206static inline unsigned long kvirt_to_pa(unsigned long adr) 206static inline unsigned long kvirt_to_pa(unsigned long adr)
207{ 207{
208 unsigned long kva, ret; 208 unsigned long kva, ret;
209 209
210 kva = (unsigned long) page_address(vmalloc_to_page((void *)adr)); 210 kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
211 kva |= adr & (PAGE_SIZE-1); /* restore the offset */ 211 kva |= adr & (PAGE_SIZE-1); /* restore the offset */
212 ret = __pa(kva); 212 ret = __pa(kva);
213 return ret; 213 return ret;
214} 214}
215 215
216static void * rvmalloc(unsigned long size) 216static void * rvmalloc(unsigned long size)
@@ -219,13 +219,13 @@ static void * rvmalloc(unsigned long size)
219 unsigned long adr; 219 unsigned long adr;
220 220
221 size=PAGE_ALIGN(size); 221 size=PAGE_ALIGN(size);
222 mem=vmalloc_32(size); 222 mem=vmalloc_32(size);
223 if (mem) 223 if (mem)
224 { 224 {
225 memset(mem, 0, size); /* Clear the ram out, no junk to the user */ 225 memset(mem, 0, size); /* Clear the ram out, no junk to the user */
226 adr=(unsigned long) mem; 226 adr=(unsigned long) mem;
227 while (size > 0) 227 while (size > 0)
228 { 228 {
229 SetPageReserved(vmalloc_to_page((void *)adr)); 229 SetPageReserved(vmalloc_to_page((void *)adr));
230 adr+=PAGE_SIZE; 230 adr+=PAGE_SIZE;
231 size-=PAGE_SIZE; 231 size-=PAGE_SIZE;
@@ -236,13 +236,13 @@ static void * rvmalloc(unsigned long size)
236 236
237static void rvfree(void * mem, unsigned long size) 237static void rvfree(void * mem, unsigned long size)
238{ 238{
239 unsigned long adr; 239 unsigned long adr;
240 240
241 if (mem) 241 if (mem)
242 { 242 {
243 adr=(unsigned long) mem; 243 adr=(unsigned long) mem;
244 while ((long) size > 0) 244 while ((long) size > 0)
245 { 245 {
246 ClearPageReserved(vmalloc_to_page((void *)adr)); 246 ClearPageReserved(vmalloc_to_page((void *)adr));
247 adr+=PAGE_SIZE; 247 adr+=PAGE_SIZE;
248 size-=PAGE_SIZE; 248 size-=PAGE_SIZE;
@@ -263,13 +263,13 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
263 263
264 if (pdev == NULL) 264 if (pdev == NULL)
265 return -ENXIO; 265 return -ENXIO;
266 266
267#ifdef PWC_MAGIC 267#ifdef PWC_MAGIC
268 if (pdev->magic != PWC_MAGIC) { 268 if (pdev->magic != PWC_MAGIC) {
269 Err("allocate_buffers(): magic failed.\n"); 269 Err("allocate_buffers(): magic failed.\n");
270 return -ENXIO; 270 return -ENXIO;
271 } 271 }
272#endif 272#endif
273 /* Allocate Isochronous pipe buffers */ 273 /* Allocate Isochronous pipe buffers */
274 for (i = 0; i < MAX_ISO_BUFS; i++) { 274 for (i = 0; i < MAX_ISO_BUFS; i++) {
275 if (pdev->sbuf[i].data == NULL) { 275 if (pdev->sbuf[i].data == NULL) {
@@ -308,7 +308,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
308 memset(kbuf, 128, PWC_FRAME_SIZE); 308 memset(kbuf, 128, PWC_FRAME_SIZE);
309 } 309 }
310 } 310 }
311 311
312 /* Allocate decompressor table space */ 312 /* Allocate decompressor table space */
313 kbuf = NULL; 313 kbuf = NULL;
314 switch (pdev->type) 314 switch (pdev->type)
@@ -320,7 +320,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
320 case 730: 320 case 730:
321 case 740: 321 case 740:
322 case 750: 322 case 750:
323#if 0 323#if 0
324 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private)); 324 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
325 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */ 325 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */
326 break; 326 break;
@@ -329,11 +329,11 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
329 /* TODO & FIXME */ 329 /* TODO & FIXME */
330 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); 330 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
331 break; 331 break;
332#endif 332#endif
333 ; 333 ;
334 } 334 }
335 pdev->decompress_data = kbuf; 335 pdev->decompress_data = kbuf;
336 336
337 /* Allocate image buffer; double buffer for mmap() */ 337 /* Allocate image buffer; double buffer for mmap() */
338 kbuf = rvmalloc(default_mbufs * pdev->len_per_image); 338 kbuf = rvmalloc(default_mbufs * pdev->len_per_image);
339 if (kbuf == NULL) { 339 if (kbuf == NULL) {
@@ -348,7 +348,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
348 pdev->image_ptr[i] = NULL; 348 pdev->image_ptr[i] = NULL;
349 349
350 kbuf = NULL; 350 kbuf = NULL;
351 351
352 Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n"); 352 Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n");
353 return 0; 353 return 0;
354} 354}
@@ -366,7 +366,7 @@ static void pwc_free_buffers(struct pwc_device *pdev)
366 Err("free_buffers(): magic failed.\n"); 366 Err("free_buffers(): magic failed.\n");
367 return; 367 return;
368 } 368 }
369#endif 369#endif
370 370
371 /* Release Iso-pipe buffers */ 371 /* Release Iso-pipe buffers */
372 for (i = 0; i < MAX_ISO_BUFS; i++) 372 for (i = 0; i < MAX_ISO_BUFS; i++)
@@ -403,17 +403,17 @@ static void pwc_free_buffers(struct pwc_device *pdev)
403 rvfree(pdev->image_data, default_mbufs * pdev->len_per_image); 403 rvfree(pdev->image_data, default_mbufs * pdev->len_per_image);
404 } 404 }
405 pdev->image_data = NULL; 405 pdev->image_data = NULL;
406 406
407 Trace(TRACE_MEMORY, "Leaving free_buffers().\n"); 407 Trace(TRACE_MEMORY, "Leaving free_buffers().\n");
408} 408}
409 409
410/* The frame & image buffer mess. 410/* The frame & image buffer mess.
411 411
412 Yes, this is a mess. Well, it used to be simple, but alas... In this 412 Yes, this is a mess. Well, it used to be simple, but alas... In this
413 module, 3 buffers schemes are used to get the data from the USB bus to 413 module, 3 buffers schemes are used to get the data from the USB bus to
414 the user program. The first scheme involves the ISO buffers (called thus 414 the user program. The first scheme involves the ISO buffers (called thus
415 since they transport ISO data from the USB controller), and not really 415 since they transport ISO data from the USB controller), and not really
416 interesting. Suffices to say the data from this buffer is quickly 416 interesting. Suffices to say the data from this buffer is quickly
417 gathered in an interrupt handler (pwc_isoc_handler) and placed into the 417 gathered in an interrupt handler (pwc_isoc_handler) and placed into the
418 frame buffer. 418 frame buffer.
419 419
@@ -443,8 +443,8 @@ static void pwc_free_buffers(struct pwc_device *pdev)
443 and a 'full' frame list: 443 and a 'full' frame list:
444 * Initially, all frame buffers but one are on the 'empty' list; the one 444 * Initially, all frame buffers but one are on the 'empty' list; the one
445 remaining buffer is our initial fill frame. 445 remaining buffer is our initial fill frame.
446 * If a frame is needed for filling, we try to take it from the 'empty' 446 * If a frame is needed for filling, we try to take it from the 'empty'
447 list, unless that list is empty, in which case we take the buffer at 447 list, unless that list is empty, in which case we take the buffer at
448 the head of the 'full' list. 448 the head of the 'full' list.
449 * When our fill buffer has been filled, it is appended to the 'full' 449 * When our fill buffer has been filled, it is appended to the 'full'
450 list. 450 list.
@@ -646,7 +646,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
646 case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break; 646 case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break;
647 } 647 }
648 Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg); 648 Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg);
649 /* Give up after a number of contiguous errors on the USB bus. 649 /* Give up after a number of contiguous errors on the USB bus.
650 Appearantly something is wrong so we simulate an unplug event. 650 Appearantly something is wrong so we simulate an unplug event.
651 */ 651 */
652 if (++pdev->visoc_errors > MAX_ISOC_ERRORS) 652 if (++pdev->visoc_errors > MAX_ISOC_ERRORS)
@@ -673,8 +673,8 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
673 pdev->visoc_errors = 0; 673 pdev->visoc_errors = 0;
674 674
675 /* vsync: 0 = don't copy data 675 /* vsync: 0 = don't copy data
676 1 = sync-hunt 676 1 = sync-hunt
677 2 = synched 677 2 = synched
678 */ 678 */
679 /* Compact data */ 679 /* Compact data */
680 for (i = 0; i < urb->number_of_packets; i++) { 680 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)
701 } /* ..flen > 0 */ 701 } /* ..flen > 0 */
702 702
703 if (flen < pdev->vlast_packet_size) { 703 if (flen < pdev->vlast_packet_size) {
704 /* Shorter packet... We probably have the end of an image-frame; 704 /* Shorter packet... We probably have the end of an image-frame;
705 wake up read() process and let select()/poll() do something. 705 wake up read() process and let select()/poll() do something.
706 Decompression is done in user time over there. 706 Decompression is done in user time over there.
707 */ 707 */
708 if (pdev->vsync == 2) { 708 if (pdev->vsync == 2) {
709 /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus 709 /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus
710 frames on the USB wire after an exposure change. This conditition is 710 frames on the USB wire after an exposure change. This conditition is
711 however detected in the cam and a bit is set in the header. 711 however detected in the cam and a bit is set in the header.
712 */ 712 */
713 if (pdev->type == 730) { 713 if (pdev->type == 730) {
714 unsigned char *ptr = (unsigned char *)fbuf->data; 714 unsigned char *ptr = (unsigned char *)fbuf->data;
715 715
716 if (ptr[1] == 1 && ptr[0] & 0x10) { 716 if (ptr[1] == 1 && ptr[0] & 0x10) {
717#if PWC_DEBUG 717#if PWC_DEBUG
718 Debug("Hyundai CMOS sensor bug. Dropping frame %d.\n", fbuf->sequence); 718 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)
733 Info("Image is normal.\n"); 733 Info("Image is normal.\n");
734 } 734 }
735 pdev->vmirror = ptr[0] & 0x03; 735 pdev->vmirror = ptr[0] & 0x03;
736 /* Sometimes the trailer of the 730 is still sent as a 4 byte packet 736 /* Sometimes the trailer of the 730 is still sent as a 4 byte packet
737 after a short frame; this condition is filtered out specifically. A 4 byte 737 after a short frame; this condition is filtered out specifically. A 4 byte
738 frame doesn't make sense anyway. 738 frame doesn't make sense anyway.
739 So we get either this sequence: 739 So we get either this sequence:
740 drop_bit set -> 4 byte frame -> short frame -> good frame 740 drop_bit set -> 4 byte frame -> short frame -> good frame
741 Or this one: 741 Or this one:
742 drop_bit set -> short frame -> good frame 742 drop_bit set -> short frame -> good frame
743 So we drop either 3 or 2 frames in all! 743 So we drop either 3 or 2 frames in all!
744 */ 744 */
745 if (fbuf->filled == 4) 745 if (fbuf->filled == 4)
@@ -830,7 +830,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
830 intf = usb_ifnum_to_if(udev, 0); 830 intf = usb_ifnum_to_if(udev, 0);
831 if (intf) 831 if (intf)
832 idesc = usb_altnum_to_altsetting(intf, pdev->valternate); 832 idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
833 833
834 if (!idesc) 834 if (!idesc)
835 return -EFAULT; 835 return -EFAULT;
836 836
@@ -841,7 +841,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
841 pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize); 841 pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize);
842 break; 842 break;
843 } 843 }
844 844
845 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { 845 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
846 Err("Failed to find packet size for video endpoint in current alternate setting.\n"); 846 Err("Failed to find packet size for video endpoint in current alternate setting.\n");
847 return -ENFILE; /* Odd error, that should be noticeable */ 847 return -ENFILE; /* Odd error, that should be noticeable */
@@ -875,18 +875,18 @@ static int pwc_isoc_init(struct pwc_device *pdev)
875 return ret; 875 return ret;
876 } 876 }
877 877
878 /* init URB structure */ 878 /* init URB structure */
879 for (i = 0; i < MAX_ISO_BUFS; i++) { 879 for (i = 0; i < MAX_ISO_BUFS; i++) {
880 urb = pdev->sbuf[i].urb; 880 urb = pdev->sbuf[i].urb;
881 881
882 urb->interval = 1; // devik 882 urb->interval = 1; // devik
883 urb->dev = udev; 883 urb->dev = udev;
884 urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint); 884 urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
885 urb->transfer_flags = URB_ISO_ASAP; 885 urb->transfer_flags = URB_ISO_ASAP;
886 urb->transfer_buffer = pdev->sbuf[i].data; 886 urb->transfer_buffer = pdev->sbuf[i].data;
887 urb->transfer_buffer_length = ISO_BUFFER_SIZE; 887 urb->transfer_buffer_length = ISO_BUFFER_SIZE;
888 urb->complete = pwc_isoc_handler; 888 urb->complete = pwc_isoc_handler;
889 urb->context = pdev; 889 urb->context = pdev;
890 urb->start_frame = 0; 890 urb->start_frame = 0;
891 urb->number_of_packets = ISO_FRAMES_PER_DESC; 891 urb->number_of_packets = ISO_FRAMES_PER_DESC;
892 for (j = 0; j < ISO_FRAMES_PER_DESC; j++) { 892 for (j = 0; j < ISO_FRAMES_PER_DESC; j++) {
@@ -935,7 +935,7 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev)
935 } 935 }
936 936
937 /* Stop camera, but only if we are sure the camera is still there (unplug 937 /* Stop camera, but only if we are sure the camera is still there (unplug
938 is signalled by EPIPE) 938 is signalled by EPIPE)
939 */ 939 */
940 if (pdev->error_status && pdev->error_status != EPIPE) { 940 if (pdev->error_status && pdev->error_status != EPIPE) {
941 Trace(TRACE_OPEN, "Setting alternate interface 0.\n"); 941 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
956 pwc_reset_buffers(pdev); 956 pwc_reset_buffers(pdev);
957 /* Try to set video mode... */ 957 /* Try to set video mode... */
958 start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot); 958 start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot);
959 if (ret) { 959 if (ret) {
960 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n"); 960 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n");
961 /* That failed... restore old mode (we know that worked) */ 961 /* That failed... restore old mode (we know that worked) */
962 start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot); 962 start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
963 if (start) { 963 if (start) {
964 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n"); 964 Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n");
965 } 965 }
966 } 966 }
967 if (start == 0) 967 if (start == 0)
@@ -987,18 +987,18 @@ static int pwc_video_open(struct inode *inode, struct file *file)
987 struct pwc_device *pdev; 987 struct pwc_device *pdev;
988 988
989 Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev); 989 Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev);
990 990
991 pdev = (struct pwc_device *)vdev->priv; 991 pdev = (struct pwc_device *)vdev->priv;
992 if (pdev == NULL) 992 if (pdev == NULL)
993 BUG(); 993 BUG();
994 if (pdev->vopen) 994 if (pdev->vopen)
995 return -EBUSY; 995 return -EBUSY;
996 996
997 down(&pdev->modlock); 997 down(&pdev->modlock);
998 if (!pdev->usb_init) { 998 if (!pdev->usb_init) {
999 Trace(TRACE_OPEN, "Doing first time initialization.\n"); 999 Trace(TRACE_OPEN, "Doing first time initialization.\n");
1000 pdev->usb_init = 1; 1000 pdev->usb_init = 1;
1001 1001
1002 if (pwc_trace & TRACE_OPEN) 1002 if (pwc_trace & TRACE_OPEN)
1003 { 1003 {
1004 /* Query sensor type */ 1004 /* Query sensor type */
@@ -1036,7 +1036,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1036 /* Set LED on/off time */ 1036 /* Set LED on/off time */
1037 if (pwc_set_leds(pdev, led_on, led_off) < 0) 1037 if (pwc_set_leds(pdev, led_on, led_off) < 0)
1038 Info("Failed to set LED on/off time.\n"); 1038 Info("Failed to set LED on/off time.\n");
1039 1039
1040 pwc_construct(pdev); /* set min/max sizes correct */ 1040 pwc_construct(pdev); /* set min/max sizes correct */
1041 1041
1042 /* So far, so good. Allocate memory. */ 1042 /* So far, so good. Allocate memory. */
@@ -1046,7 +1046,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1046 up(&pdev->modlock); 1046 up(&pdev->modlock);
1047 return i; 1047 return i;
1048 } 1048 }
1049 1049
1050 /* Reset buffers & parameters */ 1050 /* Reset buffers & parameters */
1051 pwc_reset_buffers(pdev); 1051 pwc_reset_buffers(pdev);
1052 for (i = 0; i < default_mbufs; i++) 1052 for (i = 0; i < default_mbufs; i++)
@@ -1081,7 +1081,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1081 up(&pdev->modlock); 1081 up(&pdev->modlock);
1082 return i; 1082 return i;
1083 } 1083 }
1084 1084
1085 i = pwc_isoc_init(pdev); 1085 i = pwc_isoc_init(pdev);
1086 if (i) { 1086 if (i) {
1087 Trace(TRACE_OPEN, "Failed to init ISOC stuff = %d.\n", i); 1087 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)
1155/* 1155/*
1156 * FIXME: what about two parallel reads ???? 1156 * FIXME: what about two parallel reads ????
1157 * ANSWER: Not supported. You can't open the device more than once, 1157 * ANSWER: Not supported. You can't open the device more than once,
1158 despite what the V4L1 interface says. First, I don't see 1158 despite what the V4L1 interface says. First, I don't see
1159 the need, second there's no mechanism of alerting the 1159 the need, second there's no mechanism of alerting the
1160 2nd/3rd/... process of events like changing image size. 1160 2nd/3rd/... process of events like changing image size.
1161 And I don't see the point of blocking that for the 1161 And I don't see the point of blocking that for the
1162 2nd/3rd/... process. 1162 2nd/3rd/... process.
1163 In multi-threaded environments reading parallel from any 1163 In multi-threaded environments reading parallel from any
1164 device is tricky anyhow. 1164 device is tricky anyhow.
1165 */ 1165 */
1166 1166
1167static ssize_t pwc_video_read(struct file *file, char __user * buf, 1167static 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,
1171 struct pwc_device *pdev; 1171 struct pwc_device *pdev;
1172 int noblock = file->f_flags & O_NONBLOCK; 1172 int noblock = file->f_flags & O_NONBLOCK;
1173 DECLARE_WAITQUEUE(wait, current); 1173 DECLARE_WAITQUEUE(wait, current);
1174 int bytes_to_read; 1174 int bytes_to_read;
1175 1175
1176 Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count); 1176 Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count);
1177 if (vdev == NULL) 1177 if (vdev == NULL)
@@ -1193,22 +1193,22 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1193 set_current_state(TASK_RUNNING); 1193 set_current_state(TASK_RUNNING);
1194 return -pdev->error_status ; 1194 return -pdev->error_status ;
1195 } 1195 }
1196 if (noblock) { 1196 if (noblock) {
1197 remove_wait_queue(&pdev->frameq, &wait); 1197 remove_wait_queue(&pdev->frameq, &wait);
1198 set_current_state(TASK_RUNNING); 1198 set_current_state(TASK_RUNNING);
1199 return -EWOULDBLOCK; 1199 return -EWOULDBLOCK;
1200 } 1200 }
1201 if (signal_pending(current)) { 1201 if (signal_pending(current)) {
1202 remove_wait_queue(&pdev->frameq, &wait); 1202 remove_wait_queue(&pdev->frameq, &wait);
1203 set_current_state(TASK_RUNNING); 1203 set_current_state(TASK_RUNNING);
1204 return -ERESTARTSYS; 1204 return -ERESTARTSYS;
1205 } 1205 }
1206 schedule(); 1206 schedule();
1207 set_current_state(TASK_INTERRUPTIBLE); 1207 set_current_state(TASK_INTERRUPTIBLE);
1208 } 1208 }
1209 remove_wait_queue(&pdev->frameq, &wait); 1209 remove_wait_queue(&pdev->frameq, &wait);
1210 set_current_state(TASK_RUNNING); 1210 set_current_state(TASK_RUNNING);
1211 1211
1212 /* Decompress and release frame */ 1212 /* Decompress and release frame */
1213 if (pwc_handle_frame(pdev)) 1213 if (pwc_handle_frame(pdev))
1214 return -EFAULT; 1214 return -EFAULT;
@@ -1218,7 +1218,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1218 if (pdev->vpalette == VIDEO_PALETTE_RAW) 1218 if (pdev->vpalette == VIDEO_PALETTE_RAW)
1219 bytes_to_read = pdev->frame_size; 1219 bytes_to_read = pdev->frame_size;
1220 else 1220 else
1221 bytes_to_read = pdev->view.size; 1221 bytes_to_read = pdev->view.size;
1222 1222
1223 /* copy bytes to user space; we allow for partial reads */ 1223 /* copy bytes to user space; we allow for partial reads */
1224 if (count + pdev->image_read_pos > bytes_to_read) 1224 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,
1348 struct video_picture *p = arg; 1348 struct video_picture *p = arg;
1349 /* 1349 /*
1350 * FIXME: Suppose we are mid read 1350 * FIXME: Suppose we are mid read
1351 ANSWER: No problem: the firmware of the camera 1351 ANSWER: No problem: the firmware of the camera
1352 can handle brightness/contrast/etc 1352 can handle brightness/contrast/etc
1353 changes at _any_ time, and the palette 1353 changes at _any_ time, and the palette
1354 is used exactly once in the uncompress 1354 is used exactly once in the uncompress
1355 routine. 1355 routine.
1356 */ 1356 */
1357 pwc_set_brightness(pdev, p->brightness); 1357 pwc_set_brightness(pdev, p->brightness);
1358 pwc_set_contrast(pdev, p->contrast); 1358 pwc_set_contrast(pdev, p->contrast);
@@ -1373,21 +1373,21 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1373 break; 1373 break;
1374 } 1374 }
1375 1375
1376 /* Window/size parameters */ 1376 /* Window/size parameters */
1377 case VIDIOCGWIN: 1377 case VIDIOCGWIN:
1378 { 1378 {
1379 struct video_window *vw = arg; 1379 struct video_window *vw = arg;
1380 1380
1381 vw->x = 0; 1381 vw->x = 0;
1382 vw->y = 0; 1382 vw->y = 0;
1383 vw->width = pdev->view.x; 1383 vw->width = pdev->view.x;
1384 vw->height = pdev->view.y; 1384 vw->height = pdev->view.y;
1385 vw->chromakey = 0; 1385 vw->chromakey = 0;
1386 vw->flags = (pdev->vframes << PWC_FPS_SHIFT) | 1386 vw->flags = (pdev->vframes << PWC_FPS_SHIFT) |
1387 (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0); 1387 (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0);
1388 break; 1388 break;
1389 } 1389 }
1390 1390
1391 case VIDIOCSWIN: 1391 case VIDIOCSWIN:
1392 { 1392 {
1393 struct video_window *vw = arg; 1393 struct video_window *vw = arg;
@@ -1402,9 +1402,9 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1402 ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot); 1402 ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot);
1403 if (ret) 1403 if (ret)
1404 return ret; 1404 return ret;
1405 break; 1405 break;
1406 } 1406 }
1407 1407
1408 /* We don't have overlay support (yet) */ 1408 /* We don't have overlay support (yet) */
1409 case VIDIOCGFBUF: 1409 case VIDIOCGFBUF:
1410 { 1410 {
@@ -1471,8 +1471,8 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1471 return -EBUSY; /* buffer wasn't available. Bummer */ 1471 return -EBUSY; /* buffer wasn't available. Bummer */
1472 pdev->image_used[vm->frame] = 1; 1472 pdev->image_used[vm->frame] = 1;
1473 1473
1474 /* Okay, we're done here. In the SYNC call we wait until a 1474 /* Okay, we're done here. In the SYNC call we wait until a
1475 frame comes available, then expand image into the given 1475 frame comes available, then expand image into the given
1476 buffer. 1476 buffer.
1477 In contrast to the CPiA cam the Philips cams deliver a 1477 In contrast to the CPiA cam the Philips cams deliver a
1478 constant stream, almost like a grabber card. Also, 1478 constant stream, almost like a grabber card. Also,
@@ -1487,16 +1487,16 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1487 { 1487 {
1488 /* The doc says: "Whenever a buffer is used it should 1488 /* The doc says: "Whenever a buffer is used it should
1489 call VIDIOCSYNC to free this frame up and continue." 1489 call VIDIOCSYNC to free this frame up and continue."
1490 1490
1491 The only odd thing about this whole procedure is 1491 The only odd thing about this whole procedure is
1492 that MCAPTURE flags the buffer as "in use", and 1492 that MCAPTURE flags the buffer as "in use", and
1493 SYNC immediately unmarks it, while it isn't 1493 SYNC immediately unmarks it, while it isn't
1494 after SYNC that you know that the buffer actually 1494 after SYNC that you know that the buffer actually
1495 got filled! So you better not start a CAPTURE in 1495 got filled! So you better not start a CAPTURE in
1496 the same frame immediately (use double buffering). 1496 the same frame immediately (use double buffering).
1497 This is not a problem for this cam, since it has 1497 This is not a problem for this cam, since it has
1498 extra intermediate buffers, but a hardware 1498 extra intermediate buffers, but a hardware
1499 grabber card will then overwrite the buffer 1499 grabber card will then overwrite the buffer
1500 you're working on. 1500 you're working on.
1501 */ 1501 */
1502 int *mbuf = arg; 1502 int *mbuf = arg;
@@ -1512,10 +1512,10 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1512 return -EINVAL; 1512 return -EINVAL;
1513 1513
1514 /* Add ourselves to the frame wait-queue. 1514 /* Add ourselves to the frame wait-queue.
1515 1515
1516 FIXME: needs auditing for safety. 1516 FIXME: needs auditing for safety.
1517 QUESTION: In what respect? I think that using the 1517 QUESTION: In what respect? I think that using the
1518 frameq is safe now. 1518 frameq is safe now.
1519 */ 1519 */
1520 add_wait_queue(&pdev->frameq, &wait); 1520 add_wait_queue(&pdev->frameq, &wait);
1521 while (pdev->full_frames == NULL) { 1521 while (pdev->full_frames == NULL) {
@@ -1524,21 +1524,21 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1524 set_current_state(TASK_RUNNING); 1524 set_current_state(TASK_RUNNING);
1525 return -pdev->error_status; 1525 return -pdev->error_status;
1526 } 1526 }
1527 1527
1528 if (signal_pending(current)) { 1528 if (signal_pending(current)) {
1529 remove_wait_queue(&pdev->frameq, &wait); 1529 remove_wait_queue(&pdev->frameq, &wait);
1530 set_current_state(TASK_RUNNING); 1530 set_current_state(TASK_RUNNING);
1531 return -ERESTARTSYS; 1531 return -ERESTARTSYS;
1532 } 1532 }
1533 schedule(); 1533 schedule();
1534 set_current_state(TASK_INTERRUPTIBLE); 1534 set_current_state(TASK_INTERRUPTIBLE);
1535 } 1535 }
1536 remove_wait_queue(&pdev->frameq, &wait); 1536 remove_wait_queue(&pdev->frameq, &wait);
1537 set_current_state(TASK_RUNNING); 1537 set_current_state(TASK_RUNNING);
1538 1538
1539 /* The frame is ready. Expand in the image buffer 1539 /* The frame is ready. Expand in the image buffer
1540 requested by the user. I don't care if you 1540 requested by the user. I don't care if you
1541 mmap() 5 buffers and request data in this order: 1541 mmap() 5 buffers and request data in this order:
1542 buffer 4 2 3 0 1 2 3 0 4 3 1 . . . 1542 buffer 4 2 3 0 1 2 3 0 4 3 1 . . .
1543 Grabber hardware may not be so forgiving. 1543 Grabber hardware may not be so forgiving.
1544 */ 1544 */
@@ -1551,11 +1551,11 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1551 return -EFAULT; 1551 return -EFAULT;
1552 break; 1552 break;
1553 } 1553 }
1554 1554
1555 case VIDIOCGAUDIO: 1555 case VIDIOCGAUDIO:
1556 { 1556 {
1557 struct video_audio *v = arg; 1557 struct video_audio *v = arg;
1558 1558
1559 strcpy(v->name, "Microphone"); 1559 strcpy(v->name, "Microphone");
1560 v->audio = -1; /* unknown audio minor */ 1560 v->audio = -1; /* unknown audio minor */
1561 v->flags = 0; 1561 v->flags = 0;
@@ -1565,19 +1565,19 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1565 v->treble = 0; 1565 v->treble = 0;
1566 v->balance = 0x8000; 1566 v->balance = 0x8000;
1567 v->step = 1; 1567 v->step = 1;
1568 break; 1568 break;
1569 } 1569 }
1570 1570
1571 case VIDIOCSAUDIO: 1571 case VIDIOCSAUDIO:
1572 { 1572 {
1573 /* Dummy: nothing can be set */ 1573 /* Dummy: nothing can be set */
1574 break; 1574 break;
1575 } 1575 }
1576 1576
1577 case VIDIOCGUNIT: 1577 case VIDIOCGUNIT:
1578 { 1578 {
1579 struct video_unit *vu = arg; 1579 struct video_unit *vu = arg;
1580 1580
1581 vu->video = pdev->vdev->minor & 0x3F; 1581 vu->video = pdev->vdev->minor & 0x3F;
1582 vu->audio = -1; /* not known yet */ 1582 vu->audio = -1; /* not known yet */
1583 vu->vbi = -1; 1583 vu->vbi = -1;
@@ -1589,7 +1589,7 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1589 return pwc_ioctl(pdev, cmd, arg); 1589 return pwc_ioctl(pdev, cmd, arg);
1590 } /* ..switch */ 1590 } /* ..switch */
1591 return 0; 1591 return 0;
1592} 1592}
1593 1593
1594static int pwc_video_ioctl(struct inode *inode, struct file *file, 1594static int pwc_video_ioctl(struct inode *inode, struct file *file,
1595 unsigned int cmd, unsigned long arg) 1595 unsigned int cmd, unsigned long arg)
@@ -1605,10 +1605,10 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma)
1605 unsigned long start = vma->vm_start; 1605 unsigned long start = vma->vm_start;
1606 unsigned long size = vma->vm_end-vma->vm_start; 1606 unsigned long size = vma->vm_end-vma->vm_start;
1607 unsigned long page, pos; 1607 unsigned long page, pos;
1608 1608
1609 Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size); 1609 Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size);
1610 pdev = vdev->priv; 1610 pdev = vdev->priv;
1611 1611
1612 vma->vm_flags |= VM_IO; 1612 vma->vm_flags |= VM_IO;
1613 1613
1614 pos = (unsigned long)pdev->image_data; 1614 pos = (unsigned long)pdev->image_data;
@@ -1646,7 +1646,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1646 char serial_number[30], *name; 1646 char serial_number[30], *name;
1647 1647
1648 /* Check if we can handle this device */ 1648 /* Check if we can handle this device */
1649 Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", 1649 Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n",
1650 le16_to_cpu(udev->descriptor.idVendor), 1650 le16_to_cpu(udev->descriptor.idVendor),
1651 le16_to_cpu(udev->descriptor.idProduct), 1651 le16_to_cpu(udev->descriptor.idProduct),
1652 intf->altsetting->desc.bInterfaceNumber); 1652 intf->altsetting->desc.bInterfaceNumber);
@@ -1770,11 +1770,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1770 name = "Logitech QuickCam (res.)"; 1770 name = "Logitech QuickCam (res.)";
1771 type_id = 730; /* Assuming CMOS */ 1771 type_id = 730; /* Assuming CMOS */
1772 break; 1772 break;
1773 default: 1773 default:
1774 return -ENODEV; 1774 return -ENODEV;
1775 break; 1775 break;
1776 } 1776 }
1777 } 1777 }
1778 else if (vendor_id == 0x055d) { 1778 else if (vendor_id == 0x055d) {
1779 /* I don't know the difference between the C10 and the C30; 1779 /* I don't know the difference between the C10 and the C30;
1780 I suppose the difference is the sensor, but both cameras 1780 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
1837 return -ENODEV; 1837 return -ENODEV;
1838 break; 1838 break;
1839 } 1839 }
1840 1840
1841 } 1841 }
1842 else if (vendor_id == 0x0d81) { 1842 else if (vendor_id == 0x0d81) {
1843 switch(product_id) { 1843 switch(product_id) {
@@ -1856,7 +1856,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1856 break; 1856 break;
1857 } 1857 }
1858 } 1858 }
1859 else 1859 else
1860 return -ENODEV; /* Not any of the know types; but the list keeps growing. */ 1860 return -ENODEV; /* Not any of the know types; but the list keeps growing. */
1861 1861
1862 memset(serial_number, 0, 30); 1862 memset(serial_number, 0, 30);
@@ -1880,9 +1880,9 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1880 if (vendor_id == 0x046D && product_id == 0x08B5) 1880 if (vendor_id == 0x046D && product_id == 0x08B5)
1881 { 1881 {
1882 /* Logitech QuickCam Orbit 1882 /* Logitech QuickCam Orbit
1883 The ranges have been determined experimentally; they may differ from cam to cam. 1883 The ranges have been determined experimentally; they may differ from cam to cam.
1884 Also, the exact ranges left-right and up-down are different for my cam 1884 Also, the exact ranges left-right and up-down are different for my cam
1885 */ 1885 */
1886 pdev->angle_range.pan_min = -7000; 1886 pdev->angle_range.pan_min = -7000;
1887 pdev->angle_range.pan_max = 7000; 1887 pdev->angle_range.pan_max = 7000;
1888 pdev->angle_range.tilt_min = -3000; 1888 pdev->angle_range.tilt_min = -3000;
@@ -1939,7 +1939,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1939 } 1939 }
1940 1940
1941 /* occupy slot */ 1941 /* occupy slot */
1942 if (hint < MAX_DEV_HINTS) 1942 if (hint < MAX_DEV_HINTS)
1943 device_hint[hint].pdev = pdev; 1943 device_hint[hint].pdev = pdev;
1944 1944
1945 Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev); 1945 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)
1968 Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n"); 1968 Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n");
1969 goto disconnect_out; 1969 goto disconnect_out;
1970 } 1970 }
1971#ifdef PWC_MAGIC 1971#ifdef PWC_MAGIC
1972 if (pdev->magic != PWC_MAGIC) { 1972 if (pdev->magic != PWC_MAGIC) {
1973 Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n"); 1973 Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n");
1974 goto disconnect_out; 1974 goto disconnect_out;
1975 } 1975 }
1976#endif 1976#endif
1977 1977
1978 /* We got unplugged; this is signalled by an EPIPE error code */ 1978 /* We got unplugged; this is signalled by an EPIPE error code */
1979 if (pdev->vopen) { 1979 if (pdev->vopen) {
1980 Info("Disconnected while webcam is in use!\n"); 1980 Info("Disconnected while webcam is in use!\n");
@@ -2017,8 +2017,8 @@ static int pwc_atoi(const char *s)
2017} 2017}
2018 2018
2019 2019
2020/* 2020/*
2021 * Initialization code & module stuff 2021 * Initialization code & module stuff
2022 */ 2022 */
2023 2023
2024static char size[10]; 2024static char size[10];
@@ -2168,7 +2168,7 @@ static int __init usb_pwc_init(void)
2168 if (*dot != '\0') { 2168 if (*dot != '\0') {
2169 /* There's a serial number as well */ 2169 /* There's a serial number as well */
2170 int k; 2170 int k;
2171 2171
2172 dot++; 2172 dot++;
2173 k = 0; 2173 k = 0;
2174 while (*dot != ':' && k < 29) { 2174 while (*dot != ':' && k < 29) {
@@ -2178,18 +2178,18 @@ static int __init usb_pwc_init(void)
2178 device_hint[i].serial_number[k] = '\0'; 2178 device_hint[i].serial_number[k] = '\0';
2179 } 2179 }
2180 } 2180 }
2181#if PWC_DEBUG 2181#if PWC_DEBUG
2182 Debug("device_hint[%d]:\n", i); 2182 Debug("device_hint[%d]:\n", i);
2183 Debug(" type : %d\n", device_hint[i].type); 2183 Debug(" type : %d\n", device_hint[i].type);
2184 Debug(" serial# : %s\n", device_hint[i].serial_number); 2184 Debug(" serial# : %s\n", device_hint[i].serial_number);
2185 Debug(" node : %d\n", device_hint[i].device_node); 2185 Debug(" node : %d\n", device_hint[i].device_node);
2186#endif 2186#endif
2187 } 2187 }
2188 else 2188 else
2189 device_hint[i].type = 0; /* not filled */ 2189 device_hint[i].type = 0; /* not filled */
2190 } /* ..for MAX_DEV_HINTS */ 2190 } /* ..for MAX_DEV_HINTS */
2191 2191
2192 Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver); 2192 Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver);
2193 return usb_register(&pwc_driver); 2193 return usb_register(&pwc_driver);
2194} 2194}
2195 2195
diff --git a/drivers/usb/media/pwc/pwc-ioctl.h b/drivers/media/video/pwc/pwc-ioctl.h
index 5f9cb08bc02e..784bc72521fa 100644
--- a/drivers/usb/media/pwc/pwc-ioctl.h
+++ b/drivers/media/video/pwc/pwc-ioctl.h
@@ -33,10 +33,10 @@
33/* 33/*
34 Changes 34 Changes
35 2001/08/03 Alvarado Added ioctl constants to access methods for 35 2001/08/03 Alvarado Added ioctl constants to access methods for
36 changing white balance and red/blue gains 36 changing white balance and red/blue gains
37 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE 37 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
38 2003/12/13 Nemosft Unv. Some modifications to make interfacing to 38 2003/12/13 Nemosft Unv. Some modifications to make interfacing to
39 PWCX easier 39 PWCX easier
40 */ 40 */
41 41
42/* These are private ioctl() commands, specific for the Philips webcams. 42/* These are private ioctl() commands, specific for the Philips webcams.
@@ -45,10 +45,10 @@
45 45
46 The #define names are built up like follows: 46 The #define names are built up like follows:
47 VIDIOC VIDeo IOCtl prefix 47 VIDIOC VIDeo IOCtl prefix
48 PWC Philps WebCam 48 PWC Philps WebCam
49 G optional: Get 49 G optional: Get
50 S optional: Set 50 S optional: Set
51 ... the function 51 ... the function
52 */ 52 */
53 53
54 54
@@ -94,7 +94,7 @@ struct pwc_serial
94{ 94{
95 char serial[30]; /* String with serial number. Contains terminating 0 */ 95 char serial[30]; /* String with serial number. Contains terminating 0 */
96}; 96};
97 97
98/* pwc_whitebalance.mode values */ 98/* pwc_whitebalance.mode values */
99#define PWC_WB_INDOOR 0 99#define PWC_WB_INDOOR 0
100#define PWC_WB_OUTDOOR 1 100#define PWC_WB_OUTDOOR 1
@@ -102,14 +102,14 @@ struct pwc_serial
102#define PWC_WB_MANUAL 3 102#define PWC_WB_MANUAL 3
103#define PWC_WB_AUTO 4 103#define PWC_WB_AUTO 4
104 104
105/* Used with VIDIOCPWC[SG]AWB (Auto White Balance). 105/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
106 Set mode to one of the PWC_WB_* values above. 106 Set mode to one of the PWC_WB_* values above.
107 *red and *blue are the respective gains of these colour components inside 107 *red and *blue are the respective gains of these colour components inside
108 the camera; range 0..65535 108 the camera; range 0..65535
109 When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; 109 When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
110 otherwise undefined. 110 otherwise undefined.
111 'read_red' and 'read_blue' are read-only. 111 'read_red' and 'read_blue' are read-only.
112*/ 112*/
113struct pwc_whitebalance 113struct pwc_whitebalance
114{ 114{
115 int mode; 115 int mode;
@@ -117,9 +117,9 @@ struct pwc_whitebalance
117 int read_red, read_blue; /* R/O */ 117 int read_red, read_blue; /* R/O */
118}; 118};
119 119
120/* 120/*
121 'control_speed' and 'control_delay' are used in automatic whitebalance mode, 121 'control_speed' and 'control_delay' are used in automatic whitebalance mode,
122 and tell the camera how fast it should react to changes in lighting, and 122 and tell the camera how fast it should react to changes in lighting, and
123 with how much delay. Valid values are 0..65535. 123 with how much delay. Valid values are 0..65535.
124*/ 124*/
125struct pwc_wb_speed 125struct pwc_wb_speed
@@ -148,11 +148,11 @@ struct pwc_imagesize
148#define PWC_MPT_TILT 0x02 148#define PWC_MPT_TILT 0x02
149#define PWC_MPT_TIMEOUT 0x04 /* for status */ 149#define PWC_MPT_TIMEOUT 0x04 /* for status */
150 150
151/* Set angles; when absolute != 0, the angle is absolute and the 151/* Set angles; when absolute != 0, the angle is absolute and the
152 driver calculates the relative offset for you. This can only 152 driver calculates the relative offset for you. This can only
153 be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns 153 be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
154 absolute angles. 154 absolute angles.
155 */ 155 */
156struct pwc_mpt_angles 156struct pwc_mpt_angles
157{ 157{
158 int absolute; /* write-only */ 158 int absolute; /* write-only */
@@ -179,14 +179,14 @@ struct pwc_mpt_status
179/* This is used for out-of-kernel decompression. With it, you can get 179/* This is used for out-of-kernel decompression. With it, you can get
180 all the necessary information to initialize and use the decompressor 180 all the necessary information to initialize and use the decompressor
181 routines in standalone applications. 181 routines in standalone applications.
182 */ 182 */
183struct pwc_video_command 183struct pwc_video_command
184{ 184{
185 int type; /* camera type (645, 675, 730, etc.) */ 185 int type; /* camera type (645, 675, 730, etc.) */
186 int release; /* release number */ 186 int release; /* release number */
187 187
188 int size; /* one of PSZ_* */ 188 int size; /* one of PSZ_* */
189 int alternate; 189 int alternate;
190 int command_len; /* length of USB video command */ 190 int command_len; /* length of USB video command */
191 unsigned char command_buf[13]; /* Actual USB video command */ 191 unsigned char command_buf[13]; /* Actual USB video command */
192 int bandlength; /* >0 = compressed */ 192 int bandlength; /* >0 = compressed */
@@ -264,7 +264,7 @@ struct pwc_video_command
264 264
265 /* Flickerless mode; = 0 off, otherwise on */ 265 /* Flickerless mode; = 0 off, otherwise on */
266#define VIDIOCPWCSFLICKER _IOW('v', 208, int) 266#define VIDIOCPWCSFLICKER _IOW('v', 208, int)
267#define VIDIOCPWCGFLICKER _IOR('v', 208, int) 267#define VIDIOCPWCGFLICKER _IOR('v', 208, int)
268 268
269 /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ 269 /* Dynamic noise reduction; 0 off, 3 = high noise reduction */
270#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) 270#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
@@ -273,7 +273,7 @@ struct pwc_video_command
273 /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ 273 /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
274#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) 274#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
275 275
276 /* Motorized pan & tilt functions */ 276 /* Motorized pan & tilt functions */
277#define VIDIOCPWCMPTRESET _IOW('v', 211, int) 277#define VIDIOCPWCMPTRESET _IOW('v', 211, int)
278#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) 278#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
279#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) 279#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 000000000000..4c96037f7be5
--- /dev/null
+++ b/drivers/media/video/pwc/pwc-kiara.c
@@ -0,0 +1,318 @@
1/* Linux driver for Philips webcam
2 (C) 2004 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26/* This tables contains entries for the 730/740/750 (Kiara) camera, with
27 4 different qualities (no compression, low, medium, high).
28 It lists the bandwidth requirements for said mode by its alternate interface
29 number. An alternate of 0 means that the mode is unavailable.
30
31 There are 6 * 4 * 4 entries:
32 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
33 6 framerates: 5, 10, 15, 20, 25, 30
34 4 compression modi: none, low, medium, high
35
36 When an uncompressed mode is not available, the next available compressed mode
37 will be chosen (unless the decompressor is absent). Sometimes there are only
38 1 or 2 compressed modes available; in that case entries are duplicated.
39*/
40
41
42#include "pwc-kiara.h"
43#include "pwc-uncompress.h"
44
45const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
46{
47 /* SQCIF */
48 {
49 /* 5 fps */
50 {
51 {0, },
52 {0, },
53 {0, },
54 {0, },
55 },
56 /* 10 fps */
57 {
58 {0, },
59 {0, },
60 {0, },
61 {0, },
62 },
63 /* 15 fps */
64 {
65 {0, },
66 {0, },
67 {0, },
68 {0, },
69 },
70 /* 20 fps */
71 {
72 {0, },
73 {0, },
74 {0, },
75 {0, },
76 },
77 /* 25 fps */
78 {
79 {0, },
80 {0, },
81 {0, },
82 {0, },
83 },
84 /* 30 fps */
85 {
86 {0, },
87 {0, },
88 {0, },
89 {0, },
90 },
91 },
92 /* QSIF */
93 {
94 /* 5 fps */
95 {
96 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
97 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
98 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
99 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
100 },
101 /* 10 fps */
102 {
103 {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
104 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
105 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
106 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
107 },
108 /* 15 fps */
109 {
110 {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
111 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
112 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
113 {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
114 },
115 /* 20 fps */
116 {
117 {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
118 {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
119 {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
120 {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
121 },
122 /* 25 fps */
123 {
124 {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
125 {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
126 {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
127 {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
128 },
129 /* 30 fps */
130 {
131 {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
132 {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
133 {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
134 {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
135 },
136 },
137 /* QCIF */
138 {
139 /* 5 fps */
140 {
141 {0, },
142 {0, },
143 {0, },
144 {0, },
145 },
146 /* 10 fps */
147 {
148 {0, },
149 {0, },
150 {0, },
151 {0, },
152 },
153 /* 15 fps */
154 {
155 {0, },
156 {0, },
157 {0, },
158 {0, },
159 },
160 /* 20 fps */
161 {
162 {0, },
163 {0, },
164 {0, },
165 {0, },
166 },
167 /* 25 fps */
168 {
169 {0, },
170 {0, },
171 {0, },
172 {0, },
173 },
174 /* 30 fps */
175 {
176 {0, },
177 {0, },
178 {0, },
179 {0, },
180 },
181 },
182 /* SIF */
183 {
184 /* 5 fps */
185 {
186 {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
187 {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
188 {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
189 {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
190 },
191 /* 10 fps */
192 {
193 {0, },
194 {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
195 {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
196 {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
197 },
198 /* 15 fps */
199 {
200 {0, },
201 {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
202 {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
203 {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
204 },
205 /* 20 fps */
206 {
207 {0, },
208 {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
209 {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
210 {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
211 },
212 /* 25 fps */
213 {
214 {0, },
215 {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
216 {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
217 {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
218 },
219 /* 30 fps */
220 {
221 {0, },
222 {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
223 {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
224 {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
225 },
226 },
227 /* CIF */
228 {
229 /* 5 fps */
230 {
231 {0, },
232 {0, },
233 {0, },
234 {0, },
235 },
236 /* 10 fps */
237 {
238 {0, },
239 {0, },
240 {0, },
241 {0, },
242 },
243 /* 15 fps */
244 {
245 {0, },
246 {0, },
247 {0, },
248 {0, },
249 },
250 /* 20 fps */
251 {
252 {0, },
253 {0, },
254 {0, },
255 {0, },
256 },
257 /* 25 fps */
258 {
259 {0, },
260 {0, },
261 {0, },
262 {0, },
263 },
264 /* 30 fps */
265 {
266 {0, },
267 {0, },
268 {0, },
269 {0, },
270 },
271 },
272 /* VGA */
273 {
274 /* 5 fps */
275 {
276 {0, },
277 {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
278 {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
279 {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
280 },
281 /* 10 fps */
282 {
283 {0, },
284 {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
285 {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
286 {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
287 },
288 /* 15 fps */
289 {
290 {0, },
291 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
292 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
293 {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
294 },
295 /* 20 fps */
296 {
297 {0, },
298 {0, },
299 {0, },
300 {0, },
301 },
302 /* 25 fps */
303 {
304 {0, },
305 {0, },
306 {0, },
307 {0, },
308 },
309 /* 30 fps */
310 {
311 {0, },
312 {0, },
313 {0, },
314 {0, },
315 },
316 },
317};
318
diff --git a/drivers/usb/media/pwc/pwc-kiara.h b/drivers/media/video/pwc/pwc-kiara.h
index 12929abbb1f0..12929abbb1f0 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 b7a4bd3524c7..58fe79747992 100644
--- a/drivers/usb/media/pwc/pwc-misc.c
+++ b/drivers/media/video/pwc/pwc-misc.c
@@ -1,4 +1,4 @@
1/* Linux driver for Philips webcam 1/* Linux driver for Philips webcam
2 Various miscellaneous functions and tables. 2 Various miscellaneous functions and tables.
3 (C) 1999-2003 Nemosoft Unv. 3 (C) 1999-2003 Nemosoft Unv.
4 (C) 2004 Luc Saillard (luc@saillard.org) 4 (C) 2004 Luc Saillard (luc@saillard.org)
@@ -44,17 +44,17 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
44 int i, find; 44 int i, find;
45 45
46 /* Make sure we don't go beyond our max size. 46 /* Make sure we don't go beyond our max size.
47 NB: we have different limits for RAW and normal modes. In case 47 NB: we have different limits for RAW and normal modes. In case
48 you don't have the decompressor loaded or use RAW mode, 48 you don't have the decompressor loaded or use RAW mode,
49 the maximum viewable size is smaller. 49 the maximum viewable size is smaller.
50 */ 50 */
51 if (pdev->vpalette == VIDEO_PALETTE_RAW) 51 if (pdev->vpalette == VIDEO_PALETTE_RAW)
52 { 52 {
53 if (width > pdev->abs_max.x || height > pdev->abs_max.y) 53 if (width > pdev->abs_max.x || height > pdev->abs_max.y)
54 { 54 {
55 Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n"); 55 Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
56 return -1; 56 return -1;
57 } 57 }
58 } 58 }
59 else 59 else
60 { 60 {
@@ -88,8 +88,8 @@ void pwc_construct(struct pwc_device *pdev)
88 pdev->view_min.y = 96; 88 pdev->view_min.y = 96;
89 pdev->view_max.x = 352; 89 pdev->view_max.x = 352;
90 pdev->view_max.y = 288; 90 pdev->view_max.y = 288;
91 pdev->abs_max.x = 352; 91 pdev->abs_max.x = 352;
92 pdev->abs_max.y = 288; 92 pdev->abs_max.y = 288;
93 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF; 93 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
94 pdev->vcinterface = 2; 94 pdev->vcinterface = 2;
95 pdev->vendpoint = 4; 95 pdev->vendpoint = 4;
@@ -105,8 +105,8 @@ void pwc_construct(struct pwc_device *pdev)
105 pdev->view_max.x = 640; 105 pdev->view_max.x = 640;
106 pdev->view_max.y = 480; 106 pdev->view_max.y = 480;
107 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA; 107 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
108 pdev->abs_max.x = 640; 108 pdev->abs_max.x = 640;
109 pdev->abs_max.y = 480; 109 pdev->abs_max.y = 480;
110 pdev->vcinterface = 3; 110 pdev->vcinterface = 3;
111 pdev->vendpoint = 4; 111 pdev->vendpoint = 4;
112 pdev->frame_header_size = 0; 112 pdev->frame_header_size = 0;
@@ -121,8 +121,8 @@ void pwc_construct(struct pwc_device *pdev)
121 pdev->view_max.x = 640; 121 pdev->view_max.x = 640;
122 pdev->view_max.y = 480; 122 pdev->view_max.y = 480;
123 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA; 123 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
124 pdev->abs_max.x = 640; 124 pdev->abs_max.x = 640;
125 pdev->abs_max.y = 480; 125 pdev->abs_max.y = 480;
126 pdev->vcinterface = 3; 126 pdev->vcinterface = 3;
127 pdev->vendpoint = 5; 127 pdev->vendpoint = 5;
128 pdev->frame_header_size = TOUCAM_HEADER_SIZE; 128 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 e6c5cb69d03b..168c73ef75d8 100644
--- a/drivers/usb/media/pwc/pwc-nala.h
+++ b/drivers/media/video/pwc/pwc-nala.h
@@ -54,7 +54,7 @@
54 {0}, 54 {0},
55 }, 55 },
56 /* VGA */ 56 /* VGA */
57 { 57 {
58 {0}, 58 {0},
59 {0}, 59 {0},
60 {0}, 60 {0},
diff --git a/drivers/media/video/pwc/pwc-timon.c b/drivers/media/video/pwc/pwc-timon.c
new file mode 100644
index 000000000000..175250d089cf
--- /dev/null
+++ b/drivers/media/video/pwc/pwc-timon.c
@@ -0,0 +1,316 @@
1/* Linux driver for Philips webcam
2 (C) 2004 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26/* This tables contains entries for the 675/680/690 (Timon) camera, with
27 4 different qualities (no compression, low, medium, high).
28 It lists the bandwidth requirements for said mode by its alternate interface
29 number. An alternate of 0 means that the mode is unavailable.
30
31 There are 6 * 4 * 4 entries:
32 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
33 6 framerates: 5, 10, 15, 20, 25, 30
34 4 compression modi: none, low, medium, high
35
36 When an uncompressed mode is not available, the next available compressed mode
37 will be chosen (unless the decompressor is absent). Sometimes there are only
38 1 or 2 compressed modes available; in that case entries are duplicated.
39*/
40
41#include "pwc-timon.h"
42
43const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
44{
45 /* SQCIF */
46 {
47 /* 5 fps */
48 {
49 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
50 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
51 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
52 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
53 },
54 /* 10 fps */
55 {
56 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
57 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
58 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
59 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
60 },
61 /* 15 fps */
62 {
63 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
64 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
65 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
66 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
67 },
68 /* 20 fps */
69 {
70 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
71 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
72 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
73 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
74 },
75 /* 25 fps */
76 {
77 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
78 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
79 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
80 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
81 },
82 /* 30 fps */
83 {
84 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
85 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
86 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
87 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
88 },
89 },
90 /* QSIF */
91 {
92 /* 5 fps */
93 {
94 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
95 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
96 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
97 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
98 },
99 /* 10 fps */
100 {
101 {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
102 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
103 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
104 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
105 },
106 /* 15 fps */
107 {
108 {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
109 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
110 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
111 {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
112 },
113 /* 20 fps */
114 {
115 {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
116 {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
117 {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
118 {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
119 },
120 /* 25 fps */
121 {
122 {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
123 {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
124 {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
125 {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
126 },
127 /* 30 fps */
128 {
129 {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
130 {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
131 {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
132 {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
133 },
134 },
135 /* QCIF */
136 {
137 /* 5 fps */
138 {
139 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
140 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
141 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
142 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
143 },
144 /* 10 fps */
145 {
146 {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
147 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
148 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
149 {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
150 },
151 /* 15 fps */
152 {
153 {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
154 {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
155 {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
156 {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
157 },
158 /* 20 fps */
159 {
160 {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
161 {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
162 {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
163 {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
164 },
165 /* 25 fps */
166 {
167 {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
168 {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
169 {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
170 {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
171 },
172 /* 30 fps */
173 {
174 {0, },
175 {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
176 {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
177 {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
178 },
179 },
180 /* SIF */
181 {
182 /* 5 fps */
183 {
184 {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
185 {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
186 {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
187 {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
188 },
189 /* 10 fps */
190 {
191 {0, },
192 {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
193 {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
194 {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
195 },
196 /* 15 fps */
197 {
198 {0, },
199 {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
200 {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
201 {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
202 },
203 /* 20 fps */
204 {
205 {0, },
206 {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
207 {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
208 {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
209 },
210 /* 25 fps */
211 {
212 {0, },
213 {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
214 {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
215 {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
216 },
217 /* 30 fps */
218 {
219 {0, },
220 {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
221 {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
222 {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
223 },
224 },
225 /* CIF */
226 {
227 /* 5 fps */
228 {
229 {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
230 {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
231 {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
232 {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
233 },
234 /* 10 fps */
235 {
236 {0, },
237 {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
238 {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
239 {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
240 },
241 /* 15 fps */
242 {
243 {0, },
244 {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
245 {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
246 {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
247 },
248 /* 20 fps */
249 {
250 {0, },
251 {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
252 {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
253 {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
254 },
255 /* 25 fps */
256 {
257 {0, },
258 {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
259 {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
260 {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
261 },
262 /* 30 fps */
263 {
264 {0, },
265 {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
266 {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
267 {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
268 },
269 },
270 /* VGA */
271 {
272 /* 5 fps */
273 {
274 {0, },
275 {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
276 {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
277 {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
278 },
279 /* 10 fps */
280 {
281 {0, },
282 {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
283 {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
284 {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
285 },
286 /* 15 fps */
287 {
288 {0, },
289 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
290 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
291 {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
292 },
293 /* 20 fps */
294 {
295 {0, },
296 {0, },
297 {0, },
298 {0, },
299 },
300 /* 25 fps */
301 {
302 {0, },
303 {0, },
304 {0, },
305 {0, },
306 },
307 /* 30 fps */
308 {
309 {0, },
310 {0, },
311 {0, },
312 {0, },
313 },
314 },
315};
316
diff --git a/drivers/usb/media/pwc/pwc-timon.h b/drivers/media/video/pwc/pwc-timon.h
index a86b3782a081..a86b3782a081 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 ef4204eab6c4..b37a89a163f9 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)
109 in planar format immediately. 109 in planar format immediately.
110 */ 110 */
111 int flags; 111 int flags;
112 112
113 flags = PWCX_FLAG_PLANAR; 113 flags = PWCX_FLAG_PLANAR;
114 if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot) 114 if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
115 { 115 {
116 printk(KERN_ERR "pwc: Mode Bayer is not supported for now\n"); 116 printk(KERN_ERR "pwc: Mode Bayer is not supported for now\n");
117 flags |= PWCX_FLAG_BAYER; 117 flags |= PWCX_FLAG_BAYER;
diff --git a/drivers/usb/media/pwc/pwc-uncompress.h b/drivers/media/video/pwc/pwc-uncompress.h
index d3b9250e4ed3..f75e1b6cbe19 100644
--- a/drivers/usb/media/pwc/pwc-uncompress.h
+++ b/drivers/media/video/pwc/pwc-uncompress.h
@@ -24,7 +24,7 @@
24 24
25/* This file is the bridge between the kernel module and the plugin; it 25/* This file is the bridge between the kernel module and the plugin; it
26 describes the structures and datatypes used in both modules. Any 26 describes the structures and datatypes used in both modules. Any
27 significant change should be reflected by increasing the 27 significant change should be reflected by increasing the
28 pwc_decompressor_version major number. 28 pwc_decompressor_version major number.
29 */ 29 */
30#ifndef PWC_UNCOMPRESS_H 30#ifndef PWC_UNCOMPRESS_H
diff --git a/drivers/usb/media/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 6dd76bb3dff1..1b0ee0ced0ed 100644
--- a/drivers/usb/media/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -123,7 +123,7 @@ struct pwc_device
123#endif 123#endif
124 /* Pointer to our usb_device */ 124 /* Pointer to our usb_device */
125 struct usb_device *udev; 125 struct usb_device *udev;
126 126
127 int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */ 127 int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */
128 int release; /* release number */ 128 int release; /* release number */
129 int features; /* feature bits */ 129 int features; /* feature bits */
@@ -149,7 +149,7 @@ struct pwc_device
149 char vsnapshot; /* snapshot mode */ 149 char vsnapshot; /* snapshot mode */
150 char vsync; /* used by isoc handler */ 150 char vsync; /* used by isoc handler */
151 char vmirror; /* for ToUCaM series */ 151 char vmirror; /* for ToUCaM series */
152 152
153 int cmd_len; 153 int cmd_len;
154 unsigned char cmd_buf[13]; 154 unsigned char cmd_buf[13];
155 155
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index a9f3cf0b1e3c..531e9461cb66 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -71,7 +71,7 @@
71#define NUM_BUFS 8 71#define NUM_BUFS 8
72#define IF_NAME "SAA5249" 72#define IF_NAME "SAA5249"
73 73
74static const int disp_modes[8][3] = 74static const int disp_modes[8][3] =
75{ 75{
76 { 0x46, 0x03, 0x03 }, /* DISPOFF */ 76 { 0x46, 0x03, 0x03 }, /* DISPOFF */
77 { 0x46, 0xcc, 0xcc }, /* DISPNORM */ 77 { 0x46, 0xcc, 0xcc }, /* DISPNORM */
@@ -150,8 +150,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
150 client=kmalloc(sizeof(*client), GFP_KERNEL); 150 client=kmalloc(sizeof(*client), GFP_KERNEL);
151 if(client==NULL) 151 if(client==NULL)
152 return -ENOMEM; 152 return -ENOMEM;
153 client_template.adapter = adap; 153 client_template.adapter = adap;
154 client_template.addr = addr; 154 client_template.addr = addr;
155 memcpy(client, &client_template, sizeof(*client)); 155 memcpy(client, &client_template, sizeof(*client));
156 t = kzalloc(sizeof(*t), GFP_KERNEL); 156 t = kzalloc(sizeof(*t), GFP_KERNEL);
157 if(t==NULL) 157 if(t==NULL)
@@ -161,11 +161,11 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
161 } 161 }
162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
163 mutex_init(&t->lock); 163 mutex_init(&t->lock);
164 164
165 /* 165 /*
166 * Now create a video4linux device 166 * Now create a video4linux device
167 */ 167 */
168 168
169 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL); 169 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL);
170 if(vd==NULL) 170 if(vd==NULL)
171 { 171 {
@@ -175,8 +175,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
175 } 175 }
176 i2c_set_clientdata(client, vd); 176 i2c_set_clientdata(client, vd);
177 memcpy(vd, &saa_template, sizeof(*vd)); 177 memcpy(vd, &saa_template, sizeof(*vd));
178 178
179 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 179 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
180 { 180 {
181 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 181 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
182 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 182 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)
186 t->vdau[pgbuf].stopped = TRUE; 186 t->vdau[pgbuf].stopped = TRUE;
187 t->is_searching[pgbuf] = FALSE; 187 t->is_searching[pgbuf] = FALSE;
188 } 188 }
189 vd->priv=t; 189 vd->priv=t;
190 190
191 191
192 /* 192 /*
193 * Register it 193 * Register it
194 */ 194 */
@@ -208,7 +208,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
208/* 208/*
209 * We do most of the hard work when we become a device on the i2c. 209 * We do most of the hard work when we become a device on the i2c.
210 */ 210 */
211 211
212static int saa5249_probe(struct i2c_adapter *adap) 212static int saa5249_probe(struct i2c_adapter *adap)
213{ 213{
214 if (adap->class & I2C_CLASS_TV_ANALOG) 214 if (adap->class & I2C_CLASS_TV_ANALOG)
@@ -229,7 +229,7 @@ static int saa5249_detach(struct i2c_client *client)
229 229
230/* new I2C driver support */ 230/* new I2C driver support */
231 231
232static struct i2c_driver i2c_driver_videotext = 232static struct i2c_driver i2c_driver_videotext =
233{ 233{
234 .driver = { 234 .driver = {
235 .name = IF_NAME, /* name */ 235 .name = IF_NAME, /* name */
@@ -249,7 +249,7 @@ static struct i2c_client client_template = {
249 * delay may be longer. 249 * delay may be longer.
250 */ 250 */
251 251
252static void jdelay(unsigned long delay) 252static void jdelay(unsigned long delay)
253{ 253{
254 sigset_t oldblocked = current->blocked; 254 sigset_t oldblocked = current->blocked;
255 255
@@ -269,14 +269,14 @@ static void jdelay(unsigned long delay)
269/* 269/*
270 * I2C interfaces 270 * I2C interfaces
271 */ 271 */
272 272
273static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data) 273static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data)
274{ 274{
275 char buf[64]; 275 char buf[64];
276 276
277 buf[0] = reg; 277 buf[0] = reg;
278 memcpy(buf+1, data, count); 278 memcpy(buf+1, data, count);
279 279
280 if(i2c_master_send(t->client, buf, count+1)==count+1) 280 if(i2c_master_send(t->client, buf, count+1)==count+1)
281 return 0; 281 return 0;
282 return -1; 282 return -1;
@@ -289,7 +289,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
289 int ct=0; 289 int ct=0;
290 va_list argp; 290 va_list argp;
291 va_start(argp,t); 291 va_start(argp,t);
292 292
293 while((v=va_arg(argp,int))!=-1) 293 while((v=va_arg(argp,int))!=-1)
294 buf[ct++]=v; 294 buf[ct++]=v;
295 return i2c_sendbuf(t, buf[0], ct-1, buf+1); 295 return i2c_sendbuf(t, buf[0], ct-1, buf+1);
@@ -301,7 +301,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
301 * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise 301 * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise
302 */ 302 */
303 303
304static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf) 304static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf)
305{ 305{
306 if(i2c_master_recv(t->client, buf, count)!=count) 306 if(i2c_master_recv(t->client, buf, count)!=count)
307 return -1; 307 return -1;
@@ -320,9 +320,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
320 struct video_device *vd = video_devdata(file); 320 struct video_device *vd = video_devdata(file);
321 struct saa5249_device *t=vd->priv; 321 struct saa5249_device *t=vd->priv;
322 322
323 switch(cmd) 323 switch(cmd)
324 { 324 {
325 case VTXIOCGETINFO: 325 case VTXIOCGETINFO:
326 { 326 {
327 vtx_info_t *info = arg; 327 vtx_info_t *info = arg;
328 info->version_major = VTX_VER_MAJ; 328 info->version_major = VTX_VER_MAJ;
@@ -332,10 +332,10 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
332 return 0; 332 return 0;
333 } 333 }
334 334
335 case VTXIOCCLRPAGE: 335 case VTXIOCCLRPAGE:
336 { 336 {
337 vtx_pagereq_t *req = arg; 337 vtx_pagereq_t *req = arg;
338 338
339 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 339 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
340 return -EINVAL; 340 return -EINVAL;
341 memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 341 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,
343 return 0; 343 return 0;
344 } 344 }
345 345
346 case VTXIOCCLRFOUND: 346 case VTXIOCCLRFOUND:
347 { 347 {
348 vtx_pagereq_t *req = arg; 348 vtx_pagereq_t *req = arg;
349 349
350 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 350 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
351 return -EINVAL; 351 return -EINVAL;
352 t->vdau[req->pgbuf].clrfound = TRUE; 352 t->vdau[req->pgbuf].clrfound = TRUE;
353 return 0; 353 return 0;
354 } 354 }
355 355
356 case VTXIOCPAGEREQ: 356 case VTXIOCPAGEREQ:
357 { 357 {
358 vtx_pagereq_t *req = arg; 358 vtx_pagereq_t *req = arg;
359 if (!(req->pagemask & PGMASK_PAGE)) 359 if (!(req->pagemask & PGMASK_PAGE))
@@ -381,7 +381,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
381 return 0; 381 return 0;
382 } 382 }
383 383
384 case VTXIOCGETSTAT: 384 case VTXIOCGETSTAT:
385 { 385 {
386 vtx_pagereq_t *req = arg; 386 vtx_pagereq_t *req = arg;
387 u8 infobits[10]; 387 u8 infobits[10];
@@ -390,7 +390,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
390 390
391 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 391 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
392 return -EINVAL; 392 return -EINVAL;
393 if (!t->vdau[req->pgbuf].stopped) 393 if (!t->vdau[req->pgbuf].stopped)
394 { 394 {
395 if (i2c_senddata(t, 2, 0, -1) || 395 if (i2c_senddata(t, 2, 0, -1) ||
396 i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) || 396 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,
403 return -EIO; 403 return -EIO;
404 404
405 if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */ 405 if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */
406 (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) || 406 (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) ||
407 time_after_eq(jiffies, t->vdau[req->pgbuf].expire))) 407 time_after_eq(jiffies, t->vdau[req->pgbuf].expire)))
408 { /* check if new page arrived */ 408 { /* check if new page arrived */
409 if (i2c_senddata(t, 8, 0, 0, 0, -1) || 409 if (i2c_senddata(t, 8, 0, 0, 0, -1) ||
@@ -411,7 +411,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
411 return -EIO; 411 return -EIO;
412 t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE; 412 t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE;
413 memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE); 413 memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE);
414 if (t->virtual_mode) 414 if (t->virtual_mode)
415 { 415 {
416 /* Packet X/24 */ 416 /* Packet X/24 */
417 if (i2c_senddata(t, 8, 0, 0x20, 0, -1) || 417 if (i2c_senddata(t, 8, 0, 0x20, 0, -1) ||
@@ -459,9 +459,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
459 info.notfound = !!(infobits[8] & 0x10); 459 info.notfound = !!(infobits[8] & 0x10);
460 info.pblf = !!(infobits[9] & 0x20); 460 info.pblf = !!(infobits[9] & 0x20);
461 info.hamming = 0; 461 info.hamming = 0;
462 for (a = 0; a <= 7; a++) 462 for (a = 0; a <= 7; a++)
463 { 463 {
464 if (infobits[a] & 0xf0) 464 if (infobits[a] & 0xf0)
465 { 465 {
466 info.hamming = 1; 466 info.hamming = 1;
467 break; 467 break;
@@ -471,14 +471,14 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
471 info.notfound = 1; 471 info.notfound = 1;
472 if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t))) 472 if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t)))
473 return -EFAULT; 473 return -EFAULT;
474 if (!info.hamming && !info.notfound) 474 if (!info.hamming && !info.notfound)
475 { 475 {
476 t->is_searching[req->pgbuf] = FALSE; 476 t->is_searching[req->pgbuf] = FALSE;
477 } 477 }
478 return 0; 478 return 0;
479 } 479 }
480 480
481 case VTXIOCGETPAGE: 481 case VTXIOCGETPAGE:
482 { 482 {
483 vtx_pagereq_t *req = arg; 483 vtx_pagereq_t *req = arg;
484 int start, end; 484 int start, end;
@@ -488,15 +488,15 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
488 return -EINVAL; 488 return -EINVAL;
489 if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1)) 489 if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1))
490 return -EFAULT; 490 return -EFAULT;
491 491
492 /* 492 /*
493 * Always read the time directly from SAA5249 493 * Always read the time directly from SAA5249
494 */ 494 */
495 495
496 if (req->start <= 39 && req->end >= 32) 496 if (req->start <= 39 && req->end >= 32)
497 { 497 {
498 int len; 498 int len;
499 char buf[16]; 499 char buf[16];
500 start = max(req->start, 32); 500 start = max(req->start, 32);
501 end = min(req->end, 39); 501 end = min(req->end, 39);
502 len=end-start+1; 502 len=end-start+1;
@@ -507,7 +507,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
507 return -EFAULT; 507 return -EFAULT;
508 } 508 }
509 /* Insert the current header if DAU is still searching for a page */ 509 /* Insert the current header if DAU is still searching for a page */
510 if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf]) 510 if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf])
511 { 511 {
512 char buf[32]; 512 char buf[32];
513 int len; 513 int len;
@@ -523,7 +523,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
523 return 0; 523 return 0;
524 } 524 }
525 525
526 case VTXIOCSTOPDAU: 526 case VTXIOCSTOPDAU:
527 { 527 {
528 vtx_pagereq_t *req = arg; 528 vtx_pagereq_t *req = arg;
529 529
@@ -534,12 +534,12 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
534 return 0; 534 return 0;
535 } 535 }
536 536
537 case VTXIOCPUTPAGE: 537 case VTXIOCPUTPAGE:
538 case VTXIOCSETDISP: 538 case VTXIOCSETDISP:
539 case VTXIOCPUTSTAT: 539 case VTXIOCPUTSTAT:
540 return 0; 540 return 0;
541 541
542 case VTXIOCCLRCACHE: 542 case VTXIOCCLRCACHE:
543 { 543 {
544 if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11, 544 if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11,
545 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', 545 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
@@ -551,7 +551,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
551 return 0; 551 return 0;
552 } 552 }
553 553
554 case VTXIOCSETVIRT: 554 case VTXIOCSETVIRT:
555 { 555 {
556 /* The SAA5249 has virtual-row reception turned on always */ 556 /* The SAA5249 has virtual-row reception turned on always */
557 t->virtual_mode = (int)(long)arg; 557 t->virtual_mode = (int)(long)arg;
@@ -612,14 +612,14 @@ static inline unsigned int vtx_fix_command(unsigned int cmd)
612/* 612/*
613 * Handle the locking 613 * Handle the locking
614 */ 614 */
615 615
616static int saa5249_ioctl(struct inode *inode, struct file *file, 616static int saa5249_ioctl(struct inode *inode, struct file *file,
617 unsigned int cmd, unsigned long arg) 617 unsigned int cmd, unsigned long arg)
618{ 618{
619 struct video_device *vd = video_devdata(file); 619 struct video_device *vd = video_devdata(file);
620 struct saa5249_device *t=vd->priv; 620 struct saa5249_device *t=vd->priv;
621 int err; 621 int err;
622 622
623 cmd = vtx_fix_command(cmd); 623 cmd = vtx_fix_command(cmd);
624 mutex_lock(&t->lock); 624 mutex_lock(&t->lock);
625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); 625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl);
@@ -627,7 +627,7 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
627 return err; 627 return err;
628} 628}
629 629
630static int saa5249_open(struct inode *inode, struct file *file) 630static int saa5249_open(struct inode *inode, struct file *file)
631{ 631{
632 struct video_device *vd = video_devdata(file); 632 struct video_device *vd = video_devdata(file);
633 struct saa5249_device *t=vd->priv; 633 struct saa5249_device *t=vd->priv;
@@ -636,7 +636,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
636 err = video_exclusive_open(inode,file); 636 err = video_exclusive_open(inode,file);
637 if (err < 0) 637 if (err < 0)
638 return err; 638 return err;
639 639
640 if (t->client==NULL) { 640 if (t->client==NULL) {
641 err = -ENODEV; 641 err = -ENODEV;
642 goto fail; 642 goto fail;
@@ -647,13 +647,13 @@ static int saa5249_open(struct inode *inode, struct file *file)
647 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) || 647 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
648 /* Display TV-picture, no virtual rows */ 648 /* Display TV-picture, no virtual rows */
649 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 */ 649 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 */
650 650
651 { 651 {
652 err = -EIO; 652 err = -EIO;
653 goto fail; 653 goto fail;
654 } 654 }
655 655
656 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 656 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
657 { 657 {
658 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 658 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
659 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 659 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)
673 673
674 674
675 675
676static int saa5249_release(struct inode *inode, struct file *file) 676static int saa5249_release(struct inode *inode, struct file *file)
677{ 677{
678 struct video_device *vd = video_devdata(file); 678 struct video_device *vd = video_devdata(file);
679 struct saa5249_device *t=vd->priv; 679 struct saa5249_device *t=vd->priv;
@@ -690,7 +690,7 @@ static int __init init_saa_5249 (void)
690 return i2c_add_driver(&i2c_driver_videotext); 690 return i2c_add_driver(&i2c_driver_videotext);
691} 691}
692 692
693static void __exit cleanup_saa_5249 (void) 693static void __exit cleanup_saa_5249 (void)
694{ 694{
695 i2c_del_driver(&i2c_driver_videotext); 695 i2c_del_driver(&i2c_driver_videotext);
696} 696}
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index d17395c4f55c..a81285ca7d5b 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -32,7 +32,7 @@
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33 33
34 34
35#include "rds.h" 35#include <media/rds.h>
36 36
37/* Addresses to scan */ 37/* Addresses to scan */
38static unsigned short normal_i2c[] = { 38static unsigned short normal_i2c[] = {
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index e18ea268384b..41d951db6ec0 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -139,7 +139,7 @@ saa7110_read (struct i2c_client *client)
139 139
140static int 140static int
141saa7110_selmux (struct i2c_client *client, 141saa7110_selmux (struct i2c_client *client,
142 int chan) 142 int chan)
143{ 143{
144 static const unsigned char modes[9][8] = { 144 static const unsigned char modes[9][8] = {
145 /* mode 0 */ 145 /* mode 0 */
@@ -457,7 +457,7 @@ static unsigned short normal_i2c[] = {
457}; 457};
458 458
459static unsigned short ignore = I2C_CLIENT_END; 459static unsigned short ignore = I2C_CLIENT_END;
460 460
461static struct i2c_client_address_data addr_data = { 461static struct i2c_client_address_data addr_data = {
462 .normal_i2c = normal_i2c, 462 .normal_i2c = normal_i2c,
463 .probe = &ignore, 463 .probe = &ignore,
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index f9ba0c943adf..686fd4746205 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * saa7111 - Philips SAA7111A video decoder driver version 0.0.3 2 * saa7111 - Philips SAA7111A video decoder driver version 0.0.3
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -482,7 +482,7 @@ saa7111_command (struct i2c_client *client,
482static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; 482static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END };
483 483
484static unsigned short ignore = I2C_CLIENT_END; 484static unsigned short ignore = I2C_CLIENT_END;
485 485
486static struct i2c_client_address_data addr_data = { 486static struct i2c_client_address_data addr_data = {
487 .normal_i2c = normal_i2c, 487 .normal_i2c = normal_i2c,
488 .probe = &ignore, 488 .probe = &ignore,
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 4a1f841d0c77..90398ab8252e 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * saa7114 - Philips SAA7114H video decoder driver version 0.0.1 2 * saa7114 - Philips SAA7114H video decoder driver version 0.0.1
3 * 3 *
4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com> 4 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
@@ -300,7 +300,7 @@ static const unsigned char init[] = {
300 0x55, 0xff, 300 0x55, 0xff,
301 0x56, 0xff, 301 0x56, 0xff,
302 0x57, 0xff, 302 0x57, 0xff,
303 0x58, 0x40, // framing code 303 0x58, 0x40, // framing code
304 0x59, 0x47, // horizontal offset 304 0x59, 0x47, // horizontal offset
305 0x5a, 0x06, // vertical offset 305 0x5a, 0x06, // vertical offset
306 0x5b, 0x83, // field offset 306 0x5b, 0x83, // field offset
@@ -345,7 +345,7 @@ static const unsigned char init[] = {
345 0x82, 0x00, 345 0x82, 0x00,
346 0x83, 0x00, 346 0x83, 0x00,
347 0x84, 0xc5, 347 0x84, 0xc5,
348 0x85, 0x0d, // hsync and vsync ? 348 0x85, 0x0d, // hsync and vsync ?
349 0x86, 0x40, 349 0x86, 0x40,
350 0x87, 0x01, 350 0x87, 0x01,
351 0x88, 0x00, 351 0x88, 0x00,
@@ -434,7 +434,7 @@ static const unsigned char init[] = {
434 0xd9, 0x04, 434 0xd9, 0x04,
435 0xda, 0x00, // horizontal luminance phase offset 435 0xda, 0x00, // horizontal luminance phase offset
436 0xdb, 0x00, 436 0xdb, 0x00,
437 0xdc, 0x00, // horizontal chrominance scaling increment 437 0xdc, 0x00, // horizontal chrominance scaling increment
438 0xdd, 0x02, 438 0xdd, 0x02,
439 0xde, 0x00, // horizontal chrominance phase offset 439 0xde, 0x00, // horizontal chrominance phase offset
440 0xdf, 0x00, 440 0xdf, 0x00,
@@ -754,7 +754,7 @@ saa7114_command (struct i2c_client *client,
754 saa7114_write(client, 0x87, 754 saa7114_write(client, 0x87,
755 decoder->reg[REG_ADDR(0x87)]); 755 decoder->reg[REG_ADDR(0x87)]);
756 saa7114_write(client, 0x88, 0xd8); // sw reset scaler 756 saa7114_write(client, 0x88, 0xd8); // sw reset scaler
757 saa7114_write(client, 0x88, 0xf8); // sw reset scaler release 757 saa7114_write(client, 0x88, 0xf8); // sw reset scaler release
758 saa7114_write(client, 0x80, 0x36); 758 saa7114_write(client, 0x80, 0x36);
759 759
760 } 760 }
@@ -813,7 +813,7 @@ static unsigned short normal_i2c[] =
813 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; 813 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END };
814 814
815static unsigned short ignore = I2C_CLIENT_END; 815static unsigned short ignore = I2C_CLIENT_END;
816 816
817static struct i2c_client_address_data addr_data = { 817static struct i2c_client_address_data addr_data = {
818 .normal_i2c = normal_i2c, 818 .normal_i2c = normal_i2c,
819 .probe = &ignore, 819 .probe = &ignore,
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index b184fd00b4e7..b05015282601 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -40,7 +40,6 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/videodev2.h> 41#include <linux/videodev2.h>
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/audiochip.h>
44#include <asm/div64.h> 43#include <asm/div64.h>
45 44
46MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver"); 45MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver");
diff --git a/drivers/media/video/saa7121.h b/drivers/media/video/saa7121.h
index 74e37d405208..66967ae37494 100644
--- a/drivers/media/video/saa7121.h
+++ b/drivers/media/video/saa7121.h
@@ -64,7 +64,7 @@
64#define PAL_MSB_VERTICAL 0x40 /* 7c */ 64#define PAL_MSB_VERTICAL 0x40 /* 7c */
65 65
66/* Initialization Sequence */ 66/* Initialization Sequence */
67 67
68static __u8 init7121ntsc[] = { 68static __u8 init7121ntsc[] = {
69 0x26, 0x0, 0x27, 0x0, 69 0x26, 0x0, 0x27, 0x0,
70 0x28, NTSC_BURST_START, 0x29, NTSC_BURST_END, 70 0x28, NTSC_BURST_START, 0x29, NTSC_BURST_END,
@@ -95,7 +95,7 @@ static __u8 init7121ntsc[] = {
95 0x78, 0x0, 0x79, 0x0, 0x7a, NTSC_FIRST_ACTIVE, 95 0x78, 0x0, 0x79, 0x0, 0x7a, NTSC_FIRST_ACTIVE,
96 0x7b, NTSC_LAST_ACTIVE, 0x7c, NTSC_MSB_VERTICAL, 96 0x7b, NTSC_LAST_ACTIVE, 0x7c, NTSC_MSB_VERTICAL,
97 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0 97 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0
98}; 98};
99#define INIT7121LEN (sizeof(init7121ntsc)/2) 99#define INIT7121LEN (sizeof(init7121ntsc)/2)
100 100
101static __u8 init7121pal[] = { 101static __u8 init7121pal[] = {
@@ -128,5 +128,5 @@ static __u8 init7121pal[] = {
128 0x78, 0x0, 0x79, 0x0, 0x7a, PAL_FIRST_ACTIVE, 128 0x78, 0x0, 0x79, 0x0, 0x7a, PAL_FIRST_ACTIVE,
129 0x7b, PAL_LAST_ACTIVE, 0x7c, PAL_MSB_VERTICAL, 129 0x7b, PAL_LAST_ACTIVE, 0x7c, PAL_MSB_VERTICAL,
130 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0 130 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0
131}; 131};
132#endif 132#endif
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index aca84d2f9825..bb3e0ba946d3 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,
507 /* release the old buffer */ 507 /* release the old buffer */
508 if (substream->runtime->dma_area) { 508 if (substream->runtime->dma_area) {
509 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); 509 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
510 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 510 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
511 dsp_buffer_free(dev); 511 dsp_buffer_free(dev);
512 substream->runtime->dma_area = NULL; 512 substream->runtime->dma_area = NULL;
513 } 513 }
@@ -523,12 +523,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
523 return err; 523 return err;
524 } 524 }
525 525
526 if (0 != (err = videobuf_dma_pci_map(dev->pci, &dev->dmasound.dma))) { 526 if (0 != (err = videobuf_pci_dma_map(dev->pci, &dev->dmasound.dma))) {
527 dsp_buffer_free(dev); 527 dsp_buffer_free(dev);
528 return err; 528 return err;
529 } 529 }
530 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) { 530 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
531 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 531 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
532 dsp_buffer_free(dev); 532 dsp_buffer_free(dev);
533 return err; 533 return err;
534 } 534 }
@@ -537,7 +537,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
537 dev->dmasound.dma.sglen, 537 dev->dmasound.dma.sglen,
538 0))) { 538 0))) {
539 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); 539 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
540 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 540 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
541 dsp_buffer_free(dev); 541 dsp_buffer_free(dev);
542 return err; 542 return err;
543 } 543 }
@@ -571,7 +571,7 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream)
571 571
572 if (substream->runtime->dma_area) { 572 if (substream->runtime->dma_area) {
573 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); 573 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
574 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 574 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
575 dsp_buffer_free(dev); 575 dsp_buffer_free(dev);
576 substream->runtime->dma_area = NULL; 576 substream->runtime->dma_area = NULL;
577 } 577 }
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 58e568d7d2ee..c98571c9d5a6 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)
254 254
255/* ------------------------------------------------------------------ */ 255/* ------------------------------------------------------------------ */
256 256
257void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf) 257void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf)
258{ 258{
259 BUG_ON(in_interrupt()); 259 BUG_ON(in_interrupt());
260 260
261 videobuf_waiton(&buf->vb,0,0); 261 videobuf_waiton(&buf->vb,0,0);
262 videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma); 262 videobuf_dma_unmap(q, &buf->vb.dma);
263 videobuf_dma_free(&buf->vb.dma); 263 videobuf_dma_free(&buf->vb.dma);
264 buf->vb.state = STATE_NEEDS_INIT; 264 buf->vb.state = STATE_NEEDS_INIT;
265} 265}
@@ -960,7 +960,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
960 if (saa7134_no_overlay <= 0) { 960 if (saa7134_no_overlay <= 0) {
961 saa7134_video_template.type |= VID_TYPE_OVERLAY; 961 saa7134_video_template.type |= VID_TYPE_OVERLAY;
962 } else { 962 } else {
963 printk("bttv: Overlay support disabled.\n"); 963 printk("%s: Overlay support disabled.\n",dev->name);
964 } 964 }
965 dev->video_dev = vdev_init(dev,&saa7134_video_template,"video"); 965 dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
966 err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, 966 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 d79d05f88705..7aa02b34e012 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)
124 unsigned long flags; 124 unsigned long flags;
125 125
126 /* prepare buffer */ 126 /* prepare buffer */
127 if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma))) 127 if (0 != (err = videobuf_pci_dma_map(dev->pci,&dev->dmasound.dma)))
128 return err; 128 return err;
129 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) 129 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
130 goto fail1; 130 goto fail1;
@@ -213,7 +213,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
213 fail2: 213 fail2:
214 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); 214 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
215 fail1: 215 fail1:
216 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); 216 videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
217 return err; 217 return err;
218} 218}
219 219
@@ -231,7 +231,7 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
231 231
232 /* unlock buffer */ 232 /* unlock buffer */
233 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); 233 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
234 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); 234 videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
235 return 0; 235 return 0;
236} 236}
237 237
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index 470903e2f5e5..60a90a2617ae 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,
89 return -EINVAL; 89 return -EINVAL;
90 90
91 if (buf->vb.size != size) { 91 if (buf->vb.size != size) {
92 saa7134_dma_free(dev,buf); 92 saa7134_dma_free(q,buf);
93 } 93 }
94 94
95 if (STATE_NEEDS_INIT == buf->vb.state) { 95 if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -98,7 +98,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
98 buf->vb.size = size; 98 buf->vb.size = size;
99 buf->pt = &dev->ts.pt_ts; 99 buf->pt = &dev->ts.pt_ts;
100 100
101 err = videobuf_iolock(dev->pci,&buf->vb,NULL); 101 err = videobuf_iolock(q,&buf->vb,NULL);
102 if (err) 102 if (err)
103 goto oops; 103 goto oops;
104 err = saa7134_pgtable_build(dev->pci,buf->pt, 104 err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -126,7 +126,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
126 return 0; 126 return 0;
127 127
128 oops: 128 oops:
129 saa7134_dma_free(dev,buf); 129 saa7134_dma_free(q,buf);
130 return err; 130 return err;
131} 131}
132 132
@@ -152,10 +152,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
152 152
153static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 153static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
154{ 154{
155 struct saa7134_dev *dev = q->priv_data;
156 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 155 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
157 156
158 saa7134_dma_free(dev,buf); 157 saa7134_dma_free(q,buf);
159} 158}
160 159
161struct videobuf_queue_ops saa7134_ts_qops = { 160struct 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 3043233a8b6e..0db53d192b2a 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
482 [ V4L2_TUNER_MODE_STEREO ] = "stereo", 482 [ V4L2_TUNER_MODE_STEREO ] = "stereo",
483 [ V4L2_TUNER_MODE_LANG1 ] = "lang1", 483 [ V4L2_TUNER_MODE_LANG1 ] = "lang1",
484 [ V4L2_TUNER_MODE_LANG2 ] = "lang2", 484 [ V4L2_TUNER_MODE_LANG2 ] = "lang2",
485 [ V4L2_TUNER_MODE_LANG1_LANG2 ] = "lang1+lang2",
485 }; 486 };
486 static u32 fm[] = { 487 static u32 fm[] = {
487 [ V4L2_TUNER_MODE_MONO ] = 0x00, /* ch1 */ 488 [ V4L2_TUNER_MODE_MONO ] = 0x00, /* ch1 */
488 [ V4L2_TUNER_MODE_STEREO ] = 0x80, /* auto */ 489 [ V4L2_TUNER_MODE_STEREO ] = 0x80, /* auto */
489 [ V4L2_TUNER_MODE_LANG1 ] = 0x00, /* ch1 */ 490 [ V4L2_TUNER_MODE_LANG1 ] = 0x00, /* ch1 */
490 [ V4L2_TUNER_MODE_LANG2 ] = 0x01, /* ch2 */ 491 [ V4L2_TUNER_MODE_LANG2 ] = 0x01, /* ch2 */
492 [ V4L2_TUNER_MODE_LANG1_LANG2 ] = 0x80, /* auto */
491 }; 493 };
492 u32 reg; 494 u32 reg;
493 495
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index f4aee0af80e1..f38366a470fa 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,
135 return -EINVAL; 135 return -EINVAL;
136 136
137 if (buf->vb.size != size) 137 if (buf->vb.size != size)
138 saa7134_dma_free(dev,buf); 138 saa7134_dma_free(q,buf);
139 139
140 if (STATE_NEEDS_INIT == buf->vb.state) { 140 if (STATE_NEEDS_INIT == buf->vb.state) {
141 buf->vb.width = llength; 141 buf->vb.width = llength;
@@ -143,7 +143,7 @@ static int buffer_prepare(struct videobuf_queue *q,
143 buf->vb.size = size; 143 buf->vb.size = size;
144 buf->pt = &fh->pt_vbi; 144 buf->pt = &fh->pt_vbi;
145 145
146 err = videobuf_iolock(dev->pci,&buf->vb,NULL); 146 err = videobuf_iolock(q,&buf->vb,NULL);
147 if (err) 147 if (err)
148 goto oops; 148 goto oops;
149 err = saa7134_pgtable_build(dev->pci,buf->pt, 149 err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -159,7 +159,7 @@ static int buffer_prepare(struct videobuf_queue *q,
159 return 0; 159 return 0;
160 160
161 oops: 161 oops:
162 saa7134_dma_free(dev,buf); 162 saa7134_dma_free(q,buf);
163 return err; 163 return err;
164} 164}
165 165
@@ -190,11 +190,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
190 190
191static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 191static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
192{ 192{
193 struct saa7134_fh *fh = q->priv_data;
194 struct saa7134_dev *dev = fh->dev;
195 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 193 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
196 194
197 saa7134_dma_free(dev,buf); 195 saa7134_dma_free(q,buf);
198} 196}
199 197
200struct videobuf_queue_ops saa7134_vbi_qops = { 198struct 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 57a11e71d996..aeef80f88a6b 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,
993 buf->vb.size != size || 993 buf->vb.size != size ||
994 buf->vb.field != field || 994 buf->vb.field != field ||
995 buf->fmt != fh->fmt) { 995 buf->fmt != fh->fmt) {
996 saa7134_dma_free(dev,buf); 996 saa7134_dma_free(q,buf);
997 } 997 }
998 998
999 if (STATE_NEEDS_INIT == buf->vb.state) { 999 if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1004,7 +1004,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1004 buf->fmt = fh->fmt; 1004 buf->fmt = fh->fmt;
1005 buf->pt = &fh->pt_cap; 1005 buf->pt = &fh->pt_cap;
1006 1006
1007 err = videobuf_iolock(dev->pci,&buf->vb,&dev->ovbuf); 1007 err = videobuf_iolock(q,&buf->vb,&dev->ovbuf);
1008 if (err) 1008 if (err)
1009 goto oops; 1009 goto oops;
1010 err = saa7134_pgtable_build(dev->pci,buf->pt, 1010 err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -1019,7 +1019,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1019 return 0; 1019 return 0;
1020 1020
1021 oops: 1021 oops:
1022 saa7134_dma_free(dev,buf); 1022 saa7134_dma_free(q,buf);
1023 return err; 1023 return err;
1024} 1024}
1025 1025
@@ -1045,10 +1045,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
1045 1045
1046static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 1046static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1047{ 1047{
1048 struct saa7134_fh *fh = q->priv_data;
1049 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 1048 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
1050 1049
1051 saa7134_dma_free(fh->dev,buf); 1050 saa7134_dma_free(q,buf);
1052} 1051}
1053 1052
1054static struct videobuf_queue_ops video_qops = { 1053static struct videobuf_queue_ops video_qops = {
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index ce1c2e0b065e..31ba293854c1 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -34,7 +34,6 @@
34#include <asm/io.h> 34#include <asm/io.h>
35 35
36#include <media/tuner.h> 36#include <media/tuner.h>
37#include <media/audiochip.h>
38#include <media/ir-common.h> 37#include <media/ir-common.h>
39#include <media/ir-kbd-i2c.h> 38#include <media/ir-kbd-i2c.h>
40#include <media/video-buf.h> 39#include <media/video-buf.h>
@@ -579,7 +578,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
579 unsigned int state); 578 unsigned int state);
580void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q); 579void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
581void saa7134_buffer_timeout(unsigned long data); 580void saa7134_buffer_timeout(unsigned long data);
582void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf); 581void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf);
583 582
584int saa7134_set_dmabits(struct saa7134_dev *dev); 583int saa7134_set_dmabits(struct saa7134_dev *dev);
585 584
diff --git a/drivers/media/video/saa7146.h b/drivers/media/video/saa7146.h
index 756963f01bbd..2830b5e33aec 100644
--- a/drivers/media/video/saa7146.h
+++ b/drivers/media/video/saa7146.h
@@ -1,7 +1,7 @@
1/* 1/*
2 saa7146.h - definitions philips saa7146 based cards 2 saa7146.h - definitions philips saa7146 based cards
3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) 3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
@@ -27,7 +27,7 @@
27 27
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29 29
30#ifndef O_NONCAP 30#ifndef O_NONCAP
31#define O_NONCAP O_TRUNC 31#define O_NONCAP O_TRUNC
32#endif 32#endif
33 33
@@ -36,7 +36,7 @@
36 36
37#ifdef __KERNEL__ 37#ifdef __KERNEL__
38 38
39struct saa7146_window 39struct saa7146_window
40{ 40{
41 int x, y; 41 int x, y;
42 ushort width, height; 42 ushort width, height;
@@ -70,7 +70,7 @@ struct saa7146
70 int irqstate; /* irq routine is state driven */ 70 int irqstate; /* irq routine is state driven */
71 int writemode; 71 int writemode;
72 int playmode; 72 int playmode;
73 unsigned int nr; 73 unsigned int nr;
74 unsigned long irq; /* IRQ used by SAA7146 card */ 74 unsigned long irq; /* IRQ used by SAA7146 card */
75 unsigned short id; 75 unsigned short id;
76 unsigned char revision; 76 unsigned char revision;
diff --git a/drivers/media/video/saa7146reg.h b/drivers/media/video/saa7146reg.h
index 6cc910f50a4b..80ec2c146b4c 100644
--- a/drivers/media/video/saa7146reg.h
+++ b/drivers/media/video/saa7146reg.h
@@ -1,7 +1,7 @@
1/* 1/*
2 saa7146.h - definitions philips saa7146 based cards 2 saa7146.h - definitions philips saa7146 based cards
3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) 3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 9f99ee1303e0..9c308410856d 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * saa7185 - Philips SAA7185B video encoder driver version 0.0.3 2 * saa7185 - Philips SAA7185B video encoder driver version 0.0.3
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -377,7 +377,7 @@ saa7185_command (struct i2c_client *client,
377static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; 377static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END };
378 378
379static unsigned short ignore = I2C_CLIENT_END; 379static unsigned short ignore = I2C_CLIENT_END;
380 380
381static struct i2c_client_address_data addr_data = { 381static struct i2c_client_address_data addr_data = {
382 .normal_i2c = normal_i2c, 382 .normal_i2c = normal_i2c,
383 .probe = &ignore, 383 .probe = &ignore,
diff --git a/drivers/media/video/saa7196.h b/drivers/media/video/saa7196.h
index f92f21cfbcac..cd4b6354a7b3 100644
--- a/drivers/media/video/saa7196.h
+++ b/drivers/media/video/saa7196.h
@@ -2,14 +2,14 @@
2 Definitions for the Philips SAA7196 digital video decoder, 2 Definitions for the Philips SAA7196 digital video decoder,
3 scaler, and clock generator circuit (DESCpro), as used in 3 scaler, and clock generator circuit (DESCpro), as used in
4 the PlanB video input of the Powermac 7x00/8x00 series. 4 the PlanB video input of the Powermac 7x00/8x00 series.
5 5
6 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu) 6 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
7 7
8 The register defines are shamelessly copied from the meteor 8 The register defines are shamelessly copied from the meteor
9 driver out of NetBSD (with permission), 9 driver out of NetBSD (with permission),
10 and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe 10 and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe
11 (Thanks !) 11 (Thanks !)
12 12
13 Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu) 13 Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu)
14 14
15 The default values used for PlanB are my mistakes. 15 The default values used for PlanB are my mistakes.
diff --git a/drivers/usb/media/se401.c b/drivers/media/video/se401.c
index f03ea7f89596..a846ebc78cd7 100644
--- a/drivers/usb/media/se401.c
+++ b/drivers/media/video/se401.c
@@ -4,7 +4,7 @@
4 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org) 4 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org)
5 * 5 *
6 * Still somewhat based on the Linux ov511 driver. 6 * Still somewhat based on the Linux ov511 driver.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your 10 * 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,
114 unsigned short value, unsigned char *cp, int size) 114 unsigned short value, unsigned char *cp, int size)
115{ 115{
116 return usb_control_msg ( 116 return usb_control_msg (
117 se401->dev, 117 se401->dev,
118 set ? usb_sndctrlpipe(se401->dev, 0) : usb_rcvctrlpipe(se401->dev, 0), 118 set ? usb_sndctrlpipe(se401->dev, 0) : usb_rcvctrlpipe(se401->dev, 0),
119 req, 119 req,
120 (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 120 (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
121 value, 121 value,
122 0, 122 0,
123 cp, 123 cp,
124 size, 124 size,
125 1000 125 1000
126 ); 126 );
127} 127}
128 128
129static int se401_set_feature(struct usb_se401 *se401, unsigned short selector, 129static 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,
140 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 140 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
141 param, 141 param,
142 selector, 142 selector,
143 NULL, 143 NULL,
144 0, 144 0,
145 1000 145 1000
146 ); 146 );
147} 147}
148 148
149static unsigned short se401_get_feature(struct usb_se401 *se401, 149static unsigned short se401_get_feature(struct usb_se401 *se401,
150 unsigned short selector) 150 unsigned short selector)
151{ 151{
152 /* For 'set' the selecetor should be in index, not sure if the spec is 152 /* For 'set' the selecetor should be in index, not sure if the spec is
153 wrong here to.... 153 wrong here to....
154 */ 154 */
155 unsigned char cp[2]; 155 unsigned char cp[2];
156 usb_control_msg ( 156 usb_control_msg (
157 se401->dev, 157 se401->dev,
158 usb_rcvctrlpipe(se401->dev, 0), 158 usb_rcvctrlpipe(se401->dev, 0),
159 SE401_REQ_GET_EXT_FEATURE, 159 SE401_REQ_GET_EXT_FEATURE,
160 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 160 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
161 0, 161 0,
162 selector, 162 selector,
163 cp, 163 cp,
164 2, 164 2,
165 1000 165 1000
166 ); 166 );
167 return cp[0]+cp[1]*256; 167 return cp[0]+cp[1]*256;
168} 168}
169 169
@@ -183,14 +183,14 @@ static int se401_send_pict(struct usb_se401 *se401)
183 se401_set_feature(se401, HV7131_REG_ARCG, se401->rgain);/* red color gain */ 183 se401_set_feature(se401, HV7131_REG_ARCG, se401->rgain);/* red color gain */
184 se401_set_feature(se401, HV7131_REG_AGCG, se401->ggain);/* green color gain */ 184 se401_set_feature(se401, HV7131_REG_AGCG, se401->ggain);/* green color gain */
185 se401_set_feature(se401, HV7131_REG_ABCG, se401->bgain);/* blue color gain */ 185 se401_set_feature(se401, HV7131_REG_ABCG, se401->bgain);/* blue color gain */
186 186
187 return 0; 187 return 0;
188} 188}
189 189
190static void se401_set_exposure(struct usb_se401 *se401, int brightness) 190static void se401_set_exposure(struct usb_se401 *se401, int brightness)
191{ 191{
192 int integration=brightness<<5; 192 int integration=brightness<<5;
193 193
194 if (flickerless==50) { 194 if (flickerless==50) {
195 integration=integration-integration%106667; 195 integration=integration-integration%106667;
196 } 196 }
@@ -255,11 +255,11 @@ static void se401_auto_resetlevel(struct usb_se401 *se401)
255 /* For some reason this normally read-only register doesn't get reset 255 /* For some reason this normally read-only register doesn't get reset
256 to zero after reading them just once... 256 to zero after reading them just once...
257 */ 257 */
258 se401_get_feature(se401, HV7131_REG_HIREFNOH); 258 se401_get_feature(se401, HV7131_REG_HIREFNOH);
259 se401_get_feature(se401, HV7131_REG_HIREFNOL); 259 se401_get_feature(se401, HV7131_REG_HIREFNOL);
260 se401_get_feature(se401, HV7131_REG_LOREFNOH); 260 se401_get_feature(se401, HV7131_REG_LOREFNOH);
261 se401_get_feature(se401, HV7131_REG_LOREFNOL); 261 se401_get_feature(se401, HV7131_REG_LOREFNOL);
262 ahrc=256*se401_get_feature(se401, HV7131_REG_HIREFNOH) + 262 ahrc=256*se401_get_feature(se401, HV7131_REG_HIREFNOH) +
263 se401_get_feature(se401, HV7131_REG_HIREFNOL); 263 se401_get_feature(se401, HV7131_REG_HIREFNOL);
264 alrc=256*se401_get_feature(se401, HV7131_REG_LOREFNOH) + 264 alrc=256*se401_get_feature(se401, HV7131_REG_LOREFNOH) +
265 se401_get_feature(se401, HV7131_REG_LOREFNOL); 265 se401_get_feature(se401, HV7131_REG_LOREFNOL);
@@ -287,12 +287,12 @@ static void se401_button_irq(struct urb *urb, struct pt_regs *regs)
287{ 287{
288 struct usb_se401 *se401 = urb->context; 288 struct usb_se401 *se401 = urb->context;
289 int status; 289 int status;
290 290
291 if (!se401->dev) { 291 if (!se401->dev) {
292 info("ohoh: device vapourished"); 292 info("ohoh: device vapourished");
293 return; 293 return;
294 } 294 }
295 295
296 switch (urb->status) { 296 switch (urb->status) {
297 case 0: 297 case 0:
298 /* success */ 298 /* success */
@@ -368,7 +368,7 @@ static void se401_video_irq(struct urb *urb, struct pt_regs *regs)
368 if (se401->nullpackets > SE401_MAX_NULLPACKETS) { 368 if (se401->nullpackets > SE401_MAX_NULLPACKETS) {
369 if (waitqueue_active(&se401->wq)) { 369 if (waitqueue_active(&se401->wq)) {
370 wake_up_interruptible(&se401->wq); 370 wake_up_interruptible(&se401->wq);
371 } 371 }
372 } 372 }
373 } 373 }
374 374
@@ -433,8 +433,8 @@ static int se401_start_stream(struct usb_se401 *se401)
433 int err=0, i; 433 int err=0, i;
434 se401->streaming=1; 434 se401->streaming=1;
435 435
436 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0); 436 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
437 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0); 437 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
438 438
439 /* Set picture settings */ 439 /* Set picture settings */
440 se401_set_feature(se401, HV7131_REG_MODE_B, 0x05);/*windowed + pix intg */ 440 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)
571 } 571 }
572 572
573 /* First three are absolute, all others relative. 573 /* First three are absolute, all others relative.
574 * Format is rgb from right to left (mirrorred image), 574 * Format is rgb from right to left (mirrorred image),
575 * we flip it to get bgr from left to right. */ 575 * we flip it to get bgr from left to right. */
576 if (frame->curlinepix < 3) { 576 if (frame->curlinepix < 3) {
577 *(frame->curline-frame->curlinepix)=1+data*4; 577 *(frame->curline-frame->curlinepix)=1+data*4;
@@ -703,7 +703,7 @@ static inline void decode_bayer (struct usb_se401 *se401, struct se401_scratch *
703 int width=se401->cwidth; 703 int width=se401->cwidth;
704 int blineoffset=0, bline; 704 int blineoffset=0, bline;
705 int linelength=width*3, i; 705 int linelength=width*3, i;
706 706
707 707
708 if (frame->curpix==0) { 708 if (frame->curpix==0) {
709 if (frame->grabstate==FRAME_READY) { 709 if (frame->grabstate==FRAME_READY) {
@@ -831,7 +831,7 @@ static int se401_newframe(struct usb_se401 *se401, int framenr)
831 se401->nullpackets=0; 831 se401->nullpackets=0;
832 info("to many null length packets, restarting capture"); 832 info("to many null length packets, restarting capture");
833 se401_stop_stream(se401); 833 se401_stop_stream(se401);
834 se401_start_stream(se401); 834 se401_start_stream(se401);
835 } else { 835 } else {
836 if (se401->scratch[se401->scratch_use].state!=BUFFER_READY) { 836 if (se401->scratch[se401->scratch_use].state!=BUFFER_READY) {
837 se401->frame[framenr].grabstate=FRAME_ERROR; 837 se401->frame[framenr].grabstate=FRAME_ERROR;
@@ -866,7 +866,7 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
866{ 866{
867 int i; 867 int i;
868 868
869 se401->dev = NULL; 869 se401->dev = NULL;
870 870
871 for (i=0; i<SE401_NUMSBUF; i++) 871 for (i=0; i<SE401_NUMSBUF; i++)
872 if (se401->urb[i]) { 872 if (se401->urb[i]) {
@@ -882,9 +882,9 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
882 usb_kill_urb(se401->inturb); 882 usb_kill_urb(se401->inturb);
883 usb_free_urb(se401->inturb); 883 usb_free_urb(se401->inturb);
884 } 884 }
885 info("%s disconnected", se401->camera_name); 885 info("%s disconnected", se401->camera_name);
886 886
887 /* Free the memory */ 887 /* Free the memory */
888 kfree(se401->width); 888 kfree(se401->width);
889 kfree(se401->height); 889 kfree(se401->height);
890 kfree(se401); 890 kfree(se401);
@@ -910,7 +910,7 @@ static int se401_open(struct inode *inode, struct file *file)
910 se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES); 910 se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES);
911 if (se401->fbuf) 911 if (se401->fbuf)
912 file->private_data = dev; 912 file->private_data = dev;
913 else 913 else
914 err = -ENOMEM; 914 err = -ENOMEM;
915 se401->user = !err; 915 se401->user = !err;
916 916
@@ -920,11 +920,11 @@ static int se401_open(struct inode *inode, struct file *file)
920static int se401_close(struct inode *inode, struct file *file) 920static int se401_close(struct inode *inode, struct file *file)
921{ 921{
922 struct video_device *dev = file->private_data; 922 struct video_device *dev = file->private_data;
923 struct usb_se401 *se401 = (struct usb_se401 *)dev; 923 struct usb_se401 *se401 = (struct usb_se401 *)dev;
924 int i; 924 int i;
925 925
926 rvfree(se401->fbuf, se401->maxframesize * SE401_NUMFRAMES); 926 rvfree(se401->fbuf, se401->maxframesize * SE401_NUMFRAMES);
927 if (se401->removed) { 927 if (se401->removed) {
928 usb_se401_remove_disconnected(se401); 928 usb_se401_remove_disconnected(se401);
929 info("device unregistered"); 929 info("device unregistered");
930 } else { 930 } else {
@@ -942,12 +942,12 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
942 unsigned int cmd, void *arg) 942 unsigned int cmd, void *arg)
943{ 943{
944 struct video_device *vdev = file->private_data; 944 struct video_device *vdev = file->private_data;
945 struct usb_se401 *se401 = (struct usb_se401 *)vdev; 945 struct usb_se401 *se401 = (struct usb_se401 *)vdev;
946 946
947 if (!se401->dev) 947 if (!se401->dev)
948 return -EIO; 948 return -EIO;
949 949
950 switch (cmd) { 950 switch (cmd) {
951 case VIDIOCGCAP: 951 case VIDIOCGCAP:
952 { 952 {
953 struct video_capability *b = arg; 953 struct video_capability *b = arg;
@@ -981,8 +981,8 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
981 return -EINVAL; 981 return -EINVAL;
982 return 0; 982 return 0;
983 } 983 }
984 case VIDIOCGPICT: 984 case VIDIOCGPICT:
985 { 985 {
986 struct video_picture *p = arg; 986 struct video_picture *p = arg;
987 987
988 se401_get_pict(se401, p); 988 se401_get_pict(se401, p);
@@ -1007,7 +1007,7 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
1007 if (se401_set_size(se401, vw->width, vw->height)) 1007 if (se401_set_size(se401, vw->width, vw->height))
1008 return -EINVAL; 1008 return -EINVAL;
1009 return 0; 1009 return 0;
1010 } 1010 }
1011 case VIDIOCGWIN: 1011 case VIDIOCGWIN:
1012 { 1012 {
1013 struct video_window *vw = arg; 1013 struct video_window *vw = arg;
@@ -1095,11 +1095,11 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
1095 case VIDIOCGAUDIO: 1095 case VIDIOCGAUDIO:
1096 case VIDIOCSAUDIO: 1096 case VIDIOCSAUDIO:
1097 return -EINVAL; 1097 return -EINVAL;
1098 default: 1098 default:
1099 return -ENOIOCTLCMD; 1099 return -ENOIOCTLCMD;
1100 } /* end switch */ 1100 } /* end switch */
1101 1101
1102 return 0; 1102 return 0;
1103} 1103}
1104 1104
1105static int se401_ioctl(struct inode *inode, struct file *file, 1105static int se401_ioctl(struct inode *inode, struct file *file,
@@ -1142,7 +1142,7 @@ static ssize_t se401_read(struct file *file, char __user *buf,
1142 1142
1143 se401->frame[0].grabstate=FRAME_UNUSED; 1143 se401->frame[0].grabstate=FRAME_UNUSED;
1144 if (ret) 1144 if (ret)
1145 return ret; 1145 return ret;
1146 if (copy_to_user(buf, se401->frame[0].data, realcount)) 1146 if (copy_to_user(buf, se401->frame[0].data, realcount))
1147 return -EFAULT; 1147 return -EFAULT;
1148 1148
@@ -1183,24 +1183,24 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma)
1183 } 1183 }
1184 mutex_unlock(&se401->lock); 1184 mutex_unlock(&se401->lock);
1185 1185
1186 return 0; 1186 return 0;
1187} 1187}
1188 1188
1189static struct file_operations se401_fops = { 1189static struct file_operations se401_fops = {
1190 .owner = THIS_MODULE, 1190 .owner = THIS_MODULE,
1191 .open = se401_open, 1191 .open = se401_open,
1192 .release = se401_close, 1192 .release = se401_close,
1193 .read = se401_read, 1193 .read = se401_read,
1194 .mmap = se401_mmap, 1194 .mmap = se401_mmap,
1195 .ioctl = se401_ioctl, 1195 .ioctl = se401_ioctl,
1196 .compat_ioctl = v4l_compat_ioctl32, 1196 .compat_ioctl = v4l_compat_ioctl32,
1197 .llseek = no_llseek, 1197 .llseek = no_llseek,
1198}; 1198};
1199static struct video_device se401_template = { 1199static struct video_device se401_template = {
1200 .owner = THIS_MODULE, 1200 .owner = THIS_MODULE,
1201 .name = "se401 USB camera", 1201 .name = "se401 USB camera",
1202 .type = VID_TYPE_CAPTURE, 1202 .type = VID_TYPE_CAPTURE,
1203 .hardware = VID_HARDWARE_SE401, 1203 .hardware = VID_HARDWARE_SE401,
1204 .fops = &se401_fops, 1204 .fops = &se401_fops,
1205}; 1205};
1206 1206
@@ -1209,12 +1209,12 @@ static struct video_device se401_template = {
1209/***************************/ 1209/***************************/
1210static int se401_init(struct usb_se401 *se401, int button) 1210static int se401_init(struct usb_se401 *se401, int button)
1211{ 1211{
1212 int i=0, rc; 1212 int i=0, rc;
1213 unsigned char cp[0x40]; 1213 unsigned char cp[0x40];
1214 char temp[200]; 1214 char temp[200];
1215 1215
1216 /* led on */ 1216 /* led on */
1217 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0); 1217 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
1218 1218
1219 /* get camera descriptor */ 1219 /* get camera descriptor */
1220 rc=se401_sndctrl(0, se401, SE401_REQ_GET_CAMERA_DESCRIPTOR, 0, cp, sizeof(cp)); 1220 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)
1254 return 1; 1254 return 1;
1255 } 1255 }
1256 /* set output mode (BAYER) */ 1256 /* set output mode (BAYER) */
1257 se401_sndctrl(1, se401, SE401_REQ_SET_OUTPUT_MODE, SE401_FORMAT_BAYER, NULL, 0); 1257 se401_sndctrl(1, se401, SE401_REQ_SET_OUTPUT_MODE, SE401_FORMAT_BAYER, NULL, 0);
1258 1258
1259 rc=se401_sndctrl(0, se401, SE401_REQ_GET_BRT, 0, cp, sizeof(cp)); 1259 rc=se401_sndctrl(0, se401, SE401_REQ_GET_BRT, 0, cp, sizeof(cp));
1260 se401->brightness=cp[0]+cp[1]*256; 1260 se401->brightness=cp[0]+cp[1]*256;
@@ -1292,71 +1292,71 @@ static int se401_init(struct usb_se401 *se401, int button)
1292 } else 1292 } else
1293 se401->inturb=NULL; 1293 se401->inturb=NULL;
1294 1294
1295 /* Flash the led */ 1295 /* Flash the led */
1296 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0); 1296 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
1297 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0); 1297 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
1298 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0); 1298 se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0);
1299 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 0, NULL, 0); 1299 se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 0, NULL, 0);
1300 1300
1301 return 0; 1301 return 0;
1302} 1302}
1303 1303
1304static int se401_probe(struct usb_interface *intf, 1304static int se401_probe(struct usb_interface *intf,
1305 const struct usb_device_id *id) 1305 const struct usb_device_id *id)
1306{ 1306{
1307 struct usb_device *dev = interface_to_usbdev(intf); 1307 struct usb_device *dev = interface_to_usbdev(intf);
1308 struct usb_interface_descriptor *interface; 1308 struct usb_interface_descriptor *interface;
1309 struct usb_se401 *se401; 1309 struct usb_se401 *se401;
1310 char *camera_name=NULL; 1310 char *camera_name=NULL;
1311 int button=1; 1311 int button=1;
1312 1312
1313 /* We don't handle multi-config cameras */ 1313 /* We don't handle multi-config cameras */
1314 if (dev->descriptor.bNumConfigurations != 1) 1314 if (dev->descriptor.bNumConfigurations != 1)
1315 return -ENODEV; 1315 return -ENODEV;
1316 1316
1317 interface = &intf->cur_altsetting->desc; 1317 interface = &intf->cur_altsetting->desc;
1318 1318
1319 /* Is it an se401? */ 1319 /* Is it an se401? */
1320 if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 && 1320 if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 &&
1321 le16_to_cpu(dev->descriptor.idProduct) == 0x0004) { 1321 le16_to_cpu(dev->descriptor.idProduct) == 0x0004) {
1322 camera_name="Endpoints/Aox SE401"; 1322 camera_name="Endpoints/Aox SE401";
1323 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 && 1323 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 &&
1324 le16_to_cpu(dev->descriptor.idProduct) == 0x030b) { 1324 le16_to_cpu(dev->descriptor.idProduct) == 0x030b) {
1325 camera_name="Philips PCVC665K"; 1325 camera_name="Philips PCVC665K";
1326 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && 1326 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
1327 le16_to_cpu(dev->descriptor.idProduct) == 0x5001) { 1327 le16_to_cpu(dev->descriptor.idProduct) == 0x5001) {
1328 camera_name="Kensington VideoCAM 67014"; 1328 camera_name="Kensington VideoCAM 67014";
1329 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && 1329 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
1330 le16_to_cpu(dev->descriptor.idProduct) == 0x5002) { 1330 le16_to_cpu(dev->descriptor.idProduct) == 0x5002) {
1331 camera_name="Kensington VideoCAM 6701(5/7)"; 1331 camera_name="Kensington VideoCAM 6701(5/7)";
1332 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && 1332 } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
1333 le16_to_cpu(dev->descriptor.idProduct) == 0x5003) { 1333 le16_to_cpu(dev->descriptor.idProduct) == 0x5003) {
1334 camera_name="Kensington VideoCAM 67016"; 1334 camera_name="Kensington VideoCAM 67016";
1335 button=0; 1335 button=0;
1336 } else 1336 } else
1337 return -ENODEV; 1337 return -ENODEV;
1338 1338
1339 /* Checking vendor/product should be enough, but what the hell */ 1339 /* Checking vendor/product should be enough, but what the hell */
1340 if (interface->bInterfaceClass != 0x00) 1340 if (interface->bInterfaceClass != 0x00)
1341 return -ENODEV; 1341 return -ENODEV;
1342 if (interface->bInterfaceSubClass != 0x00) 1342 if (interface->bInterfaceSubClass != 0x00)
1343 return -ENODEV; 1343 return -ENODEV;
1344 1344
1345 /* We found one */ 1345 /* We found one */
1346 info("SE401 camera found: %s", camera_name); 1346 info("SE401 camera found: %s", camera_name);
1347 1347
1348 if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) { 1348 if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
1349 err("couldn't kmalloc se401 struct"); 1349 err("couldn't kmalloc se401 struct");
1350 return -ENOMEM; 1350 return -ENOMEM;
1351 } 1351 }
1352 1352
1353 se401->dev = dev; 1353 se401->dev = dev;
1354 se401->iface = interface->bInterfaceNumber; 1354 se401->iface = interface->bInterfaceNumber;
1355 se401->camera_name = camera_name; 1355 se401->camera_name = camera_name;
1356 1356
1357 info("firmware version: %02x", le16_to_cpu(dev->descriptor.bcdDevice) & 255); 1357 info("firmware version: %02x", le16_to_cpu(dev->descriptor.bcdDevice) & 255);
1358 1358
1359 if (se401_init(se401, button)) { 1359 if (se401_init(se401, button)) {
1360 kfree(se401); 1360 kfree(se401);
1361 return -EIO; 1361 return -EIO;
1362 } 1362 }
@@ -1375,7 +1375,7 @@ static int se401_probe(struct usb_interface *intf,
1375 info("registered new video device: video%d", se401->vdev.minor); 1375 info("registered new video device: video%d", se401->vdev.minor);
1376 1376
1377 usb_set_intfdata (intf, se401); 1377 usb_set_intfdata (intf, se401);
1378 return 0; 1378 return 0;
1379} 1379}
1380 1380
1381static void se401_disconnect(struct usb_interface *intf) 1381static void se401_disconnect(struct usb_interface *intf)
@@ -1400,10 +1400,10 @@ static void se401_disconnect(struct usb_interface *intf)
1400} 1400}
1401 1401
1402static struct usb_driver se401_driver = { 1402static struct usb_driver se401_driver = {
1403 .name = "se401", 1403 .name = "se401",
1404 .id_table = device_table, 1404 .id_table = device_table,
1405 .probe = se401_probe, 1405 .probe = se401_probe,
1406 .disconnect = se401_disconnect, 1406 .disconnect = se401_disconnect,
1407}; 1407};
1408 1408
1409 1409
diff --git a/drivers/usb/media/se401.h b/drivers/media/video/se401.h
index e88a40d4c86a..a7a216bd4413 100644
--- a/drivers/usb/media/se401.h
+++ b/drivers/media/video/se401.h
@@ -177,7 +177,7 @@ struct usb_se401 {
177 int expose_m; 177 int expose_m;
178 int expose_l; 178 int expose_l;
179 int resetlevel; 179 int resetlevel;
180 180
181 int enhance; 181 int enhance;
182 182
183 int format; 183 int format;
@@ -200,12 +200,12 @@ struct usb_se401 {
200 200
201 struct urb *urb[SE401_NUMSBUF]; 201 struct urb *urb[SE401_NUMSBUF];
202 struct urb *inturb; 202 struct urb *inturb;
203 203
204 int button; 204 int button;
205 int buttonpressed; 205 int buttonpressed;
206 206
207 int curframe; /* Current receiving frame */ 207 int curframe; /* Current receiving frame */
208 struct se401_frame frame[SE401_NUMFRAMES]; 208 struct se401_frame frame[SE401_NUMFRAMES];
209 int readcount; 209 int readcount;
210 int framecount; 210 int framecount;
211 int error; 211 int error;
diff --git a/drivers/media/video/sn9c102/Makefile b/drivers/media/video/sn9c102/Makefile
new file mode 100644
index 000000000000..536ad3098da4
--- /dev/null
+++ b/drivers/media/video/sn9c102/Makefile
@@ -0,0 +1,7 @@
1sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \
2 sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \
3 sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \
4 sn9c102_tas5130d1b.o
5
6obj-$(CONFIG_USB_SN9C102) += sn9c102.o
7
diff --git a/drivers/usb/media/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 1d70a62b9f23..2c6ff396dafc 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)
164 164
165void 165void
166sn9c102_attach_sensor(struct sn9c102_device* cam, 166sn9c102_attach_sensor(struct sn9c102_device* cam,
167 struct sn9c102_sensor* sensor) 167 struct sn9c102_sensor* sensor)
168{ 168{
169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); 169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
170} 170}
@@ -183,7 +183,7 @@ do { \
183 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 183 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
184 else if ((level) >= 3) \ 184 else if ((level) >= 3) \
185 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 185 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
186 __FUNCTION__, __LINE__ , ## args); \ 186 __FUNCTION__, __LINE__ , ## args); \
187 } \ 187 } \
188} while (0) 188} while (0)
189# define V4LDBG(level, name, cmd) \ 189# define V4LDBG(level, name, cmd) \
@@ -198,7 +198,7 @@ do { \
198 pr_info("sn9c102: " fmt "\n", ## args); \ 198 pr_info("sn9c102: " fmt "\n", ## args); \
199 else if ((level) == 3) \ 199 else if ((level) == 3) \
200 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \ 200 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
201 __LINE__ , ## args); \ 201 __LINE__ , ## args); \
202 } \ 202 } \
203} while (0) 203} while (0)
204#else 204#else
@@ -210,7 +210,7 @@ do { \
210#undef PDBG 210#undef PDBG
211#define PDBG(fmt, args...) \ 211#define PDBG(fmt, args...) \
212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
213 __FUNCTION__, __LINE__ , ## args) 213 __FUNCTION__, __LINE__ , ## args)
214 214
215#undef PDBGG 215#undef PDBGG
216#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 216#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 4c6cc6395723..ea4394dc9415 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);
62static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1}; 62static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1};
63module_param_array(video_nr, short, NULL, 0444); 63module_param_array(video_nr, short, NULL, 0444);
64MODULE_PARM_DESC(video_nr, 64MODULE_PARM_DESC(video_nr,
65 "\n<-1|n[,...]> Specify V4L2 minor mode number." 65 "\n<-1|n[,...]> Specify V4L2 minor mode number."
66 "\n -1 = use next available (default)" 66 "\n -1 = use next available (default)"
67 "\n n = use minor number n (integer >= 0)" 67 "\n n = use minor number n (integer >= 0)"
68 "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES) 68 "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES)
69 " cameras this way." 69 " cameras this way."
70 "\nFor example:" 70 "\nFor example:"
71 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 71 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
72 "\nthe second camera and use auto for the first" 72 "\nthe second camera and use auto for the first"
73 "\none and for every other camera." 73 "\none and for every other camera."
74 "\n"); 74 "\n");
75 75
76static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] = 76static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
77 SN9C102_FORCE_MUNMAP}; 77 SN9C102_FORCE_MUNMAP};
78module_param_array(force_munmap, bool, NULL, 0444); 78module_param_array(force_munmap, bool, NULL, 0444);
79MODULE_PARM_DESC(force_munmap, 79MODULE_PARM_DESC(force_munmap,
80 "\n<0|1[,...]> Force the application to unmap previously" 80 "\n<0|1[,...]> Force the application to unmap previously"
81 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 81 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
82 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 82 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
83 "\nthis feature. This parameter is specific for each" 83 "\nthis feature. This parameter is specific for each"
84 "\ndetected camera." 84 "\ndetected camera."
85 "\n 0 = do not force memory unmapping" 85 "\n 0 = do not force memory unmapping"
86 "\n 1 = force memory unmapping (save memory)" 86 "\n 1 = force memory unmapping (save memory)"
87 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 87 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
88 "\n"); 88 "\n");
89 89
90static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] = 90static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] =
91 SN9C102_FRAME_TIMEOUT}; 91 SN9C102_FRAME_TIMEOUT};
92module_param_array(frame_timeout, uint, NULL, 0644); 92module_param_array(frame_timeout, uint, NULL, 0644);
93MODULE_PARM_DESC(frame_timeout, 93MODULE_PARM_DESC(frame_timeout,
94 "\n<n[,...]> Timeout for a video frame in seconds." 94 "\n<n[,...]> Timeout for a video frame in seconds."
95 "\nThis parameter is specific for each detected camera." 95 "\nThis parameter is specific for each detected camera."
96 "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"." 96 "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"."
97 "\n"); 97 "\n");
98 98
99#ifdef SN9C102_DEBUG 99#ifdef SN9C102_DEBUG
100static unsigned short debug = SN9C102_DEBUG_LEVEL; 100static unsigned short debug = SN9C102_DEBUG_LEVEL;
101module_param(debug, ushort, 0644); 101module_param(debug, ushort, 0644);
102MODULE_PARM_DESC(debug, 102MODULE_PARM_DESC(debug,
103 "\n<n> Debugging information level, from 0 to 3:" 103 "\n<n> Debugging information level, from 0 to 3:"
104 "\n0 = none (use carefully)" 104 "\n0 = none (use carefully)"
105 "\n1 = critical errors" 105 "\n1 = critical errors"
106 "\n2 = significant informations" 106 "\n2 = significant informations"
107 "\n3 = more verbose messages" 107 "\n3 = more verbose messages"
108 "\nLevel 3 is useful for testing only, when only " 108 "\nLevel 3 is useful for testing only, when only "
109 "one device is used." 109 "one device is used."
110 "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"." 110 "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"."
111 "\n"); 111 "\n");
112#endif 112#endif
113 113
114/*****************************************************************************/ 114/*****************************************************************************/
@@ -131,16 +131,16 @@ static sn9c102_eof_header_t sn9c102_eof_header[] = {
131 131
132/*****************************************************************************/ 132/*****************************************************************************/
133 133
134static u32 134static u32
135sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, 135sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
136 enum sn9c102_io_method io) 136 enum sn9c102_io_method io)
137{ 137{
138 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 138 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
139 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 139 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
140 const size_t imagesize = cam->module_param.force_munmap || 140 const size_t imagesize = cam->module_param.force_munmap ||
141 io == IO_READ ? 141 io == IO_READ ?
142 (p->width * p->height * p->priv) / 8 : 142 (p->width * p->height * p->priv) / 8 :
143 (r->width * r->height * p->priv) / 8; 143 (r->width * r->height * p->priv) / 8;
144 void* buff = NULL; 144 void* buff = NULL;
145 u32 i; 145 u32 i;
146 146
@@ -232,8 +232,8 @@ int sn9c102_write_regs(struct sn9c102_device* cam, u8* buff, u16 index)
232 return -1; 232 return -1;
233 233
234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
235 index, 0, buff, sizeof(buff), 235 index, 0, buff, sizeof(buff),
236 SN9C102_CTRL_TIMEOUT*sizeof(buff)); 236 SN9C102_CTRL_TIMEOUT*sizeof(buff));
237 if (res < 0) { 237 if (res < 0) {
238 DBG(3, "Failed to write registers (index 0x%02X, error %d)", 238 DBG(3, "Failed to write registers (index 0x%02X, error %d)",
239 index, res); 239 index, res);
@@ -259,7 +259,7 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
259 *buff = value; 259 *buff = value;
260 260
261 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 261 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
262 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 262 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
263 if (res < 0) { 263 if (res < 0) {
264 DBG(3, "Failed to write a register (value 0x%02X, index " 264 DBG(3, "Failed to write a register (value 0x%02X, index "
265 "0x%02X, error %d)", value, index, res); 265 "0x%02X, error %d)", value, index, res);
@@ -280,7 +280,7 @@ static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
280 int res; 280 int res;
281 281
282 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 282 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
283 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 283 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
284 if (res < 0) 284 if (res < 0)
285 DBG(3, "Failed to read a register (index 0x%02X, error %d)", 285 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
286 index, res); 286 index, res);
@@ -319,8 +319,8 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor)
319 319
320 320
321static int 321static int
322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, 322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
323 struct sn9c102_sensor* sensor) 323 struct sn9c102_sensor* sensor)
324{ 324{
325 int r; 325 int r;
326 r = sn9c102_read_reg(cam, 0x08); 326 r = sn9c102_read_reg(cam, 0x08);
@@ -329,8 +329,8 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
329 329
330 330
331static int 331static int
332sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, 332sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
333 struct sn9c102_sensor* sensor) 333 struct sn9c102_sensor* sensor)
334{ 334{
335 int r; 335 int r;
336 r = sn9c102_read_reg(cam, 0x08); 336 r = sn9c102_read_reg(cam, 0x08);
@@ -338,10 +338,10 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
338} 338}
339 339
340 340
341int 341int
342sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 342sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
343 struct sn9c102_sensor* sensor, u8 data0, u8 data1, 343 struct sn9c102_sensor* sensor, u8 data0, u8 data1,
344 u8 n, u8 buffer[]) 344 u8 n, u8 buffer[])
345{ 345{
346 struct usb_device* udev = cam->usbdev; 346 struct usb_device* udev = cam->usbdev;
347 u8* data = cam->control_buffer; 347 u8* data = cam->control_buffer;
@@ -349,12 +349,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
349 349
350 /* Write cycle */ 350 /* Write cycle */
351 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 351 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
352 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10; 352 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10;
353 data[1] = data0; /* I2C slave id */ 353 data[1] = data0; /* I2C slave id */
354 data[2] = data1; /* address */ 354 data[2] = data1; /* address */
355 data[7] = 0x10; 355 data[7] = 0x10;
356 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 356 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
357 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 357 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
358 if (res < 0) 358 if (res < 0)
359 err += res; 359 err += res;
360 360
@@ -362,12 +362,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
362 362
363 /* Read cycle - n bytes */ 363 /* Read cycle - n bytes */
364 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 364 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
365 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 365 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) |
366 (n << 4) | 0x02; 366 (n << 4) | 0x02;
367 data[1] = data0; 367 data[1] = data0;
368 data[7] = 0x10; 368 data[7] = 0x10;
369 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 369 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
370 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 370 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
371 if (res < 0) 371 if (res < 0)
372 err += res; 372 err += res;
373 373
@@ -375,7 +375,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
375 375
376 /* The first read byte will be placed in data[4] */ 376 /* The first read byte will be placed in data[4] */
377 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 377 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
378 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT); 378 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT);
379 if (res < 0) 379 if (res < 0)
380 err += res; 380 err += res;
381 381
@@ -396,10 +396,10 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
396} 396}
397 397
398 398
399int 399int
400sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 400sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
401 struct sn9c102_sensor* sensor, u8 n, u8 data0, 401 struct sn9c102_sensor* sensor, u8 n, u8 data0,
402 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) 402 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
403{ 403{
404 struct usb_device* udev = cam->usbdev; 404 struct usb_device* udev = cam->usbdev;
405 u8* data = cam->control_buffer; 405 u8* data = cam->control_buffer;
@@ -407,8 +407,8 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
407 407
408 /* Write cycle. It usually is address + value */ 408 /* Write cycle. It usually is address + value */
409 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 409 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
410 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) 410 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0)
411 | ((n - 1) << 4); 411 | ((n - 1) << 4);
412 data[1] = data0; 412 data[1] = data0;
413 data[2] = data1; 413 data[2] = data1;
414 data[3] = data2; 414 data[3] = data2;
@@ -417,7 +417,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
417 data[6] = data5; 417 data[6] = data5;
418 data[7] = 0x14; 418 data[7] = 0x14;
419 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 419 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
420 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 420 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
421 if (res < 0) 421 if (res < 0)
422 err += res; 422 err += res;
423 423
@@ -437,20 +437,20 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
437 437
438int 438int
439sn9c102_i2c_try_read(struct sn9c102_device* cam, 439sn9c102_i2c_try_read(struct sn9c102_device* cam,
440 struct sn9c102_sensor* sensor, u8 address) 440 struct sn9c102_sensor* sensor, u8 address)
441{ 441{
442 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, 442 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id,
443 address, 1, NULL); 443 address, 1, NULL);
444} 444}
445 445
446 446
447int 447int
448sn9c102_i2c_try_write(struct sn9c102_device* cam, 448sn9c102_i2c_try_write(struct sn9c102_device* cam,
449 struct sn9c102_sensor* sensor, u8 address, u8 value) 449 struct sn9c102_sensor* sensor, u8 address, u8 value)
450{ 450{
451 return sn9c102_i2c_try_raw_write(cam, sensor, 3, 451 return sn9c102_i2c_try_raw_write(cam, sensor, 3,
452 sensor->i2c_slave_id, address, 452 sensor->i2c_slave_id, address,
453 value, 0, 0, 0); 453 value, 0, 0, 0);
454} 454}
455 455
456 456
@@ -484,7 +484,7 @@ sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len)
484 n = sizeof(sn9c103_sof_header) / soflen; 484 n = sizeof(sn9c103_sof_header) / soflen;
485 } 485 }
486 486
487 for (i = 0; (len >= soflen) && (i <= len - soflen); i++) 487 for (i = 0; (len >= soflen) && (i <= len - soflen); i++)
488 for (j = 0; j < n; j++) 488 for (j = 0; j < n; j++)
489 /* The invariable part of the header is 6 bytes long */ 489 /* The invariable part of the header is 6 bytes long */
490 if ((cam->bridge != BRIDGE_SN9C103 && 490 if ((cam->bridge != BRIDGE_SN9C103 &&
@@ -552,15 +552,15 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
552 552
553 if (!(*f)) 553 if (!(*f))
554 (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t, 554 (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t,
555 frame); 555 frame);
556 556
557 imagesize = (cam->sensor.pix_format.width * 557 imagesize = (cam->sensor.pix_format.width *
558 cam->sensor.pix_format.height * 558 cam->sensor.pix_format.height *
559 cam->sensor.pix_format.priv) / 8; 559 cam->sensor.pix_format.priv) / 8;
560 560
561 soflen = (cam->bridge) == BRIDGE_SN9C103 ? 561 soflen = (cam->bridge) == BRIDGE_SN9C103 ?
562 sizeof(sn9c103_sof_header_t) : 562 sizeof(sn9c103_sof_header_t) :
563 sizeof(sn9c102_sof_header_t); 563 sizeof(sn9c102_sof_header_t);
564 564
565 for (i = 0; i < urb->number_of_packets; i++) { 565 for (i = 0; i < urb->number_of_packets; i++) {
566 unsigned int img, len, status; 566 unsigned int img, len, status;
@@ -611,19 +611,19 @@ end_of_frame:
611 611
612 if ((*f)->buf.bytesused == imagesize || 612 if ((*f)->buf.bytesused == imagesize ||
613 (cam->sensor.pix_format.pixelformat == 613 (cam->sensor.pix_format.pixelformat ==
614 V4L2_PIX_FMT_SN9C10X && eof)) { 614 V4L2_PIX_FMT_SN9C10X && eof)) {
615 u32 b; 615 u32 b;
616 b = (*f)->buf.bytesused; 616 b = (*f)->buf.bytesused;
617 (*f)->state = F_DONE; 617 (*f)->state = F_DONE;
618 (*f)->buf.sequence= ++cam->frame_count; 618 (*f)->buf.sequence= ++cam->frame_count;
619 spin_lock(&cam->queue_lock); 619 spin_lock(&cam->queue_lock);
620 list_move_tail(&(*f)->frame, 620 list_move_tail(&(*f)->frame,
621 &cam->outqueue); 621 &cam->outqueue);
622 if (!list_empty(&cam->inqueue)) 622 if (!list_empty(&cam->inqueue))
623 (*f) = list_entry( 623 (*f) = list_entry(
624 cam->inqueue.next, 624 cam->inqueue.next,
625 struct sn9c102_frame_t, 625 struct sn9c102_frame_t,
626 frame ); 626 frame );
627 else 627 else
628 (*f) = NULL; 628 (*f) = NULL;
629 spin_unlock(&cam->queue_lock); 629 spin_unlock(&cam->queue_lock);
@@ -638,7 +638,7 @@ end_of_frame:
638 } else if (eof) { 638 } else if (eof) {
639 (*f)->state = F_ERROR; 639 (*f)->state = F_ERROR;
640 DBG(3, "Not expected EOF after %lu " 640 DBG(3, "Not expected EOF after %lu "
641 "bytes of image data", 641 "bytes of image data",
642 (unsigned long) 642 (unsigned long)
643 ((*f)->buf.bytesused)); 643 ((*f)->buf.bytesused));
644 } 644 }
@@ -676,7 +676,7 @@ start_of_frame:
676 goto end_of_frame; 676 goto end_of_frame;
677 } else { 677 } else {
678 DBG(3, "SOF before expected EOF after " 678 DBG(3, "SOF before expected EOF after "
679 "%lu bytes of image data", 679 "%lu bytes of image data",
680 (unsigned long) 680 (unsigned long)
681 ((*f)->buf.bytesused)); 681 ((*f)->buf.bytesused));
682 goto start_of_frame; 682 goto start_of_frame;
@@ -702,18 +702,18 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
702 struct usb_device *udev = cam->usbdev; 702 struct usb_device *udev = cam->usbdev;
703 struct urb* urb; 703 struct urb* urb;
704 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512, 704 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512,
705 680, 800, 900, 1023}; 705 680, 800, 900, 1023};
706 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512, 706 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512,
707 680, 800, 900, 1003}; 707 680, 800, 900, 1003};
708 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ? 708 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ?
709 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] : 709 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] :
710 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING]; 710 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
711 s8 i, j; 711 s8 i, j;
712 int err = 0; 712 int err = 0;
713 713
714 for (i = 0; i < SN9C102_URBS; i++) { 714 for (i = 0; i < SN9C102_URBS; i++) {
715 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz, 715 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz,
716 GFP_KERNEL); 716 GFP_KERNEL);
717 if (!cam->transfer_buffer[i]) { 717 if (!cam->transfer_buffer[i]) {
718 err = -ENOMEM; 718 err = -ENOMEM;
719 DBG(1, "Not enough memory"); 719 DBG(1, "Not enough memory");
@@ -815,9 +815,9 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
815 815
816 cam->stream = STREAM_INTERRUPT; 816 cam->stream = STREAM_INTERRUPT;
817 timeout = wait_event_timeout(cam->wait_stream, 817 timeout = wait_event_timeout(cam->wait_stream,
818 (cam->stream == STREAM_OFF) || 818 (cam->stream == STREAM_OFF) ||
819 (cam->state & DEV_DISCONNECTED), 819 (cam->state & DEV_DISCONNECTED),
820 SN9C102_URB_TIMEOUT); 820 SN9C102_URB_TIMEOUT);
821 if (cam->state & DEV_DISCONNECTED) 821 if (cam->state & DEV_DISCONNECTED)
822 return -ENODEV; 822 return -ENODEV;
823 else if (cam->stream != STREAM_OFF) { 823 else if (cam->stream != STREAM_OFF) {
@@ -861,7 +861,7 @@ static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count)
861 861
862/* 862/*
863 NOTE 1: being inside one of the following methods implies that the v4l 863 NOTE 1: being inside one of the following methods implies that the v4l
864 device exists for sure (see kobjects and reference counters) 864 device exists for sure (see kobjects and reference counters)
865 NOTE 2: buffers are PAGE_SIZE long 865 NOTE 2: buffers are PAGE_SIZE long
866*/ 866*/
867 867
@@ -884,10 +884,10 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf)
884 mutex_unlock(&sn9c102_sysfs_lock); 884 mutex_unlock(&sn9c102_sysfs_lock);
885 885
886 return count; 886 return count;
887} 887}
888 888
889 889
890static ssize_t 890static ssize_t
891sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) 891sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len)
892{ 892{
893 struct sn9c102_device* cam; 893 struct sn9c102_device* cam;
@@ -947,7 +947,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf)
947 mutex_unlock(&sn9c102_sysfs_lock); 947 mutex_unlock(&sn9c102_sysfs_lock);
948 948
949 return count; 949 return count;
950} 950}
951 951
952 952
953static ssize_t 953static ssize_t
@@ -1013,7 +1013,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf)
1013} 1013}
1014 1014
1015 1015
1016static ssize_t 1016static ssize_t
1017sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) 1017sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
1018{ 1018{
1019 struct sn9c102_device* cam; 1019 struct sn9c102_device* cam;
@@ -1078,7 +1078,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
1078 mutex_unlock(&sn9c102_sysfs_lock); 1078 mutex_unlock(&sn9c102_sysfs_lock);
1079 1079
1080 return count; 1080 return count;
1081} 1081}
1082 1082
1083 1083
1084static ssize_t 1084static ssize_t
@@ -1222,22 +1222,22 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf)
1222 DBG(3, "Frame header, read bytes: %zd", count); 1222 DBG(3, "Frame header, read bytes: %zd", count);
1223 1223
1224 return count; 1224 return count;
1225} 1225}
1226 1226
1227 1227
1228static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, 1228static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
1229 sn9c102_show_reg, sn9c102_store_reg); 1229 sn9c102_show_reg, sn9c102_store_reg);
1230static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, 1230static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
1231 sn9c102_show_val, sn9c102_store_val); 1231 sn9c102_show_val, sn9c102_store_val);
1232static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, 1232static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
1233 sn9c102_show_i2c_reg, sn9c102_store_i2c_reg); 1233 sn9c102_show_i2c_reg, sn9c102_store_i2c_reg);
1234static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, 1234static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
1235 sn9c102_show_i2c_val, sn9c102_store_i2c_val); 1235 sn9c102_show_i2c_val, sn9c102_store_i2c_val);
1236static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green); 1236static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green);
1237static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue); 1237static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue);
1238static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red); 1238static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
1239static CLASS_DEVICE_ATTR(frame_header, S_IRUGO, 1239static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
1240 sn9c102_show_frame_header, NULL); 1240 sn9c102_show_frame_header, NULL);
1241 1241
1242 1242
1243static void sn9c102_create_sysfs(struct sn9c102_device* cam) 1243static 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)
1278 1278
1279static int 1279static int
1280sn9c102_set_compression(struct sn9c102_device* cam, 1280sn9c102_set_compression(struct sn9c102_device* cam,
1281 struct v4l2_jpegcompression* compression) 1281 struct v4l2_jpegcompression* compression)
1282{ 1282{
1283 int err = 0; 1283 int err = 0;
1284 1284
@@ -1469,8 +1469,8 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1469 } 1469 }
1470 mutex_unlock(&cam->dev_mutex); 1470 mutex_unlock(&cam->dev_mutex);
1471 err = wait_event_interruptible_exclusive(cam->open, 1471 err = wait_event_interruptible_exclusive(cam->open,
1472 cam->state & DEV_DISCONNECTED 1472 cam->state & DEV_DISCONNECTED
1473 || !cam->users); 1473 || !cam->users);
1474 if (err) { 1474 if (err) {
1475 up_read(&sn9c102_disconnect); 1475 up_read(&sn9c102_disconnect);
1476 return err; 1476 return err;
@@ -1600,12 +1600,12 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1600 return -EAGAIN; 1600 return -EAGAIN;
1601 } 1601 }
1602 timeout = wait_event_interruptible_timeout 1602 timeout = wait_event_interruptible_timeout
1603 ( cam->wait_frame, 1603 ( cam->wait_frame,
1604 (!list_empty(&cam->outqueue)) || 1604 (!list_empty(&cam->outqueue)) ||
1605 (cam->state & DEV_DISCONNECTED) || 1605 (cam->state & DEV_DISCONNECTED) ||
1606 (cam->state & DEV_MISCONFIGURED), 1606 (cam->state & DEV_MISCONFIGURED),
1607 cam->module_param.frame_timeout * 1607 cam->module_param.frame_timeout *
1608 1000 * msecs_to_jiffies(1) ); 1608 1000 * msecs_to_jiffies(1) );
1609 if (timeout < 0) { 1609 if (timeout < 0) {
1610 mutex_unlock(&cam->fileop_mutex); 1610 mutex_unlock(&cam->fileop_mutex);
1611 return timeout; 1611 return timeout;
@@ -1672,7 +1672,7 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait)
1672 1672
1673 if (cam->io == IO_NONE) { 1673 if (cam->io == IO_NONE) {
1674 if (!sn9c102_request_buffers(cam, cam->nreadbuffers, 1674 if (!sn9c102_request_buffers(cam, cam->nreadbuffers,
1675 IO_READ)) { 1675 IO_READ)) {
1676 DBG(1, "poll() failed, not enough memory"); 1676 DBG(1, "poll() failed, not enough memory");
1677 goto error; 1677 goto error;
1678 } 1678 }
@@ -1729,7 +1729,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
1729{ 1729{
1730 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 1730 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
1731 unsigned long size = vma->vm_end - vma->vm_start, 1731 unsigned long size = vma->vm_end - vma->vm_start,
1732 start = vma->vm_start; 1732 start = vma->vm_start;
1733 void *pos; 1733 void *pos;
1734 u32 i; 1734 u32 i;
1735 1735
@@ -1797,13 +1797,13 @@ sn9c102_vidioc_querycap(struct sn9c102_device* cam, void __user * arg)
1797 .driver = "sn9c102", 1797 .driver = "sn9c102",
1798 .version = SN9C102_MODULE_VERSION_CODE, 1798 .version = SN9C102_MODULE_VERSION_CODE,
1799 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1799 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1800 V4L2_CAP_STREAMING, 1800 V4L2_CAP_STREAMING,
1801 }; 1801 };
1802 1802
1803 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1803 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1804 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1804 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1805 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1805 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1806 sizeof(cap.bus_info)); 1806 sizeof(cap.bus_info));
1807 1807
1808 if (copy_to_user(arg, &cap, sizeof(cap))) 1808 if (copy_to_user(arg, &cap, sizeof(cap)))
1809 return -EFAULT; 1809 return -EFAULT;
@@ -2138,7 +2138,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2138 return -EINVAL; 2138 return -EINVAL;
2139 2139
2140 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X) 2140 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X)
2141 ? 0 : (pfmt->width * pfmt->priv) / 8; 2141 ? 0 : (pfmt->width * pfmt->priv) / 8;
2142 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8); 2142 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
2143 pfmt->field = V4L2_FIELD_NONE; 2143 pfmt->field = V4L2_FIELD_NONE;
2144 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt)); 2144 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -2152,7 +2152,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2152 2152
2153static int 2153static int
2154sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd, 2154sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2155 void __user * arg) 2155 void __user * arg)
2156{ 2156{
2157 struct sn9c102_sensor* s = &cam->sensor; 2157 struct sn9c102_sensor* s = &cam->sensor;
2158 struct v4l2_format format; 2158 struct v4l2_format format;
@@ -2214,7 +2214,7 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2214 pix->priv = pfmt->priv; /* bpp */ 2214 pix->priv = pfmt->priv; /* bpp */
2215 pix->colorspace = pfmt->colorspace; 2215 pix->colorspace = pfmt->colorspace;
2216 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) 2216 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
2217 ? 0 : (pix->width * pix->priv) / 8; 2217 ? 0 : (pix->width * pix->priv) / 8;
2218 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8); 2218 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
2219 pix->field = V4L2_FIELD_NONE; 2219 pix->field = V4L2_FIELD_NONE;
2220 2220
@@ -2287,7 +2287,7 @@ static int
2287sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg) 2287sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg)
2288{ 2288{
2289 if (copy_to_user(arg, &cam->compression, 2289 if (copy_to_user(arg, &cam->compression,
2290 sizeof(cam->compression))) 2290 sizeof(cam->compression)))
2291 return -EFAULT; 2291 return -EFAULT;
2292 2292
2293 return 0; 2293 return 0;
@@ -2436,7 +2436,7 @@ sn9c102_vidioc_qbuf(struct sn9c102_device* cam, void __user * arg)
2436 2436
2437static int 2437static int
2438sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, 2438sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2439 void __user * arg) 2439 void __user * arg)
2440{ 2440{
2441 struct v4l2_buffer b; 2441 struct v4l2_buffer b;
2442 struct sn9c102_frame_t *f; 2442 struct sn9c102_frame_t *f;
@@ -2455,12 +2455,12 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2455 if (filp->f_flags & O_NONBLOCK) 2455 if (filp->f_flags & O_NONBLOCK)
2456 return -EAGAIN; 2456 return -EAGAIN;
2457 timeout = wait_event_interruptible_timeout 2457 timeout = wait_event_interruptible_timeout
2458 ( cam->wait_frame, 2458 ( cam->wait_frame,
2459 (!list_empty(&cam->outqueue)) || 2459 (!list_empty(&cam->outqueue)) ||
2460 (cam->state & DEV_DISCONNECTED) || 2460 (cam->state & DEV_DISCONNECTED) ||
2461 (cam->state & DEV_MISCONFIGURED), 2461 (cam->state & DEV_MISCONFIGURED),
2462 cam->module_param.frame_timeout * 2462 cam->module_param.frame_timeout *
2463 1000 * msecs_to_jiffies(1) ); 2463 1000 * msecs_to_jiffies(1) );
2464 if (timeout < 0) 2464 if (timeout < 0)
2465 return timeout; 2465 return timeout;
2466 if (cam->state & DEV_DISCONNECTED) 2466 if (cam->state & DEV_DISCONNECTED)
@@ -2584,7 +2584,7 @@ sn9c102_vidioc_s_parm(struct sn9c102_device* cam, void __user * arg)
2584 2584
2585 2585
2586static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, 2586static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2587 unsigned int cmd, void __user * arg) 2587 unsigned int cmd, void __user * arg)
2588{ 2588{
2589 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 2589 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2590 2590
@@ -2678,7 +2678,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2678 2678
2679 2679
2680static int sn9c102_ioctl(struct inode* inode, struct file* filp, 2680static int sn9c102_ioctl(struct inode* inode, struct file* filp,
2681 unsigned int cmd, unsigned long arg) 2681 unsigned int cmd, unsigned long arg)
2682{ 2682{
2683 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 2683 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2684 int err = 0; 2684 int err = 0;
@@ -2761,7 +2761,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2761 } 2761 }
2762 2762
2763 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ? 2763 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ?
2764 BRIDGE_SN9C103 : BRIDGE_SN9C102; 2764 BRIDGE_SN9C103 : BRIDGE_SN9C102;
2765 switch (cam->bridge) { 2765 switch (cam->bridge) {
2766 case BRIDGE_SN9C101: 2766 case BRIDGE_SN9C101:
2767 case BRIDGE_SN9C102: 2767 case BRIDGE_SN9C102:
@@ -2807,7 +2807,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2807 mutex_lock(&cam->dev_mutex); 2807 mutex_lock(&cam->dev_mutex);
2808 2808
2809 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 2809 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2810 video_nr[dev_nr]); 2810 video_nr[dev_nr]);
2811 if (err) { 2811 if (err) {
2812 DBG(1, "V4L2 device registration failed"); 2812 DBG(1, "V4L2 device registration failed");
2813 if (err == -ENFILE && video_nr[dev_nr] == -1) 2813 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 46c12ec3ca62..c4117bf64b69 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)
44} 44}
45 45
46 46
47static int hv7131d_get_ctrl(struct sn9c102_device* cam, 47static int hv7131d_get_ctrl(struct sn9c102_device* cam,
48 struct v4l2_control* ctrl) 48 struct v4l2_control* ctrl)
49{ 49{
50 switch (ctrl->id) { 50 switch (ctrl->id) {
51 case V4L2_CID_EXPOSURE: 51 case V4L2_CID_EXPOSURE:
@@ -88,8 +88,8 @@ static int hv7131d_get_ctrl(struct sn9c102_device* cam,
88} 88}
89 89
90 90
91static int hv7131d_set_ctrl(struct sn9c102_device* cam, 91static int hv7131d_set_ctrl(struct sn9c102_device* cam,
92 const struct v4l2_control* ctrl) 92 const struct v4l2_control* ctrl)
93{ 93{
94 int err = 0; 94 int err = 0;
95 95
@@ -121,8 +121,8 @@ static int hv7131d_set_ctrl(struct sn9c102_device* cam,
121} 121}
122 122
123 123
124static int hv7131d_set_crop(struct sn9c102_device* cam, 124static int hv7131d_set_crop(struct sn9c102_device* cam,
125 const struct v4l2_rect* rect) 125 const struct v4l2_rect* rect)
126{ 126{
127 struct sn9c102_sensor* s = &hv7131d; 127 struct sn9c102_sensor* s = &hv7131d;
128 int err = 0; 128 int err = 0;
@@ -136,8 +136,8 @@ static int hv7131d_set_crop(struct sn9c102_device* cam,
136} 136}
137 137
138 138
139static int hv7131d_set_pix_format(struct sn9c102_device* cam, 139static int hv7131d_set_pix_format(struct sn9c102_device* cam,
140 const struct v4l2_pix_format* pix) 140 const struct v4l2_pix_format* pix)
141{ 141{
142 int err = 0; 142 int err = 0;
143 143
diff --git a/drivers/usb/media/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index d9aa7a61095d..4169ea4a2e20 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)
39 err += sn9c102_write_reg(cam, 0xa0, 0x19); 39 err += sn9c102_write_reg(cam, 0xa0, 0x19);
40 40
41 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 41 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
42 0x0d, 0x00, 0x01, 0, 0); 42 0x0d, 0x00, 0x01, 0, 0);
43 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 43 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
44 0x0d, 0x00, 0x00, 0, 0); 44 0x0d, 0x00, 0x00, 0, 0);
45 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 45 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
46 0x03, 0x01, 0xe1, 0, 0); 46 0x03, 0x01, 0xe1, 0, 0);
47 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 47 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
48 0x04, 0x02, 0x81, 0, 0); 48 0x04, 0x02, 0x81, 0, 0);
49 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 49 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
50 0x05, 0x00, 0x17, 0, 0); 50 0x05, 0x00, 0x17, 0, 0);
51 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 51 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
52 0x06, 0x00, 0x11, 0, 0); 52 0x06, 0x00, 0x11, 0, 0);
53 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 53 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
54 0x62, 0x04, 0x9a, 0, 0); 54 0x62, 0x04, 0x9a, 0, 0);
55 55
56 return err; 56 return err;
57} 57}
58 58
59 59
60static int mi0343_get_ctrl(struct sn9c102_device* cam, 60static int mi0343_get_ctrl(struct sn9c102_device* cam,
61 struct v4l2_control* ctrl) 61 struct v4l2_control* ctrl)
62{ 62{
63 switch (ctrl->id) { 63 switch (ctrl->id) {
64 case V4L2_CID_EXPOSURE: 64 case V4L2_CID_EXPOSURE:
65 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 65 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
66 0x09, 2+1, mi0343_i2c_data) < 0) 66 0x09, 2+1, mi0343_i2c_data) < 0)
67 return -EIO; 67 return -EIO;
68 ctrl->value = mi0343_i2c_data[2]; 68 ctrl->value = mi0343_i2c_data[2];
69 return 0; 69 return 0;
70 case V4L2_CID_GAIN: 70 case V4L2_CID_GAIN:
71 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 71 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
72 0x35, 2+1, mi0343_i2c_data) < 0) 72 0x35, 2+1, mi0343_i2c_data) < 0)
73 return -EIO; 73 return -EIO;
74 break; 74 break;
75 case V4L2_CID_HFLIP: 75 case V4L2_CID_HFLIP:
76 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 76 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
77 0x20, 2+1, mi0343_i2c_data) < 0) 77 0x20, 2+1, mi0343_i2c_data) < 0)
78 return -EIO; 78 return -EIO;
79 ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0; 79 ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0;
80 return 0; 80 return 0;
81 case V4L2_CID_VFLIP: 81 case V4L2_CID_VFLIP:
82 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 82 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
83 0x20, 2+1, mi0343_i2c_data) < 0) 83 0x20, 2+1, mi0343_i2c_data) < 0)
84 return -EIO; 84 return -EIO;
85 ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0; 85 ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0;
86 return 0; 86 return 0;
87 case V4L2_CID_RED_BALANCE: 87 case V4L2_CID_RED_BALANCE:
88 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 88 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
89 0x2d, 2+1, mi0343_i2c_data) < 0) 89 0x2d, 2+1, mi0343_i2c_data) < 0)
90 return -EIO; 90 return -EIO;
91 break; 91 break;
92 case V4L2_CID_BLUE_BALANCE: 92 case V4L2_CID_BLUE_BALANCE:
93 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 93 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
94 0x2c, 2+1, mi0343_i2c_data) < 0) 94 0x2c, 2+1, mi0343_i2c_data) < 0)
95 return -EIO; 95 return -EIO;
96 break; 96 break;
97 case SN9C102_V4L2_CID_GREEN_BALANCE: 97 case SN9C102_V4L2_CID_GREEN_BALANCE:
98 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 98 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
99 0x2e, 2+1, mi0343_i2c_data) < 0) 99 0x2e, 2+1, mi0343_i2c_data) < 0)
100 return -EIO; 100 return -EIO;
101 break; 101 break;
102 default: 102 default:
@@ -121,8 +121,8 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
121} 121}
122 122
123 123
124static int mi0343_set_ctrl(struct sn9c102_device* cam, 124static int mi0343_set_ctrl(struct sn9c102_device* cam,
125 const struct v4l2_control* ctrl) 125 const struct v4l2_control* ctrl)
126{ 126{
127 u16 reg = 0; 127 u16 reg = 0;
128 int err = 0; 128 int err = 0;
@@ -144,51 +144,51 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
144 switch (ctrl->id) { 144 switch (ctrl->id) {
145 case V4L2_CID_EXPOSURE: 145 case V4L2_CID_EXPOSURE:
146 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 146 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
147 mi0343.i2c_slave_id, 147 mi0343.i2c_slave_id,
148 0x09, ctrl->value, 0x00, 148 0x09, ctrl->value, 0x00,
149 0, 0); 149 0, 0);
150 break; 150 break;
151 case V4L2_CID_GAIN: 151 case V4L2_CID_GAIN:
152 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 152 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
153 mi0343.i2c_slave_id, 153 mi0343.i2c_slave_id,
154 0x35, reg >> 8, reg & 0xff, 154 0x35, reg >> 8, reg & 0xff,
155 0, 0); 155 0, 0);
156 break; 156 break;
157 case V4L2_CID_HFLIP: 157 case V4L2_CID_HFLIP:
158 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 158 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
159 mi0343.i2c_slave_id, 159 mi0343.i2c_slave_id,
160 0x20, ctrl->value ? 0x40:0x00, 160 0x20, ctrl->value ? 0x40:0x00,
161 ctrl->value ? 0x20:0x00, 161 ctrl->value ? 0x20:0x00,
162 0, 0); 162 0, 0);
163 break; 163 break;
164 case V4L2_CID_VFLIP: 164 case V4L2_CID_VFLIP:
165 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 165 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
166 mi0343.i2c_slave_id, 166 mi0343.i2c_slave_id,
167 0x20, ctrl->value ? 0x80:0x00, 167 0x20, ctrl->value ? 0x80:0x00,
168 ctrl->value ? 0x80:0x00, 168 ctrl->value ? 0x80:0x00,
169 0, 0); 169 0, 0);
170 break; 170 break;
171 case V4L2_CID_RED_BALANCE: 171 case V4L2_CID_RED_BALANCE:
172 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 172 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
173 mi0343.i2c_slave_id, 173 mi0343.i2c_slave_id,
174 0x2d, reg >> 8, reg & 0xff, 174 0x2d, reg >> 8, reg & 0xff,
175 0, 0); 175 0, 0);
176 break; 176 break;
177 case V4L2_CID_BLUE_BALANCE: 177 case V4L2_CID_BLUE_BALANCE:
178 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 178 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
179 mi0343.i2c_slave_id, 179 mi0343.i2c_slave_id,
180 0x2c, reg >> 8, reg & 0xff, 180 0x2c, reg >> 8, reg & 0xff,
181 0, 0); 181 0, 0);
182 break; 182 break;
183 case SN9C102_V4L2_CID_GREEN_BALANCE: 183 case SN9C102_V4L2_CID_GREEN_BALANCE:
184 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 184 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
185 mi0343.i2c_slave_id, 185 mi0343.i2c_slave_id,
186 0x2b, reg >> 8, reg & 0xff, 186 0x2b, reg >> 8, reg & 0xff,
187 0, 0); 187 0, 0);
188 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 188 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
189 mi0343.i2c_slave_id, 189 mi0343.i2c_slave_id,
190 0x2e, reg >> 8, reg & 0xff, 190 0x2e, reg >> 8, reg & 0xff,
191 0, 0); 191 0, 0);
192 break; 192 break;
193 default: 193 default:
194 return -EINVAL; 194 return -EINVAL;
@@ -198,8 +198,8 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
198} 198}
199 199
200 200
201static int mi0343_set_crop(struct sn9c102_device* cam, 201static int mi0343_set_crop(struct sn9c102_device* cam,
202 const struct v4l2_rect* rect) 202 const struct v4l2_rect* rect)
203{ 203{
204 struct sn9c102_sensor* s = &mi0343; 204 struct sn9c102_sensor* s = &mi0343;
205 int err = 0; 205 int err = 0;
@@ -213,20 +213,20 @@ static int mi0343_set_crop(struct sn9c102_device* cam,
213} 213}
214 214
215 215
216static int mi0343_set_pix_format(struct sn9c102_device* cam, 216static int mi0343_set_pix_format(struct sn9c102_device* cam,
217 const struct v4l2_pix_format* pix) 217 const struct v4l2_pix_format* pix)
218{ 218{
219 int err = 0; 219 int err = 0;
220 220
221 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { 221 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) {
222 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 222 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
223 mi0343.i2c_slave_id, 223 mi0343.i2c_slave_id,
224 0x0a, 0x00, 0x03, 0, 0); 224 0x0a, 0x00, 0x03, 0, 0);
225 err += sn9c102_write_reg(cam, 0x20, 0x19); 225 err += sn9c102_write_reg(cam, 0x20, 0x19);
226 } else { 226 } else {
227 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 227 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
228 mi0343.i2c_slave_id, 228 mi0343.i2c_slave_id,
229 0x0a, 0x00, 0x05, 0, 0); 229 0x0a, 0x00, 0x05, 0, 0);
230 err += sn9c102_write_reg(cam, 0xa0, 0x19); 230 err += sn9c102_write_reg(cam, 0xa0, 0x19);
231 } 231 }
232 232
@@ -351,7 +351,7 @@ int sn9c102_probe_mi0343(struct sn9c102_device* cam)
351 return -EIO; 351 return -EIO;
352 352
353 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 353 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
354 2, mi0343_i2c_data) < 0) 354 2, mi0343_i2c_data) < 0)
355 return -EIO; 355 return -EIO;
356 356
357 if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3) 357 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 42852b7cb042..3da042021787 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)
69 69
70 70
71static int ov7630_set_ctrl(struct sn9c102_device* cam, 71static int ov7630_set_ctrl(struct sn9c102_device* cam,
72 const struct v4l2_control* ctrl) 72 const struct v4l2_control* ctrl)
73{ 73{
74 int err = 0; 74 int err = 0;
75 75
@@ -89,8 +89,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
89 break; 89 break;
90 case V4L2_CID_CONTRAST: 90 case V4L2_CID_CONTRAST:
91 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05, 91 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05,
92 (ctrl->value-1) | 0x20) 92 (ctrl->value-1) | 0x20)
93 : sn9c102_i2c_write(cam, 0x05, 0x00); 93 : sn9c102_i2c_write(cam, 0x05, 0x00);
94 break; 94 break;
95 case V4L2_CID_BRIGHTNESS: 95 case V4L2_CID_BRIGHTNESS:
96 err += sn9c102_i2c_write(cam, 0x06, ctrl->value); 96 err += sn9c102_i2c_write(cam, 0x06, ctrl->value);
@@ -100,8 +100,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
100 break; 100 break;
101 case V4L2_CID_HUE: 101 case V4L2_CID_HUE:
102 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04, 102 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04,
103 (ctrl->value-1) | 0x20) 103 (ctrl->value-1) | 0x20)
104 : sn9c102_i2c_write(cam, 0x04, 0x00); 104 : sn9c102_i2c_write(cam, 0x04, 0x00);
105 break; 105 break;
106 case V4L2_CID_DO_WHITE_BALANCE: 106 case V4L2_CID_DO_WHITE_BALANCE:
107 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value); 107 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
@@ -139,7 +139,7 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
139 139
140 140
141static int ov7630_set_crop(struct sn9c102_device* cam, 141static int ov7630_set_crop(struct sn9c102_device* cam,
142 const struct v4l2_rect* rect) 142 const struct v4l2_rect* rect)
143{ 143{
144 struct sn9c102_sensor* s = &ov7630; 144 struct sn9c102_sensor* s = &ov7630;
145 int err = 0; 145 int err = 0;
@@ -152,7 +152,7 @@ static int ov7630_set_crop(struct sn9c102_device* cam,
152 152
153 153
154static int ov7630_set_pix_format(struct sn9c102_device* cam, 154static int ov7630_set_pix_format(struct sn9c102_device* cam,
155 const struct v4l2_pix_format* pix) 155 const struct v4l2_pix_format* pix)
156{ 156{
157 int err = 0; 157 int err = 0;
158 158
diff --git a/drivers/usb/media/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c
index b1dee78abe04..9915944235e8 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)
53} 53}
54 54
55 55
56static int pas106b_get_ctrl(struct sn9c102_device* cam, 56static int pas106b_get_ctrl(struct sn9c102_device* cam,
57 struct v4l2_control* ctrl) 57 struct v4l2_control* ctrl)
58{ 58{
59 switch (ctrl->id) { 59 switch (ctrl->id) {
60 case V4L2_CID_EXPOSURE: 60 case V4L2_CID_EXPOSURE:
@@ -102,8 +102,8 @@ static int pas106b_get_ctrl(struct sn9c102_device* cam,
102} 102}
103 103
104 104
105static int pas106b_set_ctrl(struct sn9c102_device* cam, 105static int pas106b_set_ctrl(struct sn9c102_device* cam,
106 const struct v4l2_control* ctrl) 106 const struct v4l2_control* ctrl)
107{ 107{
108 int err = 0; 108 int err = 0;
109 109
@@ -140,8 +140,8 @@ static int pas106b_set_ctrl(struct sn9c102_device* cam,
140} 140}
141 141
142 142
143static int pas106b_set_crop(struct sn9c102_device* cam, 143static int pas106b_set_crop(struct sn9c102_device* cam,
144 const struct v4l2_rect* rect) 144 const struct v4l2_rect* rect)
145{ 145{
146 struct sn9c102_sensor* s = &pas106b; 146 struct sn9c102_sensor* s = &pas106b;
147 int err = 0; 147 int err = 0;
@@ -155,8 +155,8 @@ static int pas106b_set_crop(struct sn9c102_device* cam,
155} 155}
156 156
157 157
158static int pas106b_set_pix_format(struct sn9c102_device* cam, 158static int pas106b_set_pix_format(struct sn9c102_device* cam,
159 const struct v4l2_pix_format* pix) 159 const struct v4l2_pix_format* pix)
160{ 160{
161 int err = 0; 161 int err = 0;
162 162
diff --git a/drivers/usb/media/sn9c102_pas202bca.c b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
index 3453237055bb..c8f1ae2152b8 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)
54 54
55 55
56static int pas202bca_set_pix_format(struct sn9c102_device* cam, 56static int pas202bca_set_pix_format(struct sn9c102_device* cam,
57 const struct v4l2_pix_format* pix) 57 const struct v4l2_pix_format* pix)
58{ 58{
59 int err = 0; 59 int err = 0;
60 60
@@ -68,7 +68,7 @@ static int pas202bca_set_pix_format(struct sn9c102_device* cam,
68 68
69 69
70static int pas202bca_set_ctrl(struct sn9c102_device* cam, 70static int pas202bca_set_ctrl(struct sn9c102_device* cam,
71 const struct v4l2_control* ctrl) 71 const struct v4l2_control* ctrl)
72{ 72{
73 int err = 0; 73 int err = 0;
74 74
@@ -102,7 +102,7 @@ static int pas202bca_set_ctrl(struct sn9c102_device* cam,
102 102
103 103
104static int pas202bca_set_crop(struct sn9c102_device* cam, 104static int pas202bca_set_crop(struct sn9c102_device* cam,
105 const struct v4l2_rect* rect) 105 const struct v4l2_rect* rect)
106{ 106{
107 struct sn9c102_sensor* s = &pas202bca; 107 struct sn9c102_sensor* s = &pas202bca;
108 int err = 0; 108 int err = 0;
diff --git a/drivers/usb/media/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
index d068616ab337..e3c1178e339c 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)
58} 58}
59 59
60 60
61static int pas202bcb_get_ctrl(struct sn9c102_device* cam, 61static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
62 struct v4l2_control* ctrl) 62 struct v4l2_control* ctrl)
63{ 63{
64 switch (ctrl->id) { 64 switch (ctrl->id) {
65 case V4L2_CID_EXPOSURE: 65 case V4L2_CID_EXPOSURE:
@@ -101,8 +101,8 @@ static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
101} 101}
102 102
103 103
104static int pas202bcb_set_pix_format(struct sn9c102_device* cam, 104static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
105 const struct v4l2_pix_format* pix) 105 const struct v4l2_pix_format* pix)
106{ 106{
107 int err = 0; 107 int err = 0;
108 108
@@ -115,8 +115,8 @@ static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
115} 115}
116 116
117 117
118static int pas202bcb_set_ctrl(struct sn9c102_device* cam, 118static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
119 const struct v4l2_control* ctrl) 119 const struct v4l2_control* ctrl)
120{ 120{
121 int err = 0; 121 int err = 0;
122 122
@@ -149,8 +149,8 @@ static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
149} 149}
150 150
151 151
152static int pas202bcb_set_crop(struct sn9c102_device* cam, 152static int pas202bcb_set_crop(struct sn9c102_device* cam,
153 const struct v4l2_rect* rect) 153 const struct v4l2_rect* rect)
154{ 154{
155 struct sn9c102_sensor* s = &pas202bcb; 155 struct sn9c102_sensor* s = &pas202bcb;
156 int err = 0; 156 int err = 0;
@@ -167,7 +167,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam,
167static struct sn9c102_sensor pas202bcb = { 167static struct sn9c102_sensor pas202bcb = {
168 .name = "PAS202BCB", 168 .name = "PAS202BCB",
169 .maintainer = "Carlos Eduardo Medaglia Dyonisio " 169 .maintainer = "Carlos Eduardo Medaglia Dyonisio "
170 "<medaglia@undl.org.br>", 170 "<medaglia@undl.org.br>",
171 .sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE, 171 .sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE,
172 .frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ, 172 .frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ,
173 .interface = SN9C102_I2C_2WIRES, 173 .interface = SN9C102_I2C_2WIRES,
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 2afd9e9d09bb..2a874ee6f9f5 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -58,7 +58,7 @@ struct sn9c102_sensor;
58 Probing functions: on success, you must attach the sensor to the camera 58 Probing functions: on success, you must attach the sensor to the camera
59 by calling sn9c102_attach_sensor() provided below. 59 by calling sn9c102_attach_sensor() provided below.
60 To enable the I2C communication, you might need to perform a really basic 60 To enable the I2C communication, you might need to perform a really basic
61 initialization of the SN9C10X chip by using the write function declared 61 initialization of the SN9C10X chip by using the write function declared
62 ahead. 62 ahead.
63 Functions must return 0 on success, the appropriate error otherwise. 63 Functions must return 0 on success, the appropriate error otherwise.
64*/ 64*/
@@ -73,7 +73,7 @@ extern int sn9c102_probe_tas5130d1b(struct sn9c102_device* cam);
73 73
74/* 74/*
75 Add the above entries to this table. Be sure to add the entry in the right 75 Add the above entries to this table. Be sure to add the entry in the right
76 place, since, on failure, the next probing routine is called according to 76 place, since, on failure, the next probing routine is called according to
77 the order of the list below, from top to bottom. 77 the order of the list below, from top to bottom.
78*/ 78*/
79#define SN9C102_SENSOR_TABLE \ 79#define SN9C102_SENSOR_TABLE \
@@ -94,9 +94,9 @@ extern struct sn9c102_device*
94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id); 94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
95 95
96/* Attach a probed sensor to the camera. */ 96/* Attach a probed sensor to the camera. */
97extern void 97extern void
98sn9c102_attach_sensor(struct sn9c102_device* cam, 98sn9c102_attach_sensor(struct sn9c102_device* cam,
99 struct sn9c102_sensor* sensor); 99 struct sn9c102_sensor* sensor);
100 100
101/* 101/*
102 Each SN9C10x camera has proper PID/VID identifiers. 102 Each SN9C10x camera has proper PID/VID identifiers.
@@ -105,7 +105,7 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
105*/ 105*/
106#define SN9C102_USB_DEVICE(vend, prod, intclass) \ 106#define SN9C102_USB_DEVICE(vend, prod, intclass) \
107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
108 USB_DEVICE_ID_MATCH_INT_CLASS, \ 108 USB_DEVICE_ID_MATCH_INT_CLASS, \
109 .idVendor = (vend), \ 109 .idVendor = (vend), \
110 .idProduct = (prod), \ 110 .idProduct = (prod), \
111 .bInterfaceClass = (intclass) 111 .bInterfaceClass = (intclass)
@@ -162,19 +162,19 @@ static const struct usb_device_id sn9c102_id_table[] = { \
162 Read/write routines: they always return -1 on error, 0 or the read value 162 Read/write routines: they always return -1 on error, 0 or the read value
163 otherwise. NOTE that a real read operation is not supported by the SN9C10X 163 otherwise. NOTE that a real read operation is not supported by the SN9C10X
164 chip for some of its registers. To work around this problem, a pseudo-read 164 chip for some of its registers. To work around this problem, a pseudo-read
165 call is provided instead: it returns the last successfully written value 165 call is provided instead: it returns the last successfully written value
166 on the register (0 if it has never been written), the usual -1 on error. 166 on the register (0 if it has never been written), the usual -1 on error.
167*/ 167*/
168 168
169/* The "try" I2C I/O versions are used when probing the sensor */ 169/* The "try" I2C I/O versions are used when probing the sensor */
170extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, 170extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
171 u8 address, u8 value); 171 u8 address, u8 value);
172extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 172extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
173 u8 address); 173 u8 address);
174 174
175/* 175/*
176 These must be used if and only if the sensor doesn't implement the standard 176 These must be used if and only if the sensor doesn't implement the standard
177 I2C protocol. There are a number of good reasons why you must use the 177 I2C protocol. There are a number of good reasons why you must use the
178 single-byte versions of these functions: do not abuse. The first function 178 single-byte versions of these functions: do not abuse. The first function
179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X 179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X
180 chip. The second one programs the registers 0x09 and 0x10 with data0 and 180 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*,
184 byte. 184 byte.
185*/ 185*/
186extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 186extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
187 struct sn9c102_sensor* sensor, u8 n, 187 struct sn9c102_sensor* sensor, u8 n,
188 u8 data0, u8 data1, u8 data2, u8 data3, 188 u8 data0, u8 data1, u8 data2, u8 data3,
189 u8 data4, u8 data5); 189 u8 data4, u8 data5);
190extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 190extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
191 struct sn9c102_sensor* sensor, u8 data0, 191 struct sn9c102_sensor* sensor, u8 data0,
192 u8 data1, u8 n, u8 buffer[]); 192 u8 data1, u8 n, u8 buffer[]);
193 193
194/* To be used after the sensor struct has been attached to the camera struct */ 194/* To be used after the sensor struct has been attached to the camera struct */
195extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); 195extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
@@ -252,17 +252,17 @@ struct sn9c102_sensor {
252 252
253 /* 253 /*
254 NOTE: Where not noted,most of the functions below are not mandatory. 254 NOTE: Where not noted,most of the functions below are not mandatory.
255 Set to null if you do not implement them. If implemented, 255 Set to null if you do not implement them. If implemented,
256 they must return 0 on success, the proper error otherwise. 256 they must return 0 on success, the proper error otherwise.
257 */ 257 */
258 258
259 int (*init)(struct sn9c102_device* cam); 259 int (*init)(struct sn9c102_device* cam);
260 /* 260 /*
261 This function will be called after the sensor has been attached. 261 This function will be called after the sensor has been attached.
262 It should be used to initialize the sensor only, but may also 262 It should be used to initialize the sensor only, but may also
263 configure part of the SN9C10X chip if necessary. You don't need to 263 configure part of the SN9C10X chip if necessary. You don't need to
264 setup picture settings like brightness, contrast, etc.. here, if 264 setup picture settings like brightness, contrast, etc.. here, if
265 the corrisponding controls are implemented (see below), since 265 the corrisponding controls are implemented (see below), since
266 they are adjusted in the core driver by calling the set_ctrl() 266 they are adjusted in the core driver by calling the set_ctrl()
267 method after init(), where the arguments are the default values 267 method after init(), where the arguments are the default values
268 specified in the v4l2_queryctrl list of supported controls; 268 specified in the v4l2_queryctrl list of supported controls;
@@ -273,13 +273,13 @@ struct sn9c102_sensor {
273 273
274 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS]; 274 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS];
275 /* 275 /*
276 Optional list of default controls, defined as indicated in the 276 Optional list of default controls, defined as indicated in the
277 V4L2 API. Menu type controls are not handled by this interface. 277 V4L2 API. Menu type controls are not handled by this interface.
278 */ 278 */
279 279
280 int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl); 280 int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl);
281 int (*set_ctrl)(struct sn9c102_device* cam, 281 int (*set_ctrl)(struct sn9c102_device* cam,
282 const struct v4l2_control* ctrl); 282 const struct v4l2_control* ctrl);
283 /* 283 /*
284 You must implement at least the set_ctrl method if you have defined 284 You must implement at least the set_ctrl method if you have defined
285 the list above. The returned value must follow the V4L2 285 the list above. The returned value must follow the V4L2
@@ -306,7 +306,7 @@ struct sn9c102_sensor {
306 specified in the cropcap substructures 'bounds' and 'defrect'. 306 specified in the cropcap substructures 'bounds' and 'defrect'.
307 By default, the source rectangle should cover the largest possible 307 By default, the source rectangle should cover the largest possible
308 area. Again, it is not always true that the largest source rectangle 308 area. Again, it is not always true that the largest source rectangle
309 can cover the entire active window, although it is a rare case for 309 can cover the entire active window, although it is a rare case for
310 the hardware we have. The bounds of the source rectangle _must_ be 310 the hardware we have. The bounds of the source rectangle _must_ be
311 multiple of 16 and must use the same coordinate system as indicated 311 multiple of 16 and must use the same coordinate system as indicated
312 before; their centers shall align initially. 312 before; their centers shall align initially.
@@ -317,13 +317,13 @@ struct sn9c102_sensor {
317 defined the correct default bounds in the structures. 317 defined the correct default bounds in the structures.
318 See the V4L2 API for further details. 318 See the V4L2 API for further details.
319 NOTE: once you have defined the bounds of the active window 319 NOTE: once you have defined the bounds of the active window
320 (struct cropcap.bounds) you must not change them.anymore. 320 (struct cropcap.bounds) you must not change them.anymore.
321 Only 'bounds' and 'defrect' fields are mandatory, other fields 321 Only 'bounds' and 'defrect' fields are mandatory, other fields
322 will be ignored. 322 will be ignored.
323 */ 323 */
324 324
325 int (*set_crop)(struct sn9c102_device* cam, 325 int (*set_crop)(struct sn9c102_device* cam,
326 const struct v4l2_rect* rect); 326 const struct v4l2_rect* rect);
327 /* 327 /*
328 To be called on VIDIOC_C_SETCROP. The core module always calls a 328 To be called on VIDIOC_C_SETCROP. The core module always calls a
329 default routine which configures the appropriate SN9C10X regs (also 329 default routine which configures the appropriate SN9C10X regs (also
@@ -332,12 +332,12 @@ struct sn9c102_sensor {
332 case you override the default function, you always have to program 332 case you override the default function, you always have to program
333 the chip to match those values; on error return the corresponding 333 the chip to match those values; on error return the corresponding
334 error code without rolling back. 334 error code without rolling back.
335 NOTE: in case, you must program the SN9C10X chip to get rid of 335 NOTE: in case, you must program the SN9C10X chip to get rid of
336 blank pixels or blank lines at the _start_ of each line or 336 blank pixels or blank lines at the _start_ of each line or
337 frame after each HSYNC or VSYNC, so that the image starts with 337 frame after each HSYNC or VSYNC, so that the image starts with
338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and, 338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
339 V_SIZE you don't have to care about blank pixels or blank 339 V_SIZE you don't have to care about blank pixels or blank
340 lines at the end of each line or frame). 340 lines at the end of each line or frame).
341 */ 341 */
342 342
343 struct v4l2_pix_format pix_format; 343 struct v4l2_pix_format pix_format;
@@ -349,17 +349,17 @@ struct sn9c102_sensor {
349 number of bits per pixel for uncompressed video, 8 or 9 (despite the 349 number of bits per pixel for uncompressed video, 8 or 9 (despite the
350 current value of 'pixelformat'). 350 current value of 'pixelformat').
351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4 351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4
352 of cropcap.defrect.width and cropcap.defrect.height. I 352 of cropcap.defrect.width and cropcap.defrect.height. I
353 suggest 1/1. 353 suggest 1/1.
354 NOTE 2: The initial compression quality is defined by the first bit 354 NOTE 2: The initial compression quality is defined by the first bit
355 of reg 0x17 during the initialization of the image sensor. 355 of reg 0x17 during the initialization of the image sensor.
356 NOTE 3: as said above, you have to program the SN9C10X chip to get 356 NOTE 3: as said above, you have to program the SN9C10X chip to get
357 rid of any blank pixels, so that the output of the sensor 357 rid of any blank pixels, so that the output of the sensor
358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR). 358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
359 */ 359 */
360 360
361 int (*set_pix_format)(struct sn9c102_device* cam, 361 int (*set_pix_format)(struct sn9c102_device* cam,
362 const struct v4l2_pix_format* pix); 362 const struct v4l2_pix_format* pix);
363 /* 363 /*
364 To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to 364 To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to
365 SN9C10X pixel format or viceversa. On error return the corresponding 365 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 2e08c552f40a..294eb02fbd88 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)
44} 44}
45 45
46 46
47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam, 47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
48 const struct v4l2_control* ctrl) 48 const struct v4l2_control* ctrl)
49{ 49{
50 int err = 0; 50 int err = 0;
51 51
@@ -61,8 +61,8 @@ static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
61} 61}
62 62
63 63
64static int tas5110c1b_set_crop(struct sn9c102_device* cam, 64static int tas5110c1b_set_crop(struct sn9c102_device* cam,
65 const struct v4l2_rect* rect) 65 const struct v4l2_rect* rect)
66{ 66{
67 struct sn9c102_sensor* s = &tas5110c1b; 67 struct sn9c102_sensor* s = &tas5110c1b;
68 int err = 0; 68 int err = 0;
@@ -81,8 +81,8 @@ static int tas5110c1b_set_crop(struct sn9c102_device* cam,
81} 81}
82 82
83 83
84static int tas5110c1b_set_pix_format(struct sn9c102_device* cam, 84static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
85 const struct v4l2_pix_format* pix) 85 const struct v4l2_pix_format* pix)
86{ 86{
87 int err = 0; 87 int err = 0;
88 88
diff --git a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
index c7b339740bbf..9ecb09032b68 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)
42} 42}
43 43
44 44
45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam, 45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
46 const struct v4l2_control* ctrl) 46 const struct v4l2_control* ctrl)
47{ 47{
48 int err = 0; 48 int err = 0;
49 49
@@ -62,8 +62,8 @@ static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
62} 62}
63 63
64 64
65static int tas5130d1b_set_crop(struct sn9c102_device* cam, 65static int tas5130d1b_set_crop(struct sn9c102_device* cam,
66 const struct v4l2_rect* rect) 66 const struct v4l2_rect* rect)
67{ 67{
68 struct sn9c102_sensor* s = &tas5130d1b; 68 struct sn9c102_sensor* s = &tas5130d1b;
69 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104, 69 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104,
@@ -82,8 +82,8 @@ static int tas5130d1b_set_crop(struct sn9c102_device* cam,
82} 82}
83 83
84 84
85static int tas5130d1b_set_pix_format(struct sn9c102_device* cam, 85static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
86 const struct v4l2_pix_format* pix) 86 const struct v4l2_pix_format* pix)
87{ 87{
88 int err = 0; 88 int err = 0;
89 89
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 9d769264a329..07476c71174a 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * stradis.c - stradis 4:2:2 mpeg decoder driver 2 * stradis.c - stradis 4:2:2 mpeg decoder driver
3 * 3 *
4 * Stradis 4:2:2 MPEG-2 Decoder Driver 4 * Stradis 4:2:2 MPEG-2 Decoder Driver
@@ -1191,9 +1191,9 @@ static void saa7146_set_winsize(struct saa7146 *saa)
1191} 1191}
1192 1192
1193/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area 1193/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area
1194 * bitmap is fixed width, 128 bytes (1024 pixels represented) 1194 * bitmap is fixed width, 128 bytes (1024 pixels represented)
1195 * arranged most-sigificant-bit-left in 32-bit words 1195 * arranged most-sigificant-bit-left in 32-bit words
1196 * based on saa7146 clipping hardware, it swaps bytes if LE 1196 * based on saa7146 clipping hardware, it swaps bytes if LE
1197 * much of this makes up for egcs brain damage -- so if you 1197 * much of this makes up for egcs brain damage -- so if you
1198 * are wondering "why did he do this?" it is because the C 1198 * are wondering "why did he do this?" it is because the C
1199 * was adjusted to generate the optimal asm output without 1199 * 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)
1259 clip_draw_rectangle(clipmap, cr[i].x, cr[i].y, 1259 clip_draw_rectangle(clipmap, cr[i].x, cr[i].y,
1260 cr[i].width, cr[i].height); 1260 cr[i].width, cr[i].height);
1261 } 1261 }
1262 /* clip against viewing window AND screen 1262 /* clip against viewing window AND screen
1263 so we do not have to rely on the user program 1263 so we do not have to rely on the user program
1264 */ 1264 */
1265 clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ? 1265 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 9636da20748d..b38bda83a7c5 100644
--- a/drivers/usb/media/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * STV0680 USB Camera Driver, by Kevin Sisson (kjsisson@bellsouth.net) 2 * STV0680 USB Camera Driver, by Kevin Sisson (kjsisson@bellsouth.net)
3 * 3 *
4 * Thanks to STMicroelectronics for information on the usb commands, and 4 * Thanks to STMicroelectronics for information on the usb commands, and
5 * to Steve Miller at STM for his help and encouragement while I was 5 * to Steve Miller at STM for his help and encouragement while I was
6 * writing this driver. 6 * writing this driver.
7 * 7 *
8 * This driver is based heavily on the 8 * This driver is based heavily on the
9 * Endpoints (formerly known as AOX) se401 USB Camera Driver 9 * Endpoints (formerly known as AOX) se401 USB Camera Driver
10 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org) 10 * Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org)
11 * 11 *
12 * Still somewhat based on the Linux ov511 driver. 12 * Still somewhat based on the Linux ov511 driver.
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your 16 * Free Software Foundation; either version 2 of the License, or (at your
@@ -25,18 +25,18 @@
25 * along with this program; if not, write to the Free Software Foundation, 25 * along with this program; if not, write to the Free Software Foundation,
26 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * 27 *
28 * History: 28 * History:
29 * ver 0.1 October, 2001. Initial attempt. 29 * ver 0.1 October, 2001. Initial attempt.
30 * 30 *
31 * ver 0.2 November, 2001. Fixed asbility to resize, added brightness 31 * ver 0.2 November, 2001. Fixed asbility to resize, added brightness
32 * function, made more stable (?) 32 * function, made more stable (?)
33 * 33 *
34 * ver 0.21 Nov, 2001. Added gamma correction and white balance, 34 * ver 0.21 Nov, 2001. Added gamma correction and white balance,
35 * due to Alexander Schwartz. Still trying to 35 * due to Alexander Schwartz. Still trying to
36 * improve stablility. Moved stuff into stv680.h 36 * improve stablility. Moved stuff into stv680.h
37 * 37 *
38 * ver 0.22 Nov, 2001. Added sharpen function (by Michael Sweet, 38 * ver 0.22 Nov, 2001. Added sharpen function (by Michael Sweet,
39 * mike@easysw.com) from GIMP, also used in pencam. 39 * mike@easysw.com) from GIMP, also used in pencam.
40 * Simple, fast, good integer math routine. 40 * Simple, fast, good integer math routine.
41 * 41 *
42 * ver 0.23 Dec, 2001 (gkh) 42 * ver 0.23 Dec, 2001 (gkh)
@@ -44,11 +44,11 @@
44 * Lindent, and did other minor tweaks to get 44 * Lindent, and did other minor tweaks to get
45 * things to work properly with 2.5.1 45 * things to work properly with 2.5.1
46 * 46 *
47 * ver 0.24 Jan, 2002 (kjs) 47 * ver 0.24 Jan, 2002 (kjs)
48 * Fixed the problem with webcam crashing after 48 * Fixed the problem with webcam crashing after
49 * two pictures. Changed the way pic is halved to 49 * two pictures. Changed the way pic is halved to
50 * improve quality. Got rid of green line around 50 * improve quality. Got rid of green line around
51 * frame. Fix brightness reset when changing size 51 * frame. Fix brightness reset when changing size
52 * bug. Adjusted gamma filters slightly. 52 * bug. Adjusted gamma filters slightly.
53 * 53 *
54 * ver 0.25 Jan, 2002 (kjs) 54 * ver 0.25 Jan, 2002 (kjs)
@@ -484,7 +484,7 @@ exit:
484 PDEBUG (1, "STV(i): swapRGB is (forced) ON"); 484 PDEBUG (1, "STV(i): swapRGB is (forced) ON");
485 else if (swapRGB_on == -1) 485 else if (swapRGB_on == -1)
486 PDEBUG (1, "STV(i): swapRGB is (forced) OFF"); 486 PDEBUG (1, "STV(i): swapRGB is (forced) OFF");
487 487
488 if (stv_set_video_mode (stv680) < 0) { 488 if (stv_set_video_mode (stv680) < 0) {
489 PDEBUG (0, "STV(e): Could not set video mode in stv_init"); 489 PDEBUG (0, "STV(e): Could not set video mode in stv_init");
490 return -1; 490 return -1;
@@ -570,7 +570,7 @@ static int stv680_set_pict (struct usb_stv *stv680, struct video_picture *p)
570 if (stv680->brightness != p->brightness) { 570 if (stv680->brightness != p->brightness) {
571 stv680->chgbright = 1; 571 stv680->chgbright = 1;
572 stv680->brightness = p->brightness; 572 stv680->brightness = p->brightness;
573 } 573 }
574 574
575 stv680->whiteness = p->whiteness; /* greyscale */ 575 stv680->whiteness = p->whiteness; /* greyscale */
576 stv680->colour = p->colour; 576 stv680->colour = p->colour;
@@ -612,7 +612,7 @@ static void stv680_video_irq (struct urb *urb, struct pt_regs *regs)
612 612
613 case BUFFER_UNUSED: 613 case BUFFER_UNUSED:
614 memcpy (stv680->scratch[stv680->scratch_next].data, 614 memcpy (stv680->scratch[stv680->scratch_next].data,
615 (unsigned char *) urb->transfer_buffer, length); 615 (unsigned char *) urb->transfer_buffer, length);
616 stv680->scratch[stv680->scratch_next].state = BUFFER_READY; 616 stv680->scratch[stv680->scratch_next].state = BUFFER_READY;
617 stv680->scratch[stv680->scratch_next].length = length; 617 stv680->scratch[stv680->scratch_next].length = length;
618 if (waitqueue_active (&stv680->wq)) { 618 if (waitqueue_active (&stv680->wq)) {
@@ -752,7 +752,7 @@ static int stv680_set_size (struct usb_stv *stv680, int width, int height)
752 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); 752 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);
753 return 1; 753 return 1;
754 } 754 }
755 755
756 /* Stop a current stream and start it again at the new size */ 756 /* Stop a current stream and start it again at the new size */
757 if (wasstreaming) 757 if (wasstreaming)
758 stv680_stop_stream (stv680); 758 stv680_stop_stream (stv680);
@@ -773,7 +773,7 @@ static int stv680_set_size (struct usb_stv *stv680, int width, int height)
773 773
774/* 774/*
775 * STV0680 Vision Camera Chipset Driver 775 * STV0680 Vision Camera Chipset Driver
776 * Copyright (C) 2000 Adam Harrison <adam@antispin.org> 776 * Copyright (C) 2000 Adam Harrison <adam@antispin.org>
777*/ 777*/
778 778
779#define RED 0 779#define RED 0
@@ -842,7 +842,7 @@ static void bayer_unshuffle (struct usb_stv *stv680, struct stv680_scratch *buff
842 colour = 2; 842 colour = 2;
843 break; 843 break;
844 } 844 }
845 i = (y * vw + x) * 3; 845 i = (y * vw + x) * 3;
846 *(output + i + colour) = (unsigned char) p; 846 *(output + i + colour) = (unsigned char) p;
847 } /* for x */ 847 } /* for x */
848 848
@@ -850,9 +850,9 @@ static void bayer_unshuffle (struct usb_stv *stv680, struct stv680_scratch *buff
850 850
851 /****** gamma correction plus hardcoded white balance */ 851 /****** gamma correction plus hardcoded white balance */
852 /* Thanks to Alexander Schwartx <alexander.schwartx@gmx.net> for this code. 852 /* Thanks to Alexander Schwartx <alexander.schwartx@gmx.net> for this code.
853 Correction values red[], green[], blue[], are generated by 853 Correction values red[], green[], blue[], are generated by
854 (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1<i<255. 854 (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1<i<255.
855 White balance (RGB)= 1.0, 1.17, 1.48. Values are calculated as double float and 855 White balance (RGB)= 1.0, 1.17, 1.48. Values are calculated as double float and
856 converted to unsigned char. Values are in stv680.h */ 856 converted to unsigned char. Values are in stv680.h */
857 857
858 for (y = 0; y < vh; y++) { 858 for (y = 0; y < vh; y++) {
diff --git a/drivers/usb/media/stv680.h b/drivers/media/video/stv680.h
index ea46e0001e6d..a08f1b08a4b0 100644
--- a/drivers/usb/media/stv680.h
+++ b/drivers/media/video/stv680.h
@@ -9,12 +9,12 @@
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -152,76 +152,76 @@ struct usb_stv {
152 152
153 153
154static const unsigned char red[256] = { 154static const unsigned char red[256] = {
155 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 155 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
156 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42, 156 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,
157 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69, 157 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,
158 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87, 158 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87,
159 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101, 159 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101,
160 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 160 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
161 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124, 161 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124,
162 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134, 162 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134,
163 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143, 163 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143,
164 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151, 164 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151,
165 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159, 165 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159,
166 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166, 166 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166,
167 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173, 167 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173,
168 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179, 168 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179,
169 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186, 169 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186,
170 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192, 170 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192,
171 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197, 171 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197,
172 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204, 172 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204,
173 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209, 173 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209,
174 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215, 174 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215,
175 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219, 175 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219,
176 220, 220, 221, 221 176 220, 220, 221, 221
177}; 177};
178 178
179static const unsigned char green[256] = { 179static const unsigned char green[256] = {
180 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 180 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
181 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47, 181 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,
182 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77, 182 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,
183 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97, 183 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97,
184 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113, 184 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113,
185 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 185 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126,
186 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 186 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
187 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149, 187 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149,
188 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 188 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159,
189 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168, 189 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168,
190 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 190 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177,
191 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185, 191 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185,
192 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 192 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193,
193 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200, 193 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200,
194 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207, 194 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207,
195 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 195 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,
196 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 196 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220,
197 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 197 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
198 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 198 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233,
199 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 199 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
200 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244, 200 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244,
201 245, 245, 246, 246 201 245, 245, 246, 246
202}; 202};
203 203
204static const unsigned char blue[256] = { 204static const unsigned char blue[256] = {
205 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 205 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
206 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51, 206 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,
207 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84, 207 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,
208 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106, 208 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106,
209 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 209 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124,
210 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138, 210 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138,
211 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151, 211 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151,
212 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 212 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163,
213 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 213 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174,
214 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184, 214 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184,
215 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194, 215 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194,
216 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203, 216 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203,
217 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212, 217 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212,
218 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220, 218 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220,
219 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 219 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
220 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235, 220 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235,
221 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242, 221 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242,
222 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249, 222 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249,
223 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255, 223 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255,
224 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 224 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
225 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 225 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
226 255, 255, 255, 255 226 255, 255, 255, 255
227}; 227};
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index fc3d5824efff..78e043ac9ea0 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -48,9 +48,8 @@
48#include <linux/i2c.h> 48#include <linux/i2c.h>
49#include <linux/i2c-algo-bit.h> 49#include <linux/i2c-algo-bit.h>
50 50
51#include "bttv.h"
52#include <media/audiochip.h>
53#include <media/v4l2-common.h> 51#include <media/v4l2-common.h>
52#include <media/i2c-addr.h>
54 53
55#ifndef VIDEO_AUDIO_BALANCE 54#ifndef VIDEO_AUDIO_BALANCE
56# define VIDEO_AUDIO_BALANCE 32 55# define VIDEO_AUDIO_BALANCE 32
@@ -71,7 +70,7 @@ module_param(maxvol, int, S_IRUGO | S_IWUSR);
71 70
72/* Address to scan (I2C address of this chip) */ 71/* Address to scan (I2C address of this chip) */
73static unsigned short normal_i2c[] = { 72static unsigned short normal_i2c[] = {
74 I2C_TDA7432 >> 1, 73 I2C_ADDR_TDA7432 >> 1,
75 I2C_CLIENT_END, 74 I2C_CLIENT_END,
76}; 75};
77I2C_CLIENT_INSMOD; 76I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index 0243700f58ae..ef494febb5e4 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -35,7 +35,7 @@ static int debug = 0; /* insmod parameter */
35module_param(debug, int, 0644); 35module_param(debug, int, 0644);
36MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 36MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
37#define dprintk(args...) \ 37#define dprintk(args...) \
38 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) 38 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
39 39
40#define SWITCH 0x00 40#define SWITCH 0x00
41#define LEVEL_ADJUST 0x02 41#define LEVEL_ADJUST 0x02
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
43#define TEST 0x04 43#define TEST 0x04
44 44
45/* addresses to scan, found only at 0x42 (7-Bit) */ 45/* addresses to scan, found only at 0x42 (7-Bit) */
46static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; 46static unsigned short normal_i2c[] = { I2C_ADDR_TDA9840, I2C_CLIENT_END };
47 47
48/* magic definition of all other variables and things */ 48/* magic definition of all other variables and things */
49I2C_CLIENT_INSMOD; 49I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tda9840.h b/drivers/media/video/tda9840.h
index 28021053bd09..7da8432cdca7 100644
--- a/drivers/media/video/tda9840.h
+++ b/drivers/media/video/tda9840.h
@@ -1,7 +1,7 @@
1#ifndef __INCLUDED_TDA9840__ 1#ifndef __INCLUDED_TDA9840__
2#define __INCLUDED_TDA9840__ 2#define __INCLUDED_TDA9840__
3 3
4#define I2C_TDA9840 0x42 4#define I2C_ADDR_TDA9840 0x42
5 5
6#define TDA9840_DETECT _IOR('v',1,int) 6#define TDA9840_DETECT _IOR('v',1,int)
7/* return values for TDA9840_DETCT */ 7/* return values for TDA9840_DETCT */
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index ef98c4982250..103ccb919292 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -30,24 +30,22 @@
30#include <linux/i2c-algo-bit.h> 30#include <linux/i2c-algo-bit.h>
31#include <linux/init.h> 31#include <linux/init.h>
32 32
33#include "bttv.h" 33
34#include <media/audiochip.h> 34#include <media/i2c-addr.h>
35 35
36static int debug; /* insmod parameter */ 36static int debug; /* insmod parameter */
37module_param(debug, int, S_IRUGO | S_IWUSR); 37module_param(debug, int, S_IRUGO | S_IWUSR);
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
39 39
40
41/* Addresses to scan */ 40/* Addresses to scan */
42static unsigned short normal_i2c[] = { 41static unsigned short normal_i2c[] = {
43 I2C_TDA9875 >> 1, 42 I2C_ADDR_TDA9875 >> 1,
44 I2C_CLIENT_END 43 I2C_CLIENT_END
45}; 44};
46I2C_CLIENT_INSMOD; 45I2C_CLIENT_INSMOD;
47 46
48/* This is a superset of the TDA9875 */ 47/* This is a superset of the TDA9875 */
49struct tda9875 { 48struct tda9875 {
50 int mode;
51 int rvol, lvol; 49 int rvol, lvol;
52 int bass, treble; 50 int bass, treble;
53 struct i2c_client c; 51 struct i2c_client c;
@@ -197,7 +195,6 @@ static void do_tda9875_init(struct i2c_client *client)
197 195
198 tda9875_write(client, TDA9875_MUT, 0xcc ); /* General mute */ 196 tda9875_write(client, TDA9875_MUT, 0xcc ); /* General mute */
199 197
200 t->mode=AUDIO_UNMUTE;
201 t->lvol=t->rvol =0; /* 0dB */ 198 t->lvol=t->rvol =0; /* 0dB */
202 t->bass=0; /* 0dB */ 199 t->bass=0; /* 0dB */
203 t->treble=0; /* 0dB */ 200 t->treble=0; /* 0dB */
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 774ed0dbc56d..523df0b8cc63 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -37,7 +37,7 @@ static int debug = 0; /* insmod parameter */
37module_param(debug, int, 0644); 37module_param(debug, int, 0644);
38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
39#define dprintk(args...) \ 39#define dprintk(args...) \
40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) 40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
41 41
42#define TEA6415C_NUM_INPUTS 8 42#define TEA6415C_NUM_INPUTS 8
43#define TEA6415C_NUM_OUTPUTS 6 43#define TEA6415C_NUM_OUTPUTS 6
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index ad7d2872cfbf..e0ff811fab6f 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -37,10 +37,10 @@ static int debug = 0; /* insmod parameter */
37module_param(debug, int, 0644); 37module_param(debug, int, 0644);
38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 38MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
39#define dprintk(args...) \ 39#define dprintk(args...) \
40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) 40 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
41 41
42/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ 42/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
43static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; 43static unsigned short normal_i2c[] = { I2C_ADDR_TEA6420_1, I2C_ADDR_TEA6420_2, I2C_CLIENT_END };
44 44
45/* magic definition of all other variables and things */ 45/* magic definition of all other variables and things */
46I2C_CLIENT_INSMOD; 46I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tea6420.h b/drivers/media/video/tea6420.h
index ea664df15ad4..5ef7c18e0c54 100644
--- a/drivers/media/video/tea6420.h
+++ b/drivers/media/video/tea6420.h
@@ -2,8 +2,8 @@
2#define __INCLUDED_TEA6420__ 2#define __INCLUDED_TEA6420__
3 3
4/* possible addresses */ 4/* possible addresses */
5#define I2C_TEA6420_1 0x4c 5#define I2C_ADDR_TEA6420_1 0x4c
6#define I2C_TEA6420_2 0x4d 6#define I2C_ADDR_TEA6420_2 0x4d
7 7
8struct tea6420_multiplex 8struct tea6420_multiplex
9{ 9{
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index c4a78e7a5a58..74ab48c09c6a 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * The SAB3036 is just about different enough from the chips that 6 * The SAB3036 is just about different enough from the chips that
7 * tuner.c copes with to make it not worth the effort to crowbar 7 * tuner.c copes with to make it not worth the effort to crowbar
8 * the support into that file. So instead we have a separate driver. 8 * the support into that file. So instead we have a separate driver.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
@@ -56,15 +56,15 @@ tuner_getstatus (struct i2c_client *c)
56 56
57#define TUNER_FL 0x80 57#define TUNER_FL 0x80
58 58
59static int 59static int
60tuner_islocked (struct i2c_client *c) 60tuner_islocked (struct i2c_client *c)
61{ 61{
62 return (tuner_getstatus(c) & TUNER_FL); 62 return (tuner_getstatus(c) & TUNER_FL);
63} 63}
64 64
65/* ---------------------------------------------------------------------- */ 65/* ---------------------------------------------------------------------- */
66 66
67static void 67static void
68set_tv_freq(struct i2c_client *c, int freq) 68set_tv_freq(struct i2c_client *c, int freq)
69{ 69{
70 u16 div = ((freq * 20) / 16); 70 u16 div = ((freq * 20) / 16);
@@ -73,26 +73,26 @@ set_tv_freq(struct i2c_client *c, int freq)
73 73
74 if (debug) 74 if (debug)
75 printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div); 75 printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div);
76 76
77 /* Select high tuning current */ 77 /* Select high tuning current */
78 buffer[0] = 0x29; 78 buffer[0] = 0x29;
79 buffer[1] = 0x3e; 79 buffer[1] = 0x3e;
80 80
81 if (i2c_master_send(c, buffer, 2) != 2) 81 if (i2c_master_send(c, buffer, 2) != 2)
82 printk("tuner: i2c i/o error 1\n"); 82 printk("tuner: i2c i/o error 1\n");
83 83
84 buffer[0] = 0x80 | ((div>>8) & 0x7f); 84 buffer[0] = 0x80 | ((div>>8) & 0x7f);
85 buffer[1] = div & 0xff; 85 buffer[1] = div & 0xff;
86 86
87 if (i2c_master_send(c, buffer, 2) != 2) 87 if (i2c_master_send(c, buffer, 2) != 2)
88 printk("tuner: i2c i/o error 2\n"); 88 printk("tuner: i2c i/o error 2\n");
89 89
90 while (!tuner_islocked(c) && time_before(jiffies, give_up)) 90 while (!tuner_islocked(c) && time_before(jiffies, give_up))
91 schedule(); 91 schedule();
92 92
93 if (!tuner_islocked(c)) 93 if (!tuner_islocked(c))
94 printk(KERN_WARNING "tuner: failed to achieve PLL lock\n"); 94 printk(KERN_WARNING "tuner: failed to achieve PLL lock\n");
95 95
96 /* Select low tuning current and engage AFC */ 96 /* Select low tuning current and engage AFC */
97 buffer[0] = 0x29; 97 buffer[0] = 0x29;
98 buffer[1] = 0xb2; 98 buffer[1] = 0xb2;
@@ -106,7 +106,7 @@ set_tv_freq(struct i2c_client *c, int freq)
106 106
107/* ---------------------------------------------------------------------- */ 107/* ---------------------------------------------------------------------- */
108 108
109static int 109static int
110tuner_attach(struct i2c_adapter *adap, int addr, int kind) 110tuner_attach(struct i2c_adapter *adap, int addr, int kind)
111{ 111{
112 static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 }; 112 static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 };
@@ -116,18 +116,18 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
116 if (this_adap > 0) 116 if (this_adap > 0)
117 return -1; 117 return -1;
118 this_adap++; 118 this_adap++;
119 119
120 client_template.adapter = adap; 120 client_template.adapter = adap;
121 client_template.addr = addr; 121 client_template.addr = addr;
122 122
123 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 123 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
124 if (client == NULL) 124 if (client == NULL)
125 return -ENOMEM; 125 return -ENOMEM;
126 memcpy(client, &client_template, sizeof(struct i2c_client)); 126 memcpy(client, &client_template, sizeof(struct i2c_client));
127 127
128 printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client)); 128 printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client));
129 129
130 i2c_attach_client(client); 130 i2c_attach_client(client);
131 131
132 if (i2c_master_send(client, buffer, 2) != 2) 132 if (i2c_master_send(client, buffer, 2) != 2)
133 printk("tuner: i2c i/o error 1\n"); 133 printk("tuner: i2c i/o error 1\n");
@@ -138,30 +138,30 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
138 return 0; 138 return 0;
139} 139}
140 140
141static int 141static int
142tuner_detach(struct i2c_client *c) 142tuner_detach(struct i2c_client *c)
143{ 143{
144 return 0; 144 return 0;
145} 145}
146 146
147static int 147static int
148tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) 148tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
149{ 149{
150 int *iarg = (int*)arg; 150 int *iarg = (int*)arg;
151 151
152 switch (cmd) 152 switch (cmd)
153 { 153 {
154 case VIDIOCSFREQ: 154 case VIDIOCSFREQ:
155 set_tv_freq(client, *iarg); 155 set_tv_freq(client, *iarg);
156 break; 156 break;
157 157
158 default: 158 default:
159 return -EINVAL; 159 return -EINVAL;
160 } 160 }
161 return 0; 161 return 0;
162} 162}
163 163
164static int 164static int
165tuner_probe(struct i2c_adapter *adap) 165tuner_probe(struct i2c_adapter *adap)
166{ 166{
167 this_adap = 0; 167 this_adap = 0;
@@ -172,8 +172,8 @@ tuner_probe(struct i2c_adapter *adap)
172 172
173/* ----------------------------------------------------------------------- */ 173/* ----------------------------------------------------------------------- */
174 174
175static struct i2c_driver 175static struct i2c_driver
176i2c_driver_tuner = 176i2c_driver_tuner =
177{ 177{
178 .driver = { 178 .driver = {
179 .name = "sab3036", 179 .name = "sab3036",
@@ -186,7 +186,7 @@ i2c_driver_tuner =
186 186
187static struct i2c_client client_template = 187static struct i2c_client client_template =
188{ 188{
189 .driver = &i2c_driver_tuner, 189 .driver = &i2c_driver_tuner,
190 .name = "SAB3036", 190 .name = "SAB3036",
191}; 191};
192 192
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 32e1849441fb..df195c905366 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -21,7 +21,6 @@
21 21
22#include <media/tuner.h> 22#include <media/tuner.h>
23#include <media/v4l2-common.h> 23#include <media/v4l2-common.h>
24#include <media/audiochip.h>
25 24
26#define UNSET (-1U) 25#define UNSET (-1U)
27 26
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 4efb01bb44ac..356bff455ad1 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -30,10 +30,10 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32 32
33#include <media/audiochip.h> 33#include <media/tvaudio.h>
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35 35
36#include "tvaudio.h" 36#include <media/i2c-addr.h>
37 37
38/* ---------------------------------------------------------------------- */ 38/* ---------------------------------------------------------------------- */
39/* insmod args */ 39/* insmod args */
@@ -102,7 +102,7 @@ struct CHIPDESC {
102 102
103 /* input switch register + values for v4l inputs */ 103 /* input switch register + values for v4l inputs */
104 int inputreg; 104 int inputreg;
105 int inputmap[8]; 105 int inputmap[4];
106 int inputmute; 106 int inputmute;
107 int inputmask; 107 int inputmask;
108}; 108};
@@ -119,9 +119,10 @@ struct CHIPSTATE {
119 audiocmd shadow; 119 audiocmd shadow;
120 120
121 /* current settings */ 121 /* current settings */
122 __u16 left,right,treble,bass,mode; 122 __u16 left,right,treble,bass,muted,mode;
123 int prevmode; 123 int prevmode;
124 int radio; 124 int radio;
125 int input;
125 126
126 /* thread */ 127 /* thread */
127 pid_t tpid; 128 pid_t tpid;
@@ -137,14 +138,14 @@ struct CHIPSTATE {
137/* i2c addresses */ 138/* i2c addresses */
138 139
139static unsigned short normal_i2c[] = { 140static unsigned short normal_i2c[] = {
140 I2C_TDA8425 >> 1, 141 I2C_ADDR_TDA8425 >> 1,
141 I2C_TEA6300 >> 1, 142 I2C_ADDR_TEA6300 >> 1,
142 I2C_TEA6420 >> 1, 143 I2C_ADDR_TEA6420 >> 1,
143 I2C_TDA9840 >> 1, 144 I2C_ADDR_TDA9840 >> 1,
144 I2C_TDA985x_L >> 1, 145 I2C_ADDR_TDA985x_L >> 1,
145 I2C_TDA985x_H >> 1, 146 I2C_ADDR_TDA985x_H >> 1,
146 I2C_TDA9874 >> 1, 147 I2C_ADDR_TDA9874 >> 1,
147 I2C_PIC16C54 >> 1, 148 I2C_ADDR_PIC16C54 >> 1,
148 I2C_CLIENT_END }; 149 I2C_CLIENT_END };
149I2C_CLIENT_INSMOD; 150I2C_CLIENT_INSMOD;
150 151
@@ -1101,9 +1102,8 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; }
1101static int tda8425_initialize(struct CHIPSTATE *chip) 1102static int tda8425_initialize(struct CHIPSTATE *chip)
1102{ 1103{
1103 struct CHIPDESC *desc = chiplist + chip->type; 1104 struct CHIPDESC *desc = chiplist + chip->type;
1104 int inputmap[8] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, 1105 int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
1105 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF, 1106 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF};
1106 /* off */ TDA8425_S1_OFF, /* on */ TDA8425_S1_CH2};
1107 1107
1108 if (chip->c.adapter->id == I2C_HW_B_RIVA) { 1108 if (chip->c.adapter->id == I2C_HW_B_RIVA) {
1109 memcpy (desc->inputmap, inputmap, sizeof (inputmap)); 1109 memcpy (desc->inputmap, inputmap, sizeof (inputmap));
@@ -1269,8 +1269,8 @@ static struct CHIPDESC chiplist[] = {
1269 .name = "tda9840", 1269 .name = "tda9840",
1270 .id = I2C_DRIVERID_TDA9840, 1270 .id = I2C_DRIVERID_TDA9840,
1271 .insmodopt = &tda9840, 1271 .insmodopt = &tda9840,
1272 .addr_lo = I2C_TDA9840 >> 1, 1272 .addr_lo = I2C_ADDR_TDA9840 >> 1,
1273 .addr_hi = I2C_TDA9840 >> 1, 1273 .addr_hi = I2C_ADDR_TDA9840 >> 1,
1274 .registers = 5, 1274 .registers = 5,
1275 1275
1276 .checkit = tda9840_checkit, 1276 .checkit = tda9840_checkit,
@@ -1286,8 +1286,8 @@ static struct CHIPDESC chiplist[] = {
1286 .id = I2C_DRIVERID_TDA9873, 1286 .id = I2C_DRIVERID_TDA9873,
1287 .checkit = tda9873_checkit, 1287 .checkit = tda9873_checkit,
1288 .insmodopt = &tda9873, 1288 .insmodopt = &tda9873,
1289 .addr_lo = I2C_TDA985x_L >> 1, 1289 .addr_lo = I2C_ADDR_TDA985x_L >> 1,
1290 .addr_hi = I2C_TDA985x_H >> 1, 1290 .addr_hi = I2C_ADDR_TDA985x_H >> 1,
1291 .registers = 3, 1291 .registers = 3,
1292 .flags = CHIP_HAS_INPUTSEL, 1292 .flags = CHIP_HAS_INPUTSEL,
1293 1293
@@ -1298,7 +1298,7 @@ static struct CHIPDESC chiplist[] = {
1298 .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, 1298 .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } },
1299 .inputreg = TDA9873_SW, 1299 .inputreg = TDA9873_SW,
1300 .inputmute = TDA9873_MUTE | TDA9873_AUTOMUTE, 1300 .inputmute = TDA9873_MUTE | TDA9873_AUTOMUTE,
1301 .inputmap = {0xa0, 0xa2, 0xa0, 0xa0, 0xc0}, 1301 .inputmap = {0xa0, 0xa2, 0xa0, 0xa0},
1302 .inputmask = TDA9873_INP_MASK|TDA9873_MUTE|TDA9873_AUTOMUTE, 1302 .inputmask = TDA9873_INP_MASK|TDA9873_MUTE|TDA9873_AUTOMUTE,
1303 1303
1304 }, 1304 },
@@ -1308,8 +1308,8 @@ static struct CHIPDESC chiplist[] = {
1308 .checkit = tda9874a_checkit, 1308 .checkit = tda9874a_checkit,
1309 .initialize = tda9874a_initialize, 1309 .initialize = tda9874a_initialize,
1310 .insmodopt = &tda9874a, 1310 .insmodopt = &tda9874a,
1311 .addr_lo = I2C_TDA9874 >> 1, 1311 .addr_lo = I2C_ADDR_TDA9874 >> 1,
1312 .addr_hi = I2C_TDA9874 >> 1, 1312 .addr_hi = I2C_ADDR_TDA9874 >> 1,
1313 1313
1314 .getmode = tda9874a_getmode, 1314 .getmode = tda9874a_getmode,
1315 .setmode = tda9874a_setmode, 1315 .setmode = tda9874a_setmode,
@@ -1319,8 +1319,8 @@ static struct CHIPDESC chiplist[] = {
1319 .name = "tda9850", 1319 .name = "tda9850",
1320 .id = I2C_DRIVERID_TDA9850, 1320 .id = I2C_DRIVERID_TDA9850,
1321 .insmodopt = &tda9850, 1321 .insmodopt = &tda9850,
1322 .addr_lo = I2C_TDA985x_L >> 1, 1322 .addr_lo = I2C_ADDR_TDA985x_L >> 1,
1323 .addr_hi = I2C_TDA985x_H >> 1, 1323 .addr_hi = I2C_ADDR_TDA985x_H >> 1,
1324 .registers = 11, 1324 .registers = 11,
1325 1325
1326 .getmode = tda985x_getmode, 1326 .getmode = tda985x_getmode,
@@ -1332,8 +1332,8 @@ static struct CHIPDESC chiplist[] = {
1332 .name = "tda9855", 1332 .name = "tda9855",
1333 .id = I2C_DRIVERID_TDA9855, 1333 .id = I2C_DRIVERID_TDA9855,
1334 .insmodopt = &tda9855, 1334 .insmodopt = &tda9855,
1335 .addr_lo = I2C_TDA985x_L >> 1, 1335 .addr_lo = I2C_ADDR_TDA985x_L >> 1,
1336 .addr_hi = I2C_TDA985x_H >> 1, 1336 .addr_hi = I2C_ADDR_TDA985x_H >> 1,
1337 .registers = 11, 1337 .registers = 11,
1338 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE, 1338 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE,
1339 1339
@@ -1357,8 +1357,8 @@ static struct CHIPDESC chiplist[] = {
1357 .name = "tea6300", 1357 .name = "tea6300",
1358 .id = I2C_DRIVERID_TEA6300, 1358 .id = I2C_DRIVERID_TEA6300,
1359 .insmodopt = &tea6300, 1359 .insmodopt = &tea6300,
1360 .addr_lo = I2C_TEA6300 >> 1, 1360 .addr_lo = I2C_ADDR_TEA6300 >> 1,
1361 .addr_hi = I2C_TEA6300 >> 1, 1361 .addr_hi = I2C_ADDR_TEA6300 >> 1,
1362 .registers = 6, 1362 .registers = 6,
1363 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL, 1363 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL,
1364 1364
@@ -1379,8 +1379,8 @@ static struct CHIPDESC chiplist[] = {
1379 .id = I2C_DRIVERID_TEA6300, 1379 .id = I2C_DRIVERID_TEA6300,
1380 .initialize = tea6320_initialize, 1380 .initialize = tea6320_initialize,
1381 .insmodopt = &tea6320, 1381 .insmodopt = &tea6320,
1382 .addr_lo = I2C_TEA6300 >> 1, 1382 .addr_lo = I2C_ADDR_TEA6300 >> 1,
1383 .addr_hi = I2C_TEA6300 >> 1, 1383 .addr_hi = I2C_ADDR_TEA6300 >> 1,
1384 .registers = 8, 1384 .registers = 8,
1385 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL, 1385 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL,
1386 1386
@@ -1400,8 +1400,8 @@ static struct CHIPDESC chiplist[] = {
1400 .name = "tea6420", 1400 .name = "tea6420",
1401 .id = I2C_DRIVERID_TEA6420, 1401 .id = I2C_DRIVERID_TEA6420,
1402 .insmodopt = &tea6420, 1402 .insmodopt = &tea6420,
1403 .addr_lo = I2C_TEA6420 >> 1, 1403 .addr_lo = I2C_ADDR_TEA6420 >> 1,
1404 .addr_hi = I2C_TEA6420 >> 1, 1404 .addr_hi = I2C_ADDR_TEA6420 >> 1,
1405 .registers = 1, 1405 .registers = 1,
1406 .flags = CHIP_HAS_INPUTSEL, 1406 .flags = CHIP_HAS_INPUTSEL,
1407 1407
@@ -1413,8 +1413,8 @@ static struct CHIPDESC chiplist[] = {
1413 .name = "tda8425", 1413 .name = "tda8425",
1414 .id = I2C_DRIVERID_TDA8425, 1414 .id = I2C_DRIVERID_TDA8425,
1415 .insmodopt = &tda8425, 1415 .insmodopt = &tda8425,
1416 .addr_lo = I2C_TDA8425 >> 1, 1416 .addr_lo = I2C_ADDR_TDA8425 >> 1,
1417 .addr_hi = I2C_TDA8425 >> 1, 1417 .addr_hi = I2C_ADDR_TDA8425 >> 1,
1418 .registers = 9, 1418 .registers = 9,
1419 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL, 1419 .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL,
1420 1420
@@ -1437,8 +1437,8 @@ static struct CHIPDESC chiplist[] = {
1437 .name = "pic16c54 (PV951)", 1437 .name = "pic16c54 (PV951)",
1438 .id = I2C_DRIVERID_PIC16C54_PV9, 1438 .id = I2C_DRIVERID_PIC16C54_PV9,
1439 .insmodopt = &pic16c54, 1439 .insmodopt = &pic16c54,
1440 .addr_lo = I2C_PIC16C54 >> 1, 1440 .addr_lo = I2C_ADDR_PIC16C54 >> 1,
1441 .addr_hi = I2C_PIC16C54>> 1, 1441 .addr_hi = I2C_ADDR_PIC16C54>> 1,
1442 .registers = 2, 1442 .registers = 2,
1443 .flags = CHIP_HAS_INPUTSEL, 1443 .flags = CHIP_HAS_INPUTSEL,
1444 1444
@@ -1446,8 +1446,7 @@ static struct CHIPDESC chiplist[] = {
1446 .inputmap = {PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_TUNER, 1446 .inputmap = {PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_TUNER,
1447 PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE, 1447 PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE,
1448 PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE, 1448 PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE,
1449 PIC16C54_MISC_SND_MUTE,PIC16C54_MISC_SND_MUTE, 1449 PIC16C54_MISC_SND_MUTE},
1450 PIC16C54_MISC_SND_NOTMUTE},
1451 .inputmute = PIC16C54_MISC_SND_MUTE, 1450 .inputmute = PIC16C54_MISC_SND_MUTE,
1452 }, 1451 },
1453 { 1452 {
@@ -1456,8 +1455,8 @@ static struct CHIPDESC chiplist[] = {
1456 /*.id = I2C_DRIVERID_TA8874Z, */ 1455 /*.id = I2C_DRIVERID_TA8874Z, */
1457 .checkit = ta8874z_checkit, 1456 .checkit = ta8874z_checkit,
1458 .insmodopt = &ta8874z, 1457 .insmodopt = &ta8874z,
1459 .addr_lo = I2C_TDA9840 >> 1, 1458 .addr_lo = I2C_ADDR_TDA9840 >> 1,
1460 .addr_hi = I2C_TDA9840 >> 1, 1459 .addr_hi = I2C_ADDR_TDA9840 >> 1,
1461 .registers = 2, 1460 .registers = 2,
1462 1461
1463 .getmode = ta8874z_getmode, 1462 .getmode = ta8874z_getmode,
@@ -1583,28 +1582,40 @@ static int chip_detach(struct i2c_client *client)
1583 return 0; 1582 return 0;
1584} 1583}
1585 1584
1585static int tvaudio_set_ctrl(struct CHIPSTATE *chip, struct v4l2_control *ctrl)
1586{
1587 struct CHIPDESC *desc = chiplist + chip->type;
1588
1589 switch (ctrl->id) {
1590 case V4L2_CID_AUDIO_MUTE:
1591 if (ctrl->value < 0 || ctrl->value >= 2)
1592 return -ERANGE;
1593 chip->muted = ctrl->value;
1594 if (chip->muted)
1595 chip_write_masked(chip,desc->inputreg,desc->inputmute,desc->inputmask);
1596 else
1597 chip_write_masked(chip,desc->inputreg,
1598 desc->inputmap[chip->input],desc->inputmask);
1599 break;
1600 default:
1601 return -EINVAL;
1602 }
1603 return 0;
1604}
1605
1606
1586/* ---------------------------------------------------------------------- */ 1607/* ---------------------------------------------------------------------- */
1587/* video4linux interface */ 1608/* video4linux interface */
1588 1609
1589static int chip_command(struct i2c_client *client, 1610static int chip_command(struct i2c_client *client,
1590 unsigned int cmd, void *arg) 1611 unsigned int cmd, void *arg)
1591{ 1612{
1592 __u16 *sarg = arg;
1593 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1613 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1594 struct CHIPDESC *desc = chiplist + chip->type; 1614 struct CHIPDESC *desc = chiplist + chip->type;
1595 1615
1596 v4l_dbg(1, debug, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd); 1616 v4l_dbg(1, debug, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd);
1597 1617
1598 switch (cmd) { 1618 switch (cmd) {
1599 case AUDC_SET_INPUT:
1600 if (desc->flags & CHIP_HAS_INPUTSEL) {
1601 if (*sarg & 0x80)
1602 chip_write_masked(chip,desc->inputreg,desc->inputmute,desc->inputmask);
1603 else
1604 chip_write_masked(chip,desc->inputreg,desc->inputmap[*sarg],desc->inputmask);
1605 }
1606 break;
1607
1608 case AUDC_SET_RADIO: 1619 case AUDC_SET_RADIO:
1609 chip->radio = 1; 1620 chip->radio = 1;
1610 chip->watch_stereo = 0; 1621 chip->watch_stereo = 0;
@@ -1668,6 +1679,48 @@ static int chip_command(struct i2c_client *client,
1668 break; 1679 break;
1669 } 1680 }
1670 1681
1682 case VIDIOC_S_CTRL:
1683 return tvaudio_set_ctrl(chip, arg);
1684
1685 case VIDIOC_INT_G_AUDIO_ROUTING:
1686 {
1687 struct v4l2_routing *rt = arg;
1688
1689 rt->input = chip->input;
1690 rt->output = 0;
1691 break;
1692 }
1693
1694 case VIDIOC_INT_S_AUDIO_ROUTING:
1695 {
1696 struct v4l2_routing *rt = arg;
1697
1698 if (!(desc->flags & CHIP_HAS_INPUTSEL) || rt->input >= 4)
1699 return -EINVAL;
1700 /* There are four inputs: tuner, radio, extern and intern. */
1701 chip->input = rt->input;
1702 if (chip->muted)
1703 break;
1704 chip_write_masked(chip, desc->inputreg,
1705 desc->inputmap[chip->input], desc->inputmask);
1706 break;
1707 }
1708
1709 case VIDIOC_S_AUDIO:
1710 {
1711 struct v4l2_audio *sarg = arg;
1712
1713 if (!(desc->flags & CHIP_HAS_INPUTSEL) || sarg->index >= 4)
1714 return -EINVAL;
1715 /* There are four inputs: tuner, radio, extern and intern. */
1716 chip->input = sarg->index;
1717 if (chip->muted)
1718 break;
1719 chip_write_masked(chip, desc->inputreg,
1720 desc->inputmap[chip->input], desc->inputmask);
1721 break;
1722 }
1723
1671 case VIDIOC_S_TUNER: 1724 case VIDIOC_S_TUNER:
1672 { 1725 {
1673 struct v4l2_tuner *vt = arg; 1726 struct v4l2_tuner *vt = arg;
@@ -1680,6 +1733,7 @@ static int chip_command(struct i2c_client *client,
1680 mode = VIDEO_SOUND_MONO; 1733 mode = VIDEO_SOUND_MONO;
1681 break; 1734 break;
1682 case V4L2_TUNER_MODE_STEREO: 1735 case V4L2_TUNER_MODE_STEREO:
1736 case V4L2_TUNER_MODE_LANG1_LANG2:
1683 mode = VIDEO_SOUND_STEREO; 1737 mode = VIDEO_SOUND_STEREO;
1684 break; 1738 break;
1685 case V4L2_TUNER_MODE_LANG1: 1739 case V4L2_TUNER_MODE_LANG1:
diff --git a/drivers/media/video/tvaudio.h b/drivers/media/video/tvaudio.h
deleted file mode 100644
index af7e116af9a9..000000000000
--- a/drivers/media/video/tvaudio.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 * i2c bus addresses for the chips supported by tvaudio.c
3 */
4
5#define I2C_TDA8425 0x82
6#define I2C_TDA9840 0x84 /* also used by TA8874Z */
7#define I2C_TDA985x_L 0xb4 /* also used by 9873 */
8#define I2C_TDA985x_H 0xb6
9#define I2C_TDA9874 0xb0 /* also used by 9875 */
10
11#define I2C_TEA6300 0x80 /* also used by 6320 */
12#define I2C_TEA6420 0x98
13
14#define I2C_PIC16C54 0x96 /* PV951 */
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 582551b0969b..e0d2ff83fc91 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -248,32 +248,32 @@ audioIC[] =
248 {AUDIO_CHIP_MSP34XX, "MSP3410D"}, 248 {AUDIO_CHIP_MSP34XX, "MSP3410D"},
249 {AUDIO_CHIP_MSP34XX, "MSP3415"}, 249 {AUDIO_CHIP_MSP34XX, "MSP3415"},
250 {AUDIO_CHIP_MSP34XX, "MSP3430"}, 250 {AUDIO_CHIP_MSP34XX, "MSP3430"},
251 {AUDIO_CHIP_UNKNOWN, "MSP3438"}, 251 {AUDIO_CHIP_MSP34XX, "MSP3438"},
252 {AUDIO_CHIP_UNKNOWN, "CS5331"}, 252 {AUDIO_CHIP_UNKNOWN, "CS5331"},
253 /* 10-14 */ 253 /* 10-14 */
254 {AUDIO_CHIP_MSP34XX, "MSP3435"}, 254 {AUDIO_CHIP_MSP34XX, "MSP3435"},
255 {AUDIO_CHIP_MSP34XX, "MSP3440"}, 255 {AUDIO_CHIP_MSP34XX, "MSP3440"},
256 {AUDIO_CHIP_MSP34XX, "MSP3445"}, 256 {AUDIO_CHIP_MSP34XX, "MSP3445"},
257 {AUDIO_CHIP_UNKNOWN, "MSP3411"}, 257 {AUDIO_CHIP_MSP34XX, "MSP3411"},
258 {AUDIO_CHIP_UNKNOWN, "MSP3416"}, 258 {AUDIO_CHIP_MSP34XX, "MSP3416"},
259 /* 15-19 */ 259 /* 15-19 */
260 {AUDIO_CHIP_MSP34XX, "MSP3425"}, 260 {AUDIO_CHIP_MSP34XX, "MSP3425"},
261 {AUDIO_CHIP_UNKNOWN, "MSP3451"}, 261 {AUDIO_CHIP_MSP34XX, "MSP3451"},
262 {AUDIO_CHIP_UNKNOWN, "MSP3418"}, 262 {AUDIO_CHIP_MSP34XX, "MSP3418"},
263 {AUDIO_CHIP_UNKNOWN, "Type 0x12"}, 263 {AUDIO_CHIP_UNKNOWN, "Type 0x12"},
264 {AUDIO_CHIP_UNKNOWN, "OKI7716"}, 264 {AUDIO_CHIP_UNKNOWN, "OKI7716"},
265 /* 20-24 */ 265 /* 20-24 */
266 {AUDIO_CHIP_UNKNOWN, "MSP4410"}, 266 {AUDIO_CHIP_MSP34XX, "MSP4410"},
267 {AUDIO_CHIP_UNKNOWN, "MSP4420"}, 267 {AUDIO_CHIP_MSP34XX, "MSP4420"},
268 {AUDIO_CHIP_UNKNOWN, "MSP4440"}, 268 {AUDIO_CHIP_MSP34XX, "MSP4440"},
269 {AUDIO_CHIP_UNKNOWN, "MSP4450"}, 269 {AUDIO_CHIP_MSP34XX, "MSP4450"},
270 {AUDIO_CHIP_UNKNOWN, "MSP4408"}, 270 {AUDIO_CHIP_MSP34XX, "MSP4408"},
271 /* 25-29 */ 271 /* 25-29 */
272 {AUDIO_CHIP_UNKNOWN, "MSP4418"}, 272 {AUDIO_CHIP_MSP34XX, "MSP4418"},
273 {AUDIO_CHIP_UNKNOWN, "MSP4428"}, 273 {AUDIO_CHIP_MSP34XX, "MSP4428"},
274 {AUDIO_CHIP_UNKNOWN, "MSP4448"}, 274 {AUDIO_CHIP_MSP34XX, "MSP4448"},
275 {AUDIO_CHIP_UNKNOWN, "MSP4458"}, 275 {AUDIO_CHIP_MSP34XX, "MSP4458"},
276 {AUDIO_CHIP_UNKNOWN, "Type 0x1d"}, 276 {AUDIO_CHIP_MSP34XX, "Type 0x1d"},
277 /* 30-34 */ 277 /* 30-34 */
278 {AUDIO_CHIP_INTERNAL, "CX880"}, 278 {AUDIO_CHIP_INTERNAL, "CX880"},
279 {AUDIO_CHIP_INTERNAL, "CX881"}, 279 {AUDIO_CHIP_INTERNAL, "CX881"},
diff --git a/drivers/media/video/usbvideo/Makefile b/drivers/media/video/usbvideo/Makefile
new file mode 100644
index 000000000000..ed410a5ee8c9
--- /dev/null
+++ b/drivers/media/video/usbvideo/Makefile
@@ -0,0 +1,4 @@
1obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o
2obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o
3obj-$(CONFIG_USB_VICAM) += vicam.o usbvideo.o
4
diff --git a/drivers/usb/media/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c
index a42c22294124..76f771b6a32f 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
1300/* 1300/*
1301 * ibmcam_model3_Packet1() 1301 * ibmcam_model3_Packet1()
1302 * 1302 *
1303 * 00_0078_012d 1303 * 00_0078_012d
1304 * 00_0097_012f 1304 * 00_0097_012f
1305 * 00_d141_0124 1305 * 00_d141_0124
1306 * 00_0096_0127 1306 * 00_0096_0127
1307 * 00_fea8_0124 1307 * 00_fea8_0124
1308*/ 1308*/
1309static void ibmcam_model3_Packet1(struct uvd *uvd, unsigned short v1, unsigned short v2) 1309static void ibmcam_model3_Packet1(struct uvd *uvd, unsigned short v1, unsigned short v2)
1310{ 1310{
@@ -2687,7 +2687,7 @@ static void ibmcam_model4_setup_after_video_if(struct uvd *uvd)
2687 ibmcam_veio(uvd, 0, 0x0004, 0x0127); 2687 ibmcam_veio(uvd, 0, 0x0004, 0x0127);
2688 ibmcam_veio(uvd, 0, 0xfea8, 0x0124); 2688 ibmcam_veio(uvd, 0, 0xfea8, 0x0124);
2689 ibmcam_veio(uvd, 0, 0x00c0, 0x010c); 2689 ibmcam_veio(uvd, 0, 0x00c0, 0x010c);
2690 break; 2690 break;
2691 } 2691 }
2692 usb_clear_halt(uvd->dev, usb_rcvisocpipe(uvd->dev, uvd->video_endp)); 2692 usb_clear_halt(uvd->dev, usb_rcvisocpipe(uvd->dev, uvd->video_endp));
2693} 2693}
@@ -3238,7 +3238,7 @@ static void ibmcam_model3_setup_after_video_if(struct uvd *uvd)
3238 {0, 0x0062, 0x0107}, 3238 {0, 0x0062, 0x0107},
3239 {0, 0x0003, 0x0111}, 3239 {0, 0x0003, 0x0111},
3240 }; 3240 };
3241#define NUM_INIT_DATA 3241#define NUM_INIT_DATA
3242 3242
3243 unsigned short compression = 0; /* 0=none, 7=best frame rate */ 3243 unsigned short compression = 0; /* 0=none, 7=best frame rate */
3244 int f_rate; /* 0=Fastest 7=slowest */ 3244 int f_rate; /* 0=Fastest 7=slowest */
diff --git a/drivers/usb/media/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
index e2ede583518f..c11f5d46b114 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/media/video/usbvideo/konicawc.c
@@ -36,7 +36,7 @@
36enum ctrl_req { 36enum ctrl_req {
37 SetWhitebal = 0x01, 37 SetWhitebal = 0x01,
38 SetBrightness = 0x02, 38 SetBrightness = 0x02,
39 SetSharpness = 0x03, 39 SetSharpness = 0x03,
40 SetContrast = 0x04, 40 SetContrast = 0x04,
41 SetSaturation = 0x05, 41 SetSaturation = 0x05,
42}; 42};
@@ -47,7 +47,7 @@ enum frame_sizes {
47 SIZE_160X136 = 1, 47 SIZE_160X136 = 1,
48 SIZE_176X144 = 2, 48 SIZE_176X144 = 2,
49 SIZE_320X240 = 3, 49 SIZE_320X240 = 3,
50 50
51}; 51};
52 52
53#define MAX_FRAME_SIZE SIZE_320X240 53#define MAX_FRAME_SIZE SIZE_320X240
@@ -69,7 +69,7 @@ static const int debug = 0;
69/* Some default values for initial camera settings, 69/* Some default values for initial camera settings,
70 can be set by modprobe */ 70 can be set by modprobe */
71 71
72static int size; 72static int size;
73static int speed = 6; /* Speed (fps) 0 (slowest) to 6 (fastest) */ 73static int speed = 6; /* Speed (fps) 0 (slowest) to 6 (fastest) */
74static int brightness = MAX_BRIGHTNESS/2; 74static int brightness = MAX_BRIGHTNESS/2;
75static int contrast = MAX_CONTRAST/2; 75static int contrast = MAX_CONTRAST/2;
@@ -132,24 +132,24 @@ struct konicawc {
132 132
133static int konicawc_ctrl_msg(struct uvd *uvd, u8 dir, u8 request, u16 value, u16 index, void *buf, int len) 133static int konicawc_ctrl_msg(struct uvd *uvd, u8 dir, u8 request, u16 value, u16 index, void *buf, int len)
134{ 134{
135 int retval = usb_control_msg(uvd->dev, 135 int retval = usb_control_msg(uvd->dev,
136 dir ? usb_rcvctrlpipe(uvd->dev, 0) : usb_sndctrlpipe(uvd->dev, 0), 136 dir ? usb_rcvctrlpipe(uvd->dev, 0) : usb_sndctrlpipe(uvd->dev, 0),
137 request, 0x40 | dir, value, index, buf, len, 1000); 137 request, 0x40 | dir, value, index, buf, len, 1000);
138 return retval < 0 ? retval : 0; 138 return retval < 0 ? retval : 0;
139} 139}
140 140
141 141
142static inline void konicawc_camera_on(struct uvd *uvd) 142static inline void konicawc_camera_on(struct uvd *uvd)
143{ 143{
144 DEBUG(0, "camera on"); 144 DEBUG(0, "camera on");
145 konicawc_set_misc(uvd, 0x2, 1, 0x0b); 145 konicawc_set_misc(uvd, 0x2, 1, 0x0b);
146} 146}
147 147
148 148
149static inline void konicawc_camera_off(struct uvd *uvd) 149static inline void konicawc_camera_off(struct uvd *uvd)
150{ 150{
151 DEBUG(0, "camera off"); 151 DEBUG(0, "camera off");
152 konicawc_set_misc(uvd, 0x2, 0, 0x0b); 152 konicawc_set_misc(uvd, 0x2, 0, 0x0b);
153} 153}
154 154
155 155
@@ -317,7 +317,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
317 button = !!(sts & 0x40); 317 button = !!(sts & 0x40);
318 sts &= ~0x40; 318 sts &= ~0x40;
319 } 319 }
320 320
321 /* work out the button status, but don't do 321 /* work out the button status, but don't do
322 anything with it for now */ 322 anything with it for now */
323 323
@@ -331,7 +331,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
331 discard++; 331 discard++;
332 continue; 332 continue;
333 } 333 }
334 334
335 if((sts > 0x01) && (sts < 0x80)) { 335 if((sts > 0x01) && (sts < 0x80)) {
336 info("unknown status %2.2x", sts); 336 info("unknown status %2.2x", sts);
337 bad++; 337 bad++;
@@ -350,7 +350,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
350 DEBUG(2, "found initial image"); 350 DEBUG(2, "found initial image");
351 cam->lastframe = -1; 351 cam->lastframe = -1;
352 } 352 }
353 353
354 marker[3] = sts & 0x7F; 354 marker[3] = sts & 0x7F;
355 RingQueue_Enqueue(&uvd->dp, marker, 4); 355 RingQueue_Enqueue(&uvd->dp, marker, 4);
356 totlen += 4; 356 totlen += 4;
@@ -367,16 +367,16 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
367 367
368static void resubmit_urb(struct uvd *uvd, struct urb *urb) 368static void resubmit_urb(struct uvd *uvd, struct urb *urb)
369{ 369{
370 int i, ret; 370 int i, ret;
371 for (i = 0; i < FRAMES_PER_DESC; i++) { 371 for (i = 0; i < FRAMES_PER_DESC; i++) {
372 urb->iso_frame_desc[i].status = 0; 372 urb->iso_frame_desc[i].status = 0;
373 } 373 }
374 urb->dev = uvd->dev; 374 urb->dev = uvd->dev;
375 urb->status = 0; 375 urb->status = 0;
376 ret = usb_submit_urb(urb, GFP_ATOMIC); 376 ret = usb_submit_urb(urb, GFP_ATOMIC);
377 DEBUG(3, "submitting urb of length %d", urb->transfer_buffer_length); 377 DEBUG(3, "submitting urb of length %d", urb->transfer_buffer_length);
378 if(ret) 378 if(ret)
379 err("usb_submit_urb error (%d)", ret); 379 err("usb_submit_urb error (%d)", ret);
380 380
381} 381}
382 382
@@ -490,7 +490,7 @@ static int konicawc_start_data(struct uvd *uvd)
490 } 490 }
491 491
492 cam->last_data_urb = NULL; 492 cam->last_data_urb = NULL;
493 493
494 /* Submit all URBs */ 494 /* Submit all URBs */
495 for (i=0; i < USBVIDEO_NUMSBUF; i++) { 495 for (i=0; i < USBVIDEO_NUMSBUF; i++) {
496 errFlag = usb_submit_urb(cam->sts_urb[i], GFP_KERNEL); 496 errFlag = usb_submit_urb(cam->sts_urb[i], GFP_KERNEL);
@@ -539,7 +539,7 @@ static void konicawc_stop_data(struct uvd *uvd)
539 539
540 540
541static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame) 541static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame)
542{ 542{
543 struct konicawc *cam = (struct konicawc *)uvd->user_data; 543 struct konicawc *cam = (struct konicawc *)uvd->user_data;
544 int maxline = cam->maxline; 544 int maxline = cam->maxline;
545 int yplanesz = cam->yplanesz; 545 int yplanesz = cam->yplanesz;
@@ -583,13 +583,13 @@ static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame)
583 583
584 if(frame->scanstate == ScanState_Scanning) 584 if(frame->scanstate == ScanState_Scanning)
585 return; 585 return;
586 586
587 /* Try to move data from queue into frame buffer 587 /* Try to move data from queue into frame buffer
588 * We get data in blocks of 384 bytes made up of: 588 * We get data in blocks of 384 bytes made up of:
589 * 256 Y, 64 U, 64 V. 589 * 256 Y, 64 U, 64 V.
590 * This needs to be written out as a Y plane, a U plane and a V plane. 590 * This needs to be written out as a Y plane, a U plane and a V plane.
591 */ 591 */
592 592
593 while ( frame->curline < maxline && (RingQueue_GetLength(&uvd->dp) >= 384)) { 593 while ( frame->curline < maxline && (RingQueue_GetLength(&uvd->dp) >= 384)) {
594 /* Y */ 594 /* Y */
595 RingQueue_Dequeue(&uvd->dp, frame->data + (frame->curline * 256), 256); 595 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 75ff755224df..10c58b4a2e5b 100644
--- a/drivers/usb/media/ultracam.c
+++ b/drivers/media/video/usbvideo/ultracam.c
@@ -23,7 +23,7 @@
23typedef struct { 23typedef struct {
24 int initialized; /* Had we already sent init sequence? */ 24 int initialized; /* Had we already sent init sequence? */
25 int camera_model; /* What type of IBM camera we got? */ 25 int camera_model; /* What type of IBM camera we got? */
26 int has_hdr; 26 int has_hdr;
27} ultracam_t; 27} ultracam_t;
28#define ULTRACAM_T(uvd) ((ultracam_t *)((uvd)->user_data)) 28#define ULTRACAM_T(uvd) ((ultracam_t *)((uvd)->user_data))
29 29
diff --git a/drivers/usb/media/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 0b51fae720a9..13b37c8c0d56 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)
574 } else { 574 } else {
575 /* Just the blue screen */ 575 /* Just the blue screen */
576 } 576 }
577 577
578 *f++ = cb; 578 *f++ = cb;
579 *f++ = cg; 579 *f++ = cg;
580 *f++ = cr; 580 *f++ = cr;
@@ -1243,7 +1243,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file)
1243 1243
1244#if USBVIDEO_REPORT_STATS 1244#if USBVIDEO_REPORT_STATS
1245 usbvideo_ReportStatistics(uvd); 1245 usbvideo_ReportStatistics(uvd);
1246#endif 1246#endif
1247 1247
1248 uvd->user--; 1248 uvd->user--;
1249 if (uvd->remove_pending) { 1249 if (uvd->remove_pending) {
@@ -1290,7 +1290,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1290 return 0; 1290 return 0;
1291 } 1291 }
1292 case VIDIOCSCHAN: 1292 case VIDIOCSCHAN:
1293 { 1293 {
1294 struct video_channel *v = arg; 1294 struct video_channel *v = arg;
1295 if (v->channel != 0) 1295 if (v->channel != 0)
1296 return -EINVAL; 1296 return -EINVAL;
@@ -1347,7 +1347,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1347 vw->chromakey = 0; 1347 vw->chromakey = 0;
1348 if (VALID_CALLBACK(uvd, getFPS)) 1348 if (VALID_CALLBACK(uvd, getFPS))
1349 vw->flags = GET_CALLBACK(uvd, getFPS)(uvd); 1349 vw->flags = GET_CALLBACK(uvd, getFPS)(uvd);
1350 else 1350 else
1351 vw->flags = 10; /* FIXME: do better! */ 1351 vw->flags = 10; /* FIXME: do better! */
1352 return 0; 1352 return 0;
1353 } 1353 }
@@ -1359,7 +1359,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1359 memset(vm, 0, sizeof(*vm)); 1359 memset(vm, 0, sizeof(*vm));
1360 vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES; 1360 vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES;
1361 vm->frames = USBVIDEO_NUMFRAMES; 1361 vm->frames = USBVIDEO_NUMFRAMES;
1362 for(i = 0; i < USBVIDEO_NUMFRAMES; i++) 1362 for(i = 0; i < USBVIDEO_NUMFRAMES; i++)
1363 vm->offsets[i] = i * uvd->max_frame_size; 1363 vm->offsets[i] = i * uvd->max_frame_size;
1364 1364
1365 return 0; 1365 return 0;
@@ -1425,7 +1425,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1425 1425
1426 if (*frameNum < 0 || *frameNum >= USBVIDEO_NUMFRAMES) 1426 if (*frameNum < 0 || *frameNum >= USBVIDEO_NUMFRAMES)
1427 return -EINVAL; 1427 return -EINVAL;
1428 1428
1429 if (uvd->debug >= 1) 1429 if (uvd->debug >= 1)
1430 info("VIDIOCSYNC: syncing to frame %d.", *frameNum); 1430 info("VIDIOCSYNC: syncing to frame %d.", *frameNum);
1431 if (uvd->flags & FLAGS_NO_DECODING) 1431 if (uvd->flags & FLAGS_NO_DECODING)
@@ -1454,8 +1454,8 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
1454 struct video_buffer *vb = arg; 1454 struct video_buffer *vb = arg;
1455 1455
1456 memset(vb, 0, sizeof(*vb)); 1456 memset(vb, 0, sizeof(*vb));
1457 return 0; 1457 return 0;
1458 } 1458 }
1459 case VIDIOCKEY: 1459 case VIDIOCKEY:
1460 return 0; 1460 return 0;
1461 1461
@@ -1704,7 +1704,7 @@ static void usbvideo_IsocIrq(struct urb *urb, struct pt_regs *regs)
1704 info("Not streaming, but interrupt!"); 1704 info("Not streaming, but interrupt!");
1705 return; 1705 return;
1706 } 1706 }
1707 1707
1708 uvd->stats.urb_count++; 1708 uvd->stats.urb_count++;
1709 if (urb->actual_length <= 0) 1709 if (urb->actual_length <= 0)
1710 goto urb_done_with; 1710 goto urb_done_with;
@@ -1763,7 +1763,7 @@ static int usbvideo_StartDataPump(struct uvd *uvd)
1763 } 1763 }
1764 if (VALID_CALLBACK(uvd, videoStart)) 1764 if (VALID_CALLBACK(uvd, videoStart))
1765 GET_CALLBACK(uvd, videoStart)(uvd); 1765 GET_CALLBACK(uvd, videoStart)(uvd);
1766 else 1766 else
1767 err("%s: videoStart not set", __FUNCTION__); 1767 err("%s: videoStart not set", __FUNCTION__);
1768 1768
1769 /* We double buffer the Iso lists */ 1769 /* We double buffer the Iso lists */
@@ -1830,7 +1830,7 @@ static void usbvideo_StopDataPump(struct uvd *uvd)
1830 /* Invoke minidriver's magic to stop the camera */ 1830 /* Invoke minidriver's magic to stop the camera */
1831 if (VALID_CALLBACK(uvd, videoStop)) 1831 if (VALID_CALLBACK(uvd, videoStop))
1832 GET_CALLBACK(uvd, videoStop)(uvd); 1832 GET_CALLBACK(uvd, videoStop)(uvd);
1833 else 1833 else
1834 err("%s: videoStop not set", __FUNCTION__); 1834 err("%s: videoStop not set", __FUNCTION__);
1835 1835
1836 /* Set packet size to 0 */ 1836 /* Set packet size to 0 */
@@ -1963,14 +1963,14 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
1963 info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum); 1963 info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum);
1964 1964
1965 switch (frame->frameState) { 1965 switch (frame->frameState) {
1966 case FrameState_Unused: 1966 case FrameState_Unused:
1967 if (uvd->debug >= 2) 1967 if (uvd->debug >= 2)
1968 info("%s: FrameState_Unused", __FUNCTION__); 1968 info("%s: FrameState_Unused", __FUNCTION__);
1969 return -EINVAL; 1969 return -EINVAL;
1970 case FrameState_Ready: 1970 case FrameState_Ready:
1971 case FrameState_Grabbing: 1971 case FrameState_Grabbing:
1972 case FrameState_Error: 1972 case FrameState_Error:
1973 { 1973 {
1974 int ntries, signalPending; 1974 int ntries, signalPending;
1975 redo: 1975 redo:
1976 if (!CAMERA_IS_OPERATIONAL(uvd)) { 1976 if (!CAMERA_IS_OPERATIONAL(uvd)) {
@@ -1978,7 +1978,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
1978 info("%s: Camera is not operational (1)", __FUNCTION__); 1978 info("%s: Camera is not operational (1)", __FUNCTION__);
1979 return -EIO; 1979 return -EIO;
1980 } 1980 }
1981 ntries = 0; 1981 ntries = 0;
1982 do { 1982 do {
1983 RingQueue_InterruptibleSleepOn(&uvd->dp); 1983 RingQueue_InterruptibleSleepOn(&uvd->dp);
1984 signalPending = signal_pending(current); 1984 signalPending = signal_pending(current);
@@ -2010,7 +2010,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
2010 usbvideo_CollectRawData(uvd, frame); 2010 usbvideo_CollectRawData(uvd, frame);
2011 else if (VALID_CALLBACK(uvd, processData)) 2011 else if (VALID_CALLBACK(uvd, processData))
2012 GET_CALLBACK(uvd, processData)(uvd, frame); 2012 GET_CALLBACK(uvd, processData)(uvd, frame);
2013 else 2013 else
2014 err("%s: processData not set", __FUNCTION__); 2014 err("%s: processData not set", __FUNCTION__);
2015 } 2015 }
2016 } while (frame->frameState == FrameState_Grabbing); 2016 } while (frame->frameState == FrameState_Grabbing);
@@ -2027,8 +2027,8 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
2027 goto redo; 2027 goto redo;
2028 } 2028 }
2029 /* Note that we fall through to meet our destiny below */ 2029 /* Note that we fall through to meet our destiny below */
2030 } 2030 }
2031 case FrameState_Done: 2031 case FrameState_Done:
2032 /* 2032 /*
2033 * Do all necessary postprocessing of data prepared in 2033 * Do all necessary postprocessing of data prepared in
2034 * "interrupt" code and the collecting code above. The 2034 * "interrupt" code and the collecting code above. The
@@ -2157,7 +2157,7 @@ EXPORT_SYMBOL(usbvideo_DeinterlaceFrame);
2157 * History: 2157 * History:
2158 * 09-Feb-2001 Created. 2158 * 09-Feb-2001 Created.
2159 */ 2159 */
2160static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, 2160static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd,
2161 struct usbvideo_frame *frame) 2161 struct usbvideo_frame *frame)
2162{ 2162{
2163 int i, j, v4l_linesize; 2163 int i, j, v4l_linesize;
diff --git a/drivers/usb/media/usbvideo.h b/drivers/media/video/usbvideo/usbvideo.h
index 135433c2680a..3cbf4fc499a3 100644
--- a/drivers/usb/media/usbvideo.h
+++ b/drivers/media/video/usbvideo/usbvideo.h
@@ -189,11 +189,11 @@ struct usbvideo_frame {
189 189
190/* Statistics that can be overlaid on screen */ 190/* Statistics that can be overlaid on screen */
191struct usbvideo_statistics { 191struct usbvideo_statistics {
192 unsigned long frame_num; /* Sequential number of the frame */ 192 unsigned long frame_num; /* Sequential number of the frame */
193 unsigned long urb_count; /* How many URBs we received so far */ 193 unsigned long urb_count; /* How many URBs we received so far */
194 unsigned long urb_length; /* Length of last URB */ 194 unsigned long urb_length; /* Length of last URB */
195 unsigned long data_count; /* How many bytes we received */ 195 unsigned long data_count; /* How many bytes we received */
196 unsigned long header_count; /* How many frame headers we found */ 196 unsigned long header_count; /* How many frame headers we found */
197 unsigned long iso_skip_count; /* How many empty ISO packets received */ 197 unsigned long iso_skip_count; /* How many empty ISO packets received */
198 unsigned long iso_err_count; /* How many bad ISO packets received */ 198 unsigned long iso_err_count; /* How many bad ISO packets received */
199}; 199};
diff --git a/drivers/usb/media/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 1d06e53ec7c5..90d48e8510ba 100644
--- a/drivers/usb/media/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -69,10 +69,10 @@
69#define VICAM_HEADER_SIZE 64 69#define VICAM_HEADER_SIZE 64
70 70
71#define clamp( x, l, h ) max_t( __typeof__( x ), \ 71#define clamp( x, l, h ) max_t( __typeof__( x ), \
72 ( l ), \ 72 ( l ), \
73 min_t( __typeof__( x ), \ 73 min_t( __typeof__( x ), \
74 ( h ), \ 74 ( h ), \
75 ( x ) ) ) 75 ( x ) ) )
76 76
77/* Not sure what all the bytes in these char 77/* Not sure what all the bytes in these char
78 * arrays do, but they're necessary to make 78 * arrays do, but they're necessary to make
@@ -357,7 +357,7 @@ static unsigned char setup5[] = {
357 * Not sure why these are not yet non-statics which I can reference through 357 * Not sure why these are not yet non-statics which I can reference through
358 * usbvideo.h the same as it is in 2.4.20. I bet this will get fixed sometime 358 * usbvideo.h the same as it is in 2.4.20. I bet this will get fixed sometime
359 * in the future. 359 * in the future.
360 * 360 *
361*/ 361*/
362static void *rvmalloc(unsigned long size) 362static void *rvmalloc(unsigned long size)
363{ 363{
@@ -603,12 +603,12 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
603 case VIDIOCSPICT: 603 case VIDIOCSPICT:
604 { 604 {
605 struct video_picture vp; 605 struct video_picture vp;
606 606
607 if (copy_from_user(&vp, user_arg, sizeof(vp))) { 607 if (copy_from_user(&vp, user_arg, sizeof(vp))) {
608 retval = -EFAULT; 608 retval = -EFAULT;
609 break; 609 break;
610 } 610 }
611 611
612 DBG("VIDIOCSPICT depth = %d, pal = %d\n", vp.depth, 612 DBG("VIDIOCSPICT depth = %d, pal = %d\n", vp.depth,
613 vp.palette); 613 vp.palette);
614 614
@@ -655,7 +655,7 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
655 } 655 }
656 656
657 DBG("VIDIOCSWIN %d x %d\n", vw.width, vw.height); 657 DBG("VIDIOCSWIN %d x %d\n", vw.width, vw.height);
658 658
659 if ( vw.width != 320 || vw.height != 240 ) 659 if ( vw.width != 320 || vw.height != 240 )
660 retval = -EFAULT; 660 retval = -EFAULT;
661 661
@@ -809,12 +809,12 @@ vicam_open(struct inode *inode, struct file *file)
809 cam->needsDummyRead = 1; 809 cam->needsDummyRead = 1;
810 cam->open_count++; 810 cam->open_count++;
811 811
812 file->private_data = cam; 812 file->private_data = cam;
813 813
814 return 0; 814 return 0;
815} 815}
816 816
817static int 817static int
818vicam_close(struct inode *inode, struct file *file) 818vicam_close(struct inode *inode, struct file *file)
819{ 819{
820 struct vicam_camera *cam = file->private_data; 820 struct vicam_camera *cam = file->private_data;
@@ -1187,7 +1187,7 @@ vicam_create_proc_entry(struct vicam_camera *cam)
1187 1187
1188 if ( !cam->proc_dir ) 1188 if ( !cam->proc_dir )
1189 return; // FIXME: We should probably return an error here 1189 return; // FIXME: We should probably return an error here
1190 1190
1191 ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR, 1191 ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR,
1192 cam->proc_dir); 1192 cam->proc_dir);
1193 if (ent) { 1193 if (ent) {
@@ -1282,7 +1282,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
1282 const struct usb_host_interface *interface; 1282 const struct usb_host_interface *interface;
1283 const struct usb_endpoint_descriptor *endpoint; 1283 const struct usb_endpoint_descriptor *endpoint;
1284 struct vicam_camera *cam; 1284 struct vicam_camera *cam;
1285 1285
1286 printk(KERN_INFO "ViCam based webcam connected\n"); 1286 printk(KERN_INFO "ViCam based webcam connected\n");
1287 1287
1288 interface = intf->cur_altsetting; 1288 interface = intf->cur_altsetting;
@@ -1331,7 +1331,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
1331 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor); 1331 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor);
1332 1332
1333 usb_set_intfdata (intf, cam); 1333 usb_set_intfdata (intf, cam);
1334 1334
1335 return 0; 1335 return 0;
1336} 1336}
1337 1337
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 95a6e47c99f1..11a97f30b876 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[] = {
312 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP", 312 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
313#endif 313#endif
314 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", 314 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
315 [_IOC_NR(AUDC_SET_INPUT)] = "AUDC_SET_INPUT",
316 [_IOC_NR(MSP_SET_MATRIX)] = "MSP_SET_MATRIX",
317 315
318 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", 316 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
319 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", 317 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
@@ -419,7 +417,6 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
419 case TUNER_SET_TYPE_ADDR: 417 case TUNER_SET_TYPE_ADDR:
420 case TUNER_SET_STANDBY: 418 case TUNER_SET_STANDBY:
421 case TDA9887_SET_CONFIG: 419 case TDA9887_SET_CONFIG:
422 case AUDC_SET_INPUT:
423 case VIDIOC_OVERLAY_OLD: 420 case VIDIOC_OVERLAY_OLD:
424 case VIDIOC_STREAMOFF: 421 case VIDIOC_STREAMOFF:
425 case VIDIOC_G_OUTPUT: 422 case VIDIOC_G_OUTPUT:
@@ -433,12 +430,6 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
433 printk ("%s: value=%d\n", s, *p); 430 printk ("%s: value=%d\n", s, *p);
434 break; 431 break;
435 } 432 }
436 case MSP_SET_MATRIX:
437 {
438 struct msp_matrix *p=arg;
439 printk ("%s: input=%d, output=%d\n", s, p->input, p->output);
440 break;
441 }
442 case VIDIOC_G_AUDIO: 433 case VIDIOC_G_AUDIO:
443 case VIDIOC_S_AUDIO: 434 case VIDIOC_S_AUDIO:
444 case VIDIOC_ENUMAUDIO: 435 case VIDIOC_ENUMAUDIO:
@@ -467,7 +458,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
467 struct v4l2_buffer *p=arg; 458 struct v4l2_buffer *p=arg;
468 struct v4l2_timecode *tc=&p->timecode; 459 struct v4l2_timecode *tc=&p->timecode;
469 printk ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, " 460 printk ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, "
470 "bytesused=%d, flags=0x%08d, " 461 "bytesused=%d, flags=0x%08x, "
471 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n", 462 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n",
472 s, 463 s,
473 (p->timestamp.tv_sec/3600), 464 (p->timestamp.tv_sec/3600),
@@ -481,16 +472,16 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
481 prt_names(p->memory,v4l2_memory_names), 472 prt_names(p->memory,v4l2_memory_names),
482 p->m.userptr); 473 p->m.userptr);
483 printk ("%s: timecode= %02d:%02d:%02d type=%d, " 474 printk ("%s: timecode= %02d:%02d:%02d type=%d, "
484 "flags=0x%08d, frames=%d, userbits=0x%08x", 475 "flags=0x%08x, frames=%d, userbits=0x%p\n",
485 s,tc->hours,tc->minutes,tc->seconds, 476 s,tc->hours,tc->minutes,tc->seconds,
486 tc->type, tc->flags, tc->frames, (__u32) tc->userbits); 477 tc->type, tc->flags, tc->frames, tc->userbits);
487 break; 478 break;
488 } 479 }
489 case VIDIOC_QUERYCAP: 480 case VIDIOC_QUERYCAP:
490 { 481 {
491 struct v4l2_capability *p=arg; 482 struct v4l2_capability *p=arg;
492 printk ("%s: driver=%s, card=%s, bus=%s, version=%d, " 483 printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, "
493 "capabilities=%d\n", s, 484 "capabilities=0x%08x\n", s,
494 p->driver,p->card,p->bus_info, 485 p->driver,p->card,p->bus_info,
495 p->version, 486 p->version,
496 p->capabilities); 487 p->capabilities);
@@ -574,9 +565,10 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
574 { 565 {
575 struct v4l2_input *p=arg; 566 struct v4l2_input *p=arg;
576 printk ("%s: index=%d, name=%s, type=%d, audioset=%d, " 567 printk ("%s: index=%d, name=%s, type=%d, audioset=%d, "
577 "tuner=%d, std=%lld, status=%d\n", s, 568 "tuner=%d, std=%Ld, status=%d\n", s,
578 p->index,p->name,p->type,p->audioset, 569 p->index,p->name,p->type,p->audioset,
579 p->tuner,p->std, 570 p->tuner,
571 (unsigned long long)p->std,
580 p->status); 572 p->status);
581 break; 573 break;
582 } 574 }
@@ -620,9 +612,10 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
620 { 612 {
621 struct v4l2_output *p=arg; 613 struct v4l2_output *p=arg;
622 printk ("%s: index=%d, name=%s,type=%d, audioset=%d, " 614 printk ("%s: index=%d, name=%s,type=%d, audioset=%d, "
623 "modulator=%d, std=%lld\n", 615 "modulator=%d, std=%Ld\n",
624 s,p->index,p->name,p->type,p->audioset, 616 s,p->index,p->name,p->type,p->audioset,
625 p->modulator,p->std); 617 p->modulator,
618 (unsigned long long)p->std);
626 break; 619 break;
627 } 620 }
628 case VIDIOC_QUERYCTRL: 621 case VIDIOC_QUERYCTRL:
@@ -665,7 +658,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
665 case VIDIOC_INT_G_VIDEO_ROUTING: 658 case VIDIOC_INT_G_VIDEO_ROUTING:
666 { 659 {
667 struct v4l2_routing *p=arg; 660 struct v4l2_routing *p=arg;
668 printk ("%s: input=%d, output=%d\n", s, p->input, p->output); 661 printk ("%s: input=0x%x, output=0x%x\n", s, p->input, p->output);
669 break; 662 break;
670 } 663 }
671 case VIDIOC_G_SLICED_VBI_CAP: 664 case VIDIOC_G_SLICED_VBI_CAP:
@@ -686,8 +679,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
686 case VIDIOC_ENUMSTD: 679 case VIDIOC_ENUMSTD:
687 { 680 {
688 struct v4l2_standard *p=arg; 681 struct v4l2_standard *p=arg;
689 printk ("%s: index=%d, id=%lld, name=%s, fps=%d/%d, framelines=%d\n", s, 682 printk ("%s: index=%d, id=%Ld, name=%s, fps=%d/%d, "
690 p->index, p->id, p->name, 683 "framelines=%d\n", s, p->index,
684 (unsigned long long)p->id, p->name,
691 p->frameperiod.numerator, 685 p->frameperiod.numerator,
692 p->frameperiod.denominator, 686 p->frameperiod.denominator,
693 p->framelines); 687 p->framelines);
@@ -907,7 +901,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
907 { 901 {
908 v4l2_std_id *p=arg; 902 v4l2_std_id *p=arg;
909 903
910 printk ("%s: value=%llu\n", s, *p); 904 printk ("%s: value=%Lu\n", s, (unsigned long long)*p);
911 break; 905 break;
912 } 906 }
913 } 907 }
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 87e937581d5a..d2ca0f08d0df 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -1,15 +1,20 @@
1/* 1/*
2 * 2 *
3 * generic helper functions for video4linux capture buffers, to handle 3 * generic helper functions for video4linux capture buffers, to handle
4 * memory management and PCI DMA. Right now bttv + saa7134 use it. 4 * memory management and PCI DMA.
5 * Right now, bttv, saa7134, saa7146 and cx88 use it.
5 * 6 *
6 * The functions expect the hardware being able to scatter gatter 7 * The functions expect the hardware being able to scatter gatter
7 * (i.e. the buffers are not linear in physical memory, but fragmented 8 * (i.e. the buffers are not linear in physical memory, but fragmented
8 * into PAGE_SIZE chunks). They also assume the driver does not need 9 * into PAGE_SIZE chunks). They also assume the driver does not need
9 * to touch the video data (thus it is probably not useful for USB 1.1 10 * to touch the video data.
10 * as data often must be uncompressed by the drivers). 11 *
12 * device specific map/unmap/sync stuff now are mapped as operations
13 * to allow its usage by USB and virtual devices.
11 * 14 *
12 * (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] 15 * (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
16 * (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
17 * (c) 2006 Ted Walther and John Sokol
13 * 18 *
14 * This program is free software; you can redistribute it and/or modify 19 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 20 * 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,
167 dprintk(1,"vmalloc_32(%d pages) failed\n",nr_pages); 172 dprintk(1,"vmalloc_32(%d pages) failed\n",nr_pages);
168 return -ENOMEM; 173 return -ENOMEM;
169 } 174 }
175 dprintk(1,"vmalloc is at addr 0x%08lx, size=%d\n",
176 (unsigned long)dma->vmalloc,
177 nr_pages << PAGE_SHIFT);
170 memset(dma->vmalloc,0,nr_pages << PAGE_SHIFT); 178 memset(dma->vmalloc,0,nr_pages << PAGE_SHIFT);
171 dma->nr_pages = nr_pages; 179 dma->nr_pages = nr_pages;
172 return 0; 180 return 0;
@@ -186,8 +194,10 @@ int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
186 return 0; 194 return 0;
187} 195}
188 196
189int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma) 197int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
190{ 198{
199 void *dev=q->dev;
200
191 MAGIC_CHECK(dma->magic,MAGIC_DMABUF); 201 MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
192 BUG_ON(0 == dma->nr_pages); 202 BUG_ON(0 == dma->nr_pages);
193 203
@@ -197,7 +207,7 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
197 } 207 }
198 if (dma->vmalloc) { 208 if (dma->vmalloc) {
199 dma->sglist = videobuf_vmalloc_to_sg 209 dma->sglist = videobuf_vmalloc_to_sg
200 (dma->vmalloc,dma->nr_pages); 210 (dma->vmalloc,dma->nr_pages);
201 } 211 }
202 if (dma->bus_addr) { 212 if (dma->bus_addr) {
203 dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL); 213 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)
212 dprintk(1,"scatterlist is NULL\n"); 222 dprintk(1,"scatterlist is NULL\n");
213 return -ENOMEM; 223 return -ENOMEM;
214 } 224 }
215
216 if (!dma->bus_addr) { 225 if (!dma->bus_addr) {
217 dma->sglen = pci_map_sg(dev,dma->sglist,dma->nr_pages, 226 if (q->ops->vb_map_sg) {
218 dma->direction); 227 dma->sglen = q->ops->vb_map_sg(dev,dma->sglist,
228 dma->nr_pages, dma->direction);
229 }
219 if (0 == dma->sglen) { 230 if (0 == dma->sglen) {
220 printk(KERN_WARNING 231 printk(KERN_WARNING
221 "%s: pci_map_sg failed\n",__FUNCTION__); 232 "%s: videobuf_map_sg failed\n",__FUNCTION__);
222 kfree(dma->sglist); 233 kfree(dma->sglist);
223 dma->sglist = NULL; 234 dma->sglist = NULL;
224 dma->sglen = 0; 235 dma->sglen = 0;
@@ -228,24 +239,31 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
228 return 0; 239 return 0;
229} 240}
230 241
231int videobuf_dma_pci_sync(struct pci_dev *dev, struct videobuf_dmabuf *dma) 242int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
232{ 243{
244 void *dev=q->dev;
245
233 MAGIC_CHECK(dma->magic,MAGIC_DMABUF); 246 MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
234 BUG_ON(!dma->sglen); 247 BUG_ON(!dma->sglen);
235 248
236 if (!dma->bus_addr) 249 if (!dma->bus_addr && q->ops->vb_dma_sync_sg)
237 pci_dma_sync_sg_for_cpu(dev,dma->sglist,dma->nr_pages,dma->direction); 250 q->ops->vb_dma_sync_sg(dev,dma->sglist,dma->nr_pages,
251 dma->direction);
252
238 return 0; 253 return 0;
239} 254}
240 255
241int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma) 256int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
242{ 257{
258 void *dev=q->dev;
259
243 MAGIC_CHECK(dma->magic,MAGIC_DMABUF); 260 MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
244 if (!dma->sglen) 261 if (!dma->sglen)
245 return 0; 262 return 0;
246 263
247 if (!dma->bus_addr) 264 if (!dma->bus_addr && q->ops->vb_unmap_sg)
248 pci_unmap_sg(dev,dma->sglist,dma->nr_pages,dma->direction); 265 q->ops->vb_unmap_sg(dev,dma->sglist,dma->nr_pages,
266 dma->direction);
249 kfree(dma->sglist); 267 kfree(dma->sglist);
250 dma->sglist = NULL; 268 dma->sglist = NULL;
251 dma->sglen = 0; 269 dma->sglen = 0;
@@ -318,7 +336,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
318} 336}
319 337
320int 338int
321videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb, 339videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
322 struct v4l2_framebuffer *fbuf) 340 struct v4l2_framebuffer *fbuf)
323{ 341{
324 int err,pages; 342 int err,pages;
@@ -357,7 +375,7 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
357 default: 375 default:
358 BUG(); 376 BUG();
359 } 377 }
360 err = videobuf_dma_pci_map(pci,&vb->dma); 378 err = videobuf_dma_map(q,&vb->dma);
361 if (0 != err) 379 if (0 != err)
362 return err; 380 return err;
363 381
@@ -366,9 +384,41 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
366 384
367/* --------------------------------------------------------------------- */ 385/* --------------------------------------------------------------------- */
368 386
387void videobuf_queue_pci(struct videobuf_queue* q)
388{
389 /* If not specified, defaults to PCI map sg */
390 if (!q->ops->vb_map_sg)
391 q->ops->vb_map_sg=(vb_map_sg_t *)pci_map_sg;
392
393 if (!q->ops->vb_dma_sync_sg)
394 q->ops->vb_dma_sync_sg=(vb_map_sg_t *)pci_dma_sync_sg_for_cpu;
395 if (!q->ops->vb_unmap_sg)
396 q->ops->vb_unmap_sg=(vb_map_sg_t *)pci_unmap_sg;
397}
398
399int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma)
400{
401 struct videobuf_queue q;
402
403 q.dev=pci;
404 q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
405
406 return (videobuf_dma_unmap(&q,dma));
407}
408
409int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma)
410{
411 struct videobuf_queue q;
412
413 q.dev=pci;
414 q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
415
416 return (videobuf_dma_unmap(&q,dma));
417}
418
369void videobuf_queue_init(struct videobuf_queue* q, 419void videobuf_queue_init(struct videobuf_queue* q,
370 struct videobuf_queue_ops *ops, 420 struct videobuf_queue_ops *ops,
371 struct pci_dev *pci, 421 void *dev,
372 spinlock_t *irqlock, 422 spinlock_t *irqlock,
373 enum v4l2_buf_type type, 423 enum v4l2_buf_type type,
374 enum v4l2_field field, 424 enum v4l2_field field,
@@ -377,13 +427,15 @@ void videobuf_queue_init(struct videobuf_queue* q,
377{ 427{
378 memset(q,0,sizeof(*q)); 428 memset(q,0,sizeof(*q));
379 q->irqlock = irqlock; 429 q->irqlock = irqlock;
380 q->pci = pci; 430 q->dev = dev;
381 q->type = type; 431 q->type = type;
382 q->field = field; 432 q->field = field;
383 q->msize = msize; 433 q->msize = msize;
384 q->ops = ops; 434 q->ops = ops;
385 q->priv_data = priv; 435 q->priv_data = priv;
386 436
437 videobuf_queue_pci(q);
438
387 mutex_init(&q->lock); 439 mutex_init(&q->lock);
388 INIT_LIST_HEAD(&q->stream); 440 INIT_LIST_HEAD(&q->stream);
389} 441}
@@ -431,7 +483,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
431 int i; 483 int i;
432 484
433 /* remove queued buffers from list */ 485 /* remove queued buffers from list */
434 spin_lock_irqsave(q->irqlock,flags); 486 if (q->irqlock)
487 spin_lock_irqsave(q->irqlock,flags);
435 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 488 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
436 if (NULL == q->bufs[i]) 489 if (NULL == q->bufs[i])
437 continue; 490 continue;
@@ -440,7 +493,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
440 q->bufs[i]->state = STATE_ERROR; 493 q->bufs[i]->state = STATE_ERROR;
441 } 494 }
442 } 495 }
443 spin_unlock_irqrestore(q->irqlock,flags); 496 if (q->irqlock)
497 spin_unlock_irqrestore(q->irqlock,flags);
444 498
445 /* free all buffers + clear queue */ 499 /* free all buffers + clear queue */
446 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 500 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
@@ -534,19 +588,29 @@ videobuf_reqbufs(struct videobuf_queue *q,
534 unsigned int size,count; 588 unsigned int size,count;
535 int retval; 589 int retval;
536 590
537 if (req->type != q->type) 591 if (req->type != q->type) {
592 dprintk(1,"reqbufs: queue type invalid\n");
538 return -EINVAL; 593 return -EINVAL;
539 if (req->count < 1) 594 }
595 if (req->count < 1) {
596 dprintk(1,"reqbufs: count invalid (%d)\n",req->count);
540 return -EINVAL; 597 return -EINVAL;
598 }
541 if (req->memory != V4L2_MEMORY_MMAP && 599 if (req->memory != V4L2_MEMORY_MMAP &&
542 req->memory != V4L2_MEMORY_USERPTR && 600 req->memory != V4L2_MEMORY_USERPTR &&
543 req->memory != V4L2_MEMORY_OVERLAY) 601 req->memory != V4L2_MEMORY_OVERLAY) {
602 dprintk(1,"reqbufs: memory type invalid\n");
544 return -EINVAL; 603 return -EINVAL;
604 }
545 605
546 if (q->streaming) 606 if (q->streaming) {
607 dprintk(1,"reqbufs: streaming already exists\n");
547 return -EBUSY; 608 return -EBUSY;
548 if (!list_empty(&q->stream)) 609 }
610 if (!list_empty(&q->stream)) {
611 dprintk(1,"reqbufs: stream running\n");
549 return -EBUSY; 612 return -EBUSY;
613 }
550 614
551 mutex_lock(&q->lock); 615 mutex_lock(&q->lock);
552 count = req->count; 616 count = req->count;
@@ -559,8 +623,10 @@ videobuf_reqbufs(struct videobuf_queue *q,
559 count, size, (count*size)>>PAGE_SHIFT); 623 count, size, (count*size)>>PAGE_SHIFT);
560 624
561 retval = videobuf_mmap_setup(q,count,size,req->memory); 625 retval = videobuf_mmap_setup(q,count,size,req->memory);
562 if (retval < 0) 626 if (retval < 0) {
627 dprintk(1,"reqbufs: mmap setup returned %d\n",retval);
563 goto done; 628 goto done;
629 }
564 630
565 req->count = count; 631 req->count = count;
566 632
@@ -572,12 +638,18 @@ videobuf_reqbufs(struct videobuf_queue *q,
572int 638int
573videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) 639videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
574{ 640{
575 if (unlikely(b->type != q->type)) 641 if (unlikely(b->type != q->type)) {
642 dprintk(1,"querybuf: Wrong type.\n");
576 return -EINVAL; 643 return -EINVAL;
577 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) 644 }
645 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
646 dprintk(1,"querybuf: index out of range.\n");
578 return -EINVAL; 647 return -EINVAL;
579 if (unlikely(NULL == q->bufs[b->index])) 648 }
649 if (unlikely(NULL == q->bufs[b->index])) {
650 dprintk(1,"querybuf: buffer is null.\n");
580 return -EINVAL; 651 return -EINVAL;
652 }
581 videobuf_status(b,q->bufs[b->index],q->type); 653 videobuf_status(b,q->bufs[b->index],q->type);
582 return 0; 654 return 0;
583} 655}
@@ -593,26 +665,40 @@ videobuf_qbuf(struct videobuf_queue *q,
593 665
594 mutex_lock(&q->lock); 666 mutex_lock(&q->lock);
595 retval = -EBUSY; 667 retval = -EBUSY;
596 if (q->reading) 668 if (q->reading) {
669 dprintk(1,"qbuf: Reading running...\n");
597 goto done; 670 goto done;
671 }
598 retval = -EINVAL; 672 retval = -EINVAL;
599 if (b->type != q->type) 673 if (b->type != q->type) {
674 dprintk(1,"qbuf: Wrong type.\n");
600 goto done; 675 goto done;
601 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) 676 }
677 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
678 dprintk(1,"qbuf: index out of range.\n");
602 goto done; 679 goto done;
680 }
603 buf = q->bufs[b->index]; 681 buf = q->bufs[b->index];
604 if (NULL == buf) 682 if (NULL == buf) {
683 dprintk(1,"qbuf: buffer is null.\n");
605 goto done; 684 goto done;
685 }
606 MAGIC_CHECK(buf->magic,MAGIC_BUFFER); 686 MAGIC_CHECK(buf->magic,MAGIC_BUFFER);
607 if (buf->memory != b->memory) 687 if (buf->memory != b->memory) {
688 dprintk(1,"qbuf: memory type is wrong.\n");
608 goto done; 689 goto done;
690 }
609 if (buf->state == STATE_QUEUED || 691 if (buf->state == STATE_QUEUED ||
610 buf->state == STATE_ACTIVE) 692 buf->state == STATE_ACTIVE) {
693 dprintk(1,"qbuf: buffer is already queued or active.\n");
611 goto done; 694 goto done;
695 }
612 696
613 if (b->flags & V4L2_BUF_FLAG_INPUT) { 697 if (b->flags & V4L2_BUF_FLAG_INPUT) {
614 if (b->input >= q->inputs) 698 if (b->input >= q->inputs) {
699 dprintk(1,"qbuf: wrong input.\n");
615 goto done; 700 goto done;
701 }
616 buf->input = b->input; 702 buf->input = b->input;
617 } else { 703 } else {
618 buf->input = UNSET; 704 buf->input = UNSET;
@@ -620,12 +706,16 @@ videobuf_qbuf(struct videobuf_queue *q,
620 706
621 switch (b->memory) { 707 switch (b->memory) {
622 case V4L2_MEMORY_MMAP: 708 case V4L2_MEMORY_MMAP:
623 if (0 == buf->baddr) 709 if (0 == buf->baddr) {
710 dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
624 goto done; 711 goto done;
712 }
625 break; 713 break;
626 case V4L2_MEMORY_USERPTR: 714 case V4L2_MEMORY_USERPTR:
627 if (b->length < buf->bsize) 715 if (b->length < buf->bsize) {
716 dprintk(1,"qbuf: buffer length is not enough\n");
628 goto done; 717 goto done;
718 }
629 if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr) 719 if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr)
630 q->ops->buf_release(q,buf); 720 q->ops->buf_release(q,buf);
631 buf->baddr = b->m.userptr; 721 buf->baddr = b->m.userptr;
@@ -634,20 +724,27 @@ videobuf_qbuf(struct videobuf_queue *q,
634 buf->boff = b->m.offset; 724 buf->boff = b->m.offset;
635 break; 725 break;
636 default: 726 default:
727 dprintk(1,"qbuf: wrong memory type\n");
637 goto done; 728 goto done;
638 } 729 }
639 730
731 dprintk(1,"qbuf: requesting next field\n");
640 field = videobuf_next_field(q); 732 field = videobuf_next_field(q);
641 retval = q->ops->buf_prepare(q,buf,field); 733 retval = q->ops->buf_prepare(q,buf,field);
642 if (0 != retval) 734 if (0 != retval) {
735 dprintk(1,"qbuf: buffer_prepare returned %d\n",retval);
643 goto done; 736 goto done;
737 }
644 738
645 list_add_tail(&buf->stream,&q->stream); 739 list_add_tail(&buf->stream,&q->stream);
646 if (q->streaming) { 740 if (q->streaming) {
647 spin_lock_irqsave(q->irqlock,flags); 741 if (q->irqlock)
742 spin_lock_irqsave(q->irqlock,flags);
648 q->ops->buf_queue(q,buf); 743 q->ops->buf_queue(q,buf);
649 spin_unlock_irqrestore(q->irqlock,flags); 744 if (q->irqlock)
745 spin_unlock_irqrestore(q->irqlock,flags);
650 } 746 }
747 dprintk(1,"qbuf: succeded\n");
651 retval = 0; 748 retval = 0;
652 749
653 done: 750 done:
@@ -664,26 +761,39 @@ videobuf_dqbuf(struct videobuf_queue *q,
664 761
665 mutex_lock(&q->lock); 762 mutex_lock(&q->lock);
666 retval = -EBUSY; 763 retval = -EBUSY;
667 if (q->reading) 764 if (q->reading) {
765 dprintk(1,"dqbuf: Reading running...\n");
668 goto done; 766 goto done;
767 }
669 retval = -EINVAL; 768 retval = -EINVAL;
670 if (b->type != q->type) 769 if (b->type != q->type) {
770 dprintk(1,"dqbuf: Wrong type.\n");
671 goto done; 771 goto done;
672 if (list_empty(&q->stream)) 772 }
773 if (list_empty(&q->stream)) {
774 dprintk(1,"dqbuf: stream running\n");
673 goto done; 775 goto done;
776 }
674 buf = list_entry(q->stream.next, struct videobuf_buffer, stream); 777 buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
675 retval = videobuf_waiton(buf, nonblocking, 1); 778 retval = videobuf_waiton(buf, nonblocking, 1);
676 if (retval < 0) 779 if (retval < 0) {
780 dprintk(1,"dqbuf: waiton returned %d\n",retval);
677 goto done; 781 goto done;
782 }
678 switch (buf->state) { 783 switch (buf->state) {
679 case STATE_ERROR: 784 case STATE_ERROR:
785 dprintk(1,"dqbuf: state is error\n");
680 retval = -EIO; 786 retval = -EIO;
681 /* fall through */ 787 videobuf_dma_sync(q,&buf->dma);
788 buf->state = STATE_IDLE;
789 break;
682 case STATE_DONE: 790 case STATE_DONE:
683 videobuf_dma_pci_sync(q->pci,&buf->dma); 791 dprintk(1,"dqbuf: state is done\n");
792 videobuf_dma_sync(q,&buf->dma);
684 buf->state = STATE_IDLE; 793 buf->state = STATE_IDLE;
685 break; 794 break;
686 default: 795 default:
796 dprintk(1,"dqbuf: state invalid\n");
687 retval = -EINVAL; 797 retval = -EINVAL;
688 goto done; 798 goto done;
689 } 799 }
@@ -711,13 +821,15 @@ int videobuf_streamon(struct videobuf_queue *q)
711 if (q->streaming) 821 if (q->streaming)
712 goto done; 822 goto done;
713 q->streaming = 1; 823 q->streaming = 1;
714 spin_lock_irqsave(q->irqlock,flags); 824 if (q->irqlock)
825 spin_lock_irqsave(q->irqlock,flags);
715 list_for_each(list,&q->stream) { 826 list_for_each(list,&q->stream) {
716 buf = list_entry(list, struct videobuf_buffer, stream); 827 buf = list_entry(list, struct videobuf_buffer, stream);
717 if (buf->state == STATE_PREPARED) 828 if (buf->state == STATE_PREPARED)
718 q->ops->buf_queue(q,buf); 829 q->ops->buf_queue(q,buf);
719 } 830 }
720 spin_unlock_irqrestore(q->irqlock,flags); 831 if (q->irqlock)
832 spin_unlock_irqrestore(q->irqlock,flags);
721 833
722 done: 834 done:
723 mutex_unlock(&q->lock); 835 mutex_unlock(&q->lock);
@@ -762,12 +874,14 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
762 goto done; 874 goto done;
763 875
764 /* start capture & wait */ 876 /* start capture & wait */
765 spin_lock_irqsave(q->irqlock,flags); 877 if (q->irqlock)
878 spin_lock_irqsave(q->irqlock,flags);
766 q->ops->buf_queue(q,q->read_buf); 879 q->ops->buf_queue(q,q->read_buf);
767 spin_unlock_irqrestore(q->irqlock,flags); 880 if (q->irqlock)
881 spin_unlock_irqrestore(q->irqlock,flags);
768 retval = videobuf_waiton(q->read_buf,0,0); 882 retval = videobuf_waiton(q->read_buf,0,0);
769 if (0 == retval) { 883 if (0 == retval) {
770 videobuf_dma_pci_sync(q->pci,&q->read_buf->dma); 884 videobuf_dma_sync(q,&q->read_buf->dma);
771 if (STATE_ERROR == q->read_buf->state) 885 if (STATE_ERROR == q->read_buf->state)
772 retval = -EIO; 886 retval = -EIO;
773 else 887 else
@@ -809,6 +923,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
809 /* need to capture a new frame */ 923 /* need to capture a new frame */
810 retval = -ENOMEM; 924 retval = -ENOMEM;
811 q->read_buf = videobuf_alloc(q->msize); 925 q->read_buf = videobuf_alloc(q->msize);
926 dprintk(1,"video alloc=0x%08x\n",(unsigned int) q->read_buf);
812 if (NULL == q->read_buf) 927 if (NULL == q->read_buf)
813 goto done; 928 goto done;
814 q->read_buf->memory = V4L2_MEMORY_USERPTR; 929 q->read_buf->memory = V4L2_MEMORY_USERPTR;
@@ -820,9 +935,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
820 q->read_buf = NULL; 935 q->read_buf = NULL;
821 goto done; 936 goto done;
822 } 937 }
823 spin_lock_irqsave(q->irqlock,flags); 938 if (q->irqlock)
939 spin_lock_irqsave(q->irqlock,flags);
824 q->ops->buf_queue(q,q->read_buf); 940 q->ops->buf_queue(q,q->read_buf);
825 spin_unlock_irqrestore(q->irqlock,flags); 941 if (q->irqlock)
942 spin_unlock_irqrestore(q->irqlock,flags);
826 q->read_off = 0; 943 q->read_off = 0;
827 } 944 }
828 945
@@ -830,7 +947,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
830 retval = videobuf_waiton(q->read_buf, nonblocking, 1); 947 retval = videobuf_waiton(q->read_buf, nonblocking, 1);
831 if (0 != retval) 948 if (0 != retval)
832 goto done; 949 goto done;
833 videobuf_dma_pci_sync(q->pci,&q->read_buf->dma); 950 videobuf_dma_sync(q,&q->read_buf->dma);
834 951
835 if (STATE_ERROR == q->read_buf->state) { 952 if (STATE_ERROR == q->read_buf->state) {
836 /* catch I/O errors */ 953 /* catch I/O errors */
@@ -887,10 +1004,12 @@ int videobuf_read_start(struct videobuf_queue *q)
887 return err; 1004 return err;
888 list_add_tail(&q->bufs[i]->stream, &q->stream); 1005 list_add_tail(&q->bufs[i]->stream, &q->stream);
889 } 1006 }
890 spin_lock_irqsave(q->irqlock,flags); 1007 if (q->irqlock)
1008 spin_lock_irqsave(q->irqlock,flags);
891 for (i = 0; i < count; i++) 1009 for (i = 0; i < count; i++)
892 q->ops->buf_queue(q,q->bufs[i]); 1010 q->ops->buf_queue(q,q->bufs[i]);
893 spin_unlock_irqrestore(q->irqlock,flags); 1011 if (q->irqlock)
1012 spin_unlock_irqrestore(q->irqlock,flags);
894 q->reading = 1; 1013 q->reading = 1;
895 return 0; 1014 return 0;
896} 1015}
@@ -985,9 +1104,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
985 if (q->read_off == q->read_buf->size) { 1104 if (q->read_off == q->read_buf->size) {
986 list_add_tail(&q->read_buf->stream, 1105 list_add_tail(&q->read_buf->stream,
987 &q->stream); 1106 &q->stream);
988 spin_lock_irqsave(q->irqlock,flags); 1107 if (q->irqlock)
1108 spin_lock_irqsave(q->irqlock,flags);
989 q->ops->buf_queue(q,q->read_buf); 1109 q->ops->buf_queue(q,q->read_buf);
990 spin_unlock_irqrestore(q->irqlock,flags); 1110 if (q->irqlock)
1111 spin_unlock_irqrestore(q->irqlock,flags);
991 q->read_buf = NULL; 1112 q->read_buf = NULL;
992 } 1113 }
993 if (retval < 0) 1114 if (retval < 0)
@@ -1249,11 +1370,14 @@ EXPORT_SYMBOL_GPL(videobuf_dma_init);
1249EXPORT_SYMBOL_GPL(videobuf_dma_init_user); 1370EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
1250EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel); 1371EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
1251EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay); 1372EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay);
1252EXPORT_SYMBOL_GPL(videobuf_dma_pci_map); 1373EXPORT_SYMBOL_GPL(videobuf_dma_map);
1253EXPORT_SYMBOL_GPL(videobuf_dma_pci_sync); 1374EXPORT_SYMBOL_GPL(videobuf_dma_sync);
1254EXPORT_SYMBOL_GPL(videobuf_dma_pci_unmap); 1375EXPORT_SYMBOL_GPL(videobuf_dma_unmap);
1255EXPORT_SYMBOL_GPL(videobuf_dma_free); 1376EXPORT_SYMBOL_GPL(videobuf_dma_free);
1256 1377
1378EXPORT_SYMBOL_GPL(videobuf_pci_dma_map);
1379EXPORT_SYMBOL_GPL(videobuf_pci_dma_unmap);
1380
1257EXPORT_SYMBOL_GPL(videobuf_alloc); 1381EXPORT_SYMBOL_GPL(videobuf_alloc);
1258EXPORT_SYMBOL_GPL(videobuf_waiton); 1382EXPORT_SYMBOL_GPL(videobuf_waiton);
1259EXPORT_SYMBOL_GPL(videobuf_iolock); 1383EXPORT_SYMBOL_GPL(videobuf_iolock);
diff --git a/drivers/media/video/videocodec.h b/drivers/media/video/videocodec.h
index b1239ac7f371..8c233720b6a5 100644
--- a/drivers/media/video/videocodec.h
+++ b/drivers/media/video/videocodec.h
@@ -57,7 +57,7 @@
57 therfor they may not be initialized. 57 therfor they may not be initialized.
58 58
59 The other fuctions are just for convenience, as they are for sure used by 59 The other fuctions are just for convenience, as they are for sure used by
60 most/all of the codecs. The last ones may be ommited, too. 60 most/all of the codecs. The last ones may be ommited, too.
61 61
62 See the structure declaration below for more information and which data has 62 See the structure declaration below for more information and which data has
63 to be set up for the master and the slave. 63 to be set up for the master and the slave.
@@ -75,52 +75,52 @@
75/* ========================================== */ 75/* ========================================== */
76 76
77/* 77/*
78 ==== master setup ==== 78 ==== master setup ====
79 name -> name of the device structure for reference and debugging 79 name -> name of the device structure for reference and debugging
80 master_data -> data ref. for the master (e.g. the zr36055,57,67) 80 master_data -> data ref. for the master (e.g. the zr36055,57,67)
81 readreg -> ref. to read-fn from register (setup by master, used by slave) 81 readreg -> ref. to read-fn from register (setup by master, used by slave)
82 writereg -> ref. to write-fn to register (setup by master, used by slave) 82 writereg -> ref. to write-fn to register (setup by master, used by slave)
83 this two functions do the lowlevel I/O job 83 this two functions do the lowlevel I/O job
84 84
85 ==== slave functionality setup ==== 85 ==== slave functionality setup ====
86 slave_data -> data ref. for the slave (e.g. the zr36050,60) 86 slave_data -> data ref. for the slave (e.g. the zr36050,60)
87 check -> fn-ref. checks availability of an device, returns -EIO on failure or 87 check -> fn-ref. checks availability of an device, returns -EIO on failure or
88 the type on success 88 the type on success
89 this makes espcecially sense if a driver module supports more than 89 this makes espcecially sense if a driver module supports more than
90 one codec which may be quite similar to access, nevertheless it 90 one codec which may be quite similar to access, nevertheless it
91 is good for a first functionality check 91 is good for a first functionality check
92 92
93 -- main functions you always need for compression/decompression -- 93 -- main functions you always need for compression/decompression --
94 94
95 set_mode -> this fn-ref. resets the entire codec, and sets up the mode 95 set_mode -> this fn-ref. resets the entire codec, and sets up the mode
96 with the last defined norm/size (or device default if not 96 with the last defined norm/size (or device default if not
97 available) - it returns 0 if the mode is possible 97 available) - it returns 0 if the mode is possible
98 set_size -> this fn-ref. sets the norm and image size for 98 set_size -> this fn-ref. sets the norm and image size for
99 compression/decompression (returns 0 on success) 99 compression/decompression (returns 0 on success)
100 the norm param is defined in videodev.h (VIDEO_MODE_*) 100 the norm param is defined in videodev.h (VIDEO_MODE_*)
101 101
102 additional setup may be available, too - but the codec should work with 102 additional setup may be available, too - but the codec should work with
103 some default values even without this 103 some default values even without this
104 104
105 set_data -> sets device-specific data (tables, quality etc.) 105 set_data -> sets device-specific data (tables, quality etc.)
106 get_data -> query device-specific data (tables, quality etc.) 106 get_data -> query device-specific data (tables, quality etc.)
107 107
108 if the device delivers interrupts, they may be setup/handled here 108 if the device delivers interrupts, they may be setup/handled here
109 setup_interrupt -> codec irq setup (not needed for 36050/60) 109 setup_interrupt -> codec irq setup (not needed for 36050/60)
110 handle_interrupt -> codec irq handling (not needed for 36050/60) 110 handle_interrupt -> codec irq handling (not needed for 36050/60)
111 111
112 if the device delivers pictures, they may be handled here 112 if the device delivers pictures, they may be handled here
113 put_image -> puts image data to the codec (not needed for 36050/60) 113 put_image -> puts image data to the codec (not needed for 36050/60)
114 get_image -> gets image data from the codec (not needed for 36050/60) 114 get_image -> gets image data from the codec (not needed for 36050/60)
115 the calls include frame numbers and flags (even/odd/...) 115 the calls include frame numbers and flags (even/odd/...)
116 if needed and a flag which allows blocking until its ready 116 if needed and a flag which allows blocking until its ready
117*/ 117*/
118 118
119/* ============== */ 119/* ============== */
120/* user interface */ 120/* user interface */
121/* ============== */ 121/* ============== */
122 122
123/* 123/*
124 Currently there is only a information display planned, as the layer 124 Currently there is only a information display planned, as the layer
125 is not visible for the user space at all. 125 is not visible for the user space at all.
126 126
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 0229819d0aac..a8c101494cf5 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)
1555 unsigned int w = vcs->clipping.right - vcs->clipping.left; 1555 unsigned int w = vcs->clipping.right - vcs->clipping.left;
1556 unsigned int d = vcs->decimation; 1556 unsigned int d = vcs->decimation;
1557 unsigned int bpp = vino_data_formats[vcs->data_format].bpp; 1557 unsigned int bpp = vino_data_formats[vcs->data_format].bpp;
1558 unsigned int lsize; 1558 unsigned int lsize;
1559 1559
1560 dprintk("update_line_size(): before: w = %d, d = %d, " 1560 dprintk("update_line_size(): before: w = %d, d = %d, "
1561 "line_size = %d\n", w, d, vcs->line_size); 1561 "line_size = %d\n", w, d, vcs->line_size);
1562 1562
1563 /* line size must be multiple of 8 bytes */ 1563 /* line size must be multiple of 8 bytes */
1564 lsize = (bpp * (w / d)) & ~7; 1564 lsize = (bpp * (w / d)) & ~7;
1565 w = (lsize / bpp) * d; 1565 w = (lsize / bpp) * d;
1566 1566
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
new file mode 100644
index 000000000000..5e813404d068
--- /dev/null
+++ b/drivers/media/video/vivi.c
@@ -0,0 +1,1454 @@
1/*
2 * Virtual Video driver - This code emulates a real video device with v4l2 api
3 *
4 * Copyright (c) 2006 by:
5 * Mauro Carvalho Chehab <mchehab--a.t--infradead.org>
6 * Ted Walther <ted--a.t--enumera.com>
7 * John Sokol <sokol--a.t--videotechnology.com>
8 * http://v4l.videotechnology.com/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the BSD Licence, GNU General Public License
12 * as published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version
14 */
15#include <linux/module.h>
16#include <linux/delay.h>
17#include <linux/errno.h>
18#include <linux/fs.h>
19#include <linux/kernel.h>
20#include <linux/slab.h>
21#include <linux/mm.h>
22#include <linux/ioport.h>
23#include <linux/init.h>
24#include <linux/sched.h>
25#include <linux/pci.h>
26#include <linux/random.h>
27#include <linux/version.h>
28#include <linux/videodev2.h>
29#include <linux/interrupt.h>
30#include <media/video-buf.h>
31#include <media/v4l2-common.h>
32#include <linux/kthread.h>
33#include <linux/highmem.h>
34
35/* Wake up at about 30 fps */
36#define WAKE_NUMERATOR 30
37#define WAKE_DENOMINATOR 1001
38#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
39
40/* These timers are for 1 fps - used only for testing */
41//#define WAKE_DENOMINATOR 30 /* hack for testing purposes */
42//#define BUFFER_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
43
44#include "font.h"
45
46#ifndef kzalloc
47#define kzalloc(size, flags) \
48({ \
49 void *__ret = kmalloc(size, flags); \
50 if (__ret) \
51 memset(__ret, 0, size); \
52 __ret; \
53})
54#endif
55
56MODULE_DESCRIPTION("Video Technology Magazine Virtual Video Capture Board");
57MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
58MODULE_LICENSE("Dual BSD/GPL");
59
60#define VIVI_MAJOR_VERSION 0
61#define VIVI_MINOR_VERSION 4
62#define VIVI_RELEASE 0
63#define VIVI_VERSION KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
64
65static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
66module_param(video_nr, int, 0);
67
68static int debug = 0;
69module_param(debug, int, 0);
70
71static unsigned int vid_limit = 16;
72module_param(vid_limit,int,0644);
73MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
74
75/* supported controls */
76static struct v4l2_queryctrl vivi_qctrl[] = {
77 {
78 .id = V4L2_CID_AUDIO_VOLUME,
79 .name = "Volume",
80 .minimum = 0,
81 .maximum = 65535,
82 .step = 65535/100,
83 .default_value = 65535,
84 .flags = 0,
85 .type = V4L2_CTRL_TYPE_INTEGER,
86 },{
87 .id = V4L2_CID_BRIGHTNESS,
88 .type = V4L2_CTRL_TYPE_INTEGER,
89 .name = "Brightness",
90 .minimum = 0,
91 .maximum = 255,
92 .step = 1,
93 .default_value = 127,
94 .flags = 0,
95 }, {
96 .id = V4L2_CID_CONTRAST,
97 .type = V4L2_CTRL_TYPE_INTEGER,
98 .name = "Contrast",
99 .minimum = 0,
100 .maximum = 255,
101 .step = 0x1,
102 .default_value = 0x10,
103 .flags = 0,
104 }, {
105 .id = V4L2_CID_SATURATION,
106 .type = V4L2_CTRL_TYPE_INTEGER,
107 .name = "Saturation",
108 .minimum = 0,
109 .maximum = 255,
110 .step = 0x1,
111 .default_value = 127,
112 .flags = 0,
113 }, {
114 .id = V4L2_CID_HUE,
115 .type = V4L2_CTRL_TYPE_INTEGER,
116 .name = "Hue",
117 .minimum = -128,
118 .maximum = 127,
119 .step = 0x1,
120 .default_value = 0,
121 .flags = 0,
122 }
123};
124
125static int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
126
127#define dprintk(level,fmt, arg...) \
128 do { \
129 if (debug >= (level)) \
130 printk(KERN_DEBUG "vivi: " fmt , ## arg); \
131 } while (0)
132
133/* ------------------------------------------------------------------
134 Basic structures
135 ------------------------------------------------------------------*/
136
137struct vivi_fmt {
138 char *name;
139 u32 fourcc; /* v4l2 format id */
140 int depth;
141};
142
143static struct vivi_fmt format = {
144 .name = "4:2:2, packed, YUYV",
145 .fourcc = V4L2_PIX_FMT_YUYV,
146 .depth = 16,
147};
148
149struct sg_to_addr {
150 int pos;
151 struct scatterlist *sg;
152};
153
154/* buffer for one video frame */
155struct vivi_buffer {
156 /* common v4l buffer stuff -- must be first */
157 struct videobuf_buffer vb;
158
159 struct vivi_fmt *fmt;
160
161 struct sg_to_addr *to_addr;
162};
163
164struct vivi_dmaqueue {
165 struct list_head active;
166 struct list_head queued;
167 struct timer_list timeout;
168
169 /* thread for generating video stream*/
170 struct task_struct *kthread;
171 wait_queue_head_t wq;
172 /* Counters to control fps rate */
173 int frame;
174 int ini_jiffies;
175};
176
177static LIST_HEAD(vivi_devlist);
178
179struct vivi_dev {
180 struct list_head vivi_devlist;
181
182 struct semaphore lock;
183
184 int users;
185
186 /* various device info */
187 unsigned int resources;
188 struct video_device video_dev;
189
190 struct vivi_dmaqueue vidq;
191
192 /* Several counters */
193 int h,m,s,us,jiffies;
194 char timestr[13];
195};
196
197struct vivi_fh {
198 struct vivi_dev *dev;
199
200 /* video capture */
201 struct vivi_fmt *fmt;
202 unsigned int width,height;
203 struct videobuf_queue vb_vidq;
204
205 enum v4l2_buf_type type;
206};
207
208/* ------------------------------------------------------------------
209 DMA and thread functions
210 ------------------------------------------------------------------*/
211
212/* Bars and Colors should match positions */
213
214enum colors {
215 WHITE,
216 AMBAR,
217 CYAN,
218 GREEN,
219 MAGENTA,
220 RED,
221 BLUE
222};
223
224static u8 bars[8][3] = {
225 /* R G B */
226 {204,204,204}, /* white */
227 {208,208, 0}, /* ambar */
228 { 0,206,206}, /* cyan */
229 { 0,239, 0}, /* green */
230 {239, 0,239}, /* magenta */
231 {205, 0, 0}, /* red */
232 { 0, 0,255}, /* blue */
233 { 0, 0, 0}
234};
235
236#define TO_Y(r,g,b) (((16829*r +33039*g +6416*b + 32768)>>16)+16)
237/* RGB to V(Cr) Color transform */
238#define TO_V(r,g,b) (((28784*r -24103*g -4681*b + 32768)>>16)+128)
239/* RGB to U(Cb) Color transform */
240#define TO_U(r,g,b) (((-9714*r -19070*g +28784*b + 32768)>>16)+128)
241
242#define TSTAMP_MIN_Y 24
243#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15
244#define TSTAMP_MIN_X 64
245
246void prep_to_addr(struct sg_to_addr to_addr[],struct videobuf_buffer *vb)
247{
248 int i, pos=0;
249
250 for (i=0;i<vb->dma.nr_pages;i++) {
251 to_addr[i].sg=&vb->dma.sglist[i];
252 to_addr[i].pos=pos;
253 pos += vb->dma.sglist[i].length;
254 }
255}
256
257inline int get_addr_pos(int pos, int pages, struct sg_to_addr to_addr[])
258{
259 int p1=0,p2=pages-1,p3=pages/2;
260
261 /* Sanity test */
262 BUG_ON (pos>=to_addr[p2].pos+to_addr[p2].sg->length);
263
264 while (p1+1<p2) {
265 if (pos < to_addr[p3].pos) {
266 p2=p3;
267 } else {
268 p1=p3;
269 }
270 p3=(p1+p2)/2;
271 }
272 if (pos >= to_addr[p2].pos)
273 p1=p2;
274
275 return (p1);
276}
277
278void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
279 int hmax, int line, char *timestr)
280{
281 int w,i,j,pos=inipos,pgpos,oldpg,y;
282 char *p,*s,*basep;
283 struct page *pg;
284 u8 chr,r,g,b,color;
285
286 /* Get first addr pointed to pixel position */
287 oldpg=get_addr_pos(pos,pages,to_addr);
288 pg=pfn_to_page(to_addr[oldpg].sg->dma_address >> PAGE_SHIFT);
289 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
290
291 /* We will just duplicate the second pixel at the packet */
292 wmax/=2;
293
294 /* Generate a standard color bar pattern */
295 for (w=0;w<wmax;w++) {
296 r=bars[w*7/wmax][0];
297 g=bars[w*7/wmax][1];
298 b=bars[w*7/wmax][2];
299
300 for (color=0;color<4;color++) {
301 pgpos=get_addr_pos(pos,pages,to_addr);
302 if (pgpos!=oldpg) {
303 pg=pfn_to_page(to_addr[pgpos].sg->dma_address >> PAGE_SHIFT);
304 kunmap_atomic(basep, KM_BOUNCE_READ);
305 basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
306 oldpg=pgpos;
307 }
308 p=basep+pos-to_addr[pgpos].pos;
309
310 switch (color) {
311 case 0:
312 case 2:
313 *p=TO_Y(r,g,b); /* Luminance */
314 break;
315 case 1:
316 *p=TO_U(r,g,b); /* Cb */
317 break;
318 case 3:
319 *p=TO_V(r,g,b); /* Cr */
320 break;
321 }
322 pos++;
323 }
324 }
325
326 /* Checks if it is possible to show timestamp */
327 if (TSTAMP_MAX_Y>=hmax)
328 goto end;
329 if (TSTAMP_MIN_X+strlen(timestr)>=wmax)
330 goto end;
331
332 /* Print stream time */
333 if (line>=TSTAMP_MIN_Y && line<=TSTAMP_MAX_Y) {
334 j=TSTAMP_MIN_X;
335 for (s=timestr;*s;s++) {
336 chr=rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y];
337 for (i=0;i<7;i++) {
338 if (chr&1<<(7-i)) { /* Font color*/
339 r=bars[BLUE][0];
340 g=bars[BLUE][1];
341 b=bars[BLUE][2];
342 r=g=b=0;
343 g=198;
344 } else { /* Background color */
345 r=bars[WHITE][0];
346 g=bars[WHITE][1];
347 b=bars[WHITE][2];
348 r=g=b=0;
349 }
350
351 pos=inipos+j*2;
352 for (color=0;color<4;color++) {
353 pgpos=get_addr_pos(pos,pages,to_addr);
354 if (pgpos!=oldpg) {
355 pg=pfn_to_page(to_addr[pgpos].
356 sg->dma_address
357 >> PAGE_SHIFT);
358 kunmap_atomic(basep,
359 KM_BOUNCE_READ);
360 basep= kmap_atomic(pg,
361 KM_BOUNCE_READ)+
362 to_addr[pgpos].sg->offset;
363 oldpg=pgpos;
364 }
365 p=basep+pos-to_addr[pgpos].pos;
366
367 y=TO_Y(r,g,b);
368
369 switch (color) {
370 case 0:
371 case 2:
372 *p=TO_Y(r,g,b); /* Luminance */
373 break;
374 case 1:
375 *p=TO_U(r,g,b); /* Cb */
376 break;
377 case 3:
378 *p=TO_V(r,g,b); /* Cr */
379 break;
380 }
381 pos++;
382 }
383 j++;
384 }
385 }
386 }
387
388
389end:
390 kunmap_atomic(basep, KM_BOUNCE_READ);
391}
392static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
393{
394 int h,pos=0;
395 int hmax = buf->vb.height;
396 int wmax = buf->vb.width;
397 struct videobuf_buffer *vb=&buf->vb;
398 struct sg_to_addr *to_addr=buf->to_addr;
399 struct timeval ts;
400
401 /* Test if DMA mapping is ready */
402 if (!vb->dma.sglist[0].dma_address)
403 return;
404
405 prep_to_addr(to_addr,vb);
406
407 /* Check if there is enough memory */
408 BUG_ON(buf->vb.dma.nr_pages << PAGE_SHIFT < (buf->vb.width*buf->vb.height)*2);
409
410 for (h=0;h<hmax;h++) {
411 gen_line(to_addr,pos,vb->dma.nr_pages,wmax,hmax,h,dev->timestr);
412 pos += wmax*2;
413 }
414
415 /* Updates stream time */
416
417 dev->us+=jiffies_to_usecs(jiffies-dev->jiffies);
418 dev->jiffies=jiffies;
419 if (dev->us>=1000000) {
420 dev->us-=1000000;
421 dev->s++;
422 if (dev->s>=60) {
423 dev->s-=60;
424 dev->m++;
425 if (dev->m>60) {
426 dev->m-=60;
427 dev->h++;
428 if (dev->h>24)
429 dev->h-=24;
430 }
431 }
432 }
433 sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
434 dev->h,dev->m,dev->s,(dev->us+500)/1000);
435
436 dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
437 (unsigned long)buf->vb.dma.vmalloc,pos);
438
439 /* Advice that buffer was filled */
440 buf->vb.state = STATE_DONE;
441 buf->vb.field_count++;
442 do_gettimeofday(&ts);
443 buf->vb.ts = ts;
444
445 list_del(&buf->vb.queue);
446 wake_up(&buf->vb.done);
447}
448
449static int restart_video_queue(struct vivi_dmaqueue *dma_q);
450
451static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
452{
453 struct vivi_buffer *buf;
454 struct vivi_dev *dev= container_of(dma_q,struct vivi_dev,vidq);
455
456 int bc;
457
458 /* Announces videobuf that all went ok */
459 for (bc = 0;; bc++) {
460 if (list_empty(&dma_q->active)) {
461 dprintk(1,"No active queue to serve\n");
462 break;
463 }
464
465 buf = list_entry(dma_q->active.next,
466 struct vivi_buffer, vb.queue);
467
468 /* Nobody is waiting something to be done, just return */
469 if (!waitqueue_active(&buf->vb.done)) {
470 mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
471 return;
472 }
473
474 do_gettimeofday(&buf->vb.ts);
475 dprintk(2,"[%p/%d] wakeup\n",buf,buf->vb.i);
476
477 /* Fill buffer */
478 vivi_fillbuff(dev,buf);
479 }
480 if (list_empty(&dma_q->active)) {
481 del_timer(&dma_q->timeout);
482 } else {
483 mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
484 }
485 if (bc != 1)
486 dprintk(1,"%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc);
487}
488
489void vivi_sleep(struct vivi_dmaqueue *dma_q)
490{
491 int timeout;
492 DECLARE_WAITQUEUE(wait, current);
493
494 dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
495
496 add_wait_queue(&dma_q->wq, &wait);
497 if (!kthread_should_stop()) {
498 dma_q->frame++;
499
500 /* Calculate time to wake up */
501 timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
502
503 if (timeout <= 0) {
504 int old=dma_q->frame;
505 dma_q->frame=(jiffies_to_msecs(jiffies-dma_q->ini_jiffies)*WAKE_DENOMINATOR)/(WAKE_NUMERATOR*1000)+1;
506
507 timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
508
509 dprintk(1,"underrun, losed %d frames. "
510 "Now, frame is %d. Waking on %d jiffies\n",
511 dma_q->frame-old,dma_q->frame,timeout);
512 } else
513 dprintk(1,"will sleep for %i jiffies\n",timeout);
514
515 vivi_thread_tick(dma_q);
516
517 schedule_timeout_interruptible (timeout);
518 }
519
520 remove_wait_queue(&dma_q->wq, &wait);
521 try_to_freeze();
522}
523
524int vivi_thread(void *data)
525{
526 struct vivi_dmaqueue *dma_q=data;
527
528 dprintk(1,"thread started\n");
529
530 for (;;) {
531 vivi_sleep(dma_q);
532
533 if (kthread_should_stop())
534 break;
535 }
536 dprintk(1, "thread: exit\n");
537 return 0;
538}
539
540int vivi_start_thread(struct vivi_dmaqueue *dma_q)
541{
542 dma_q->frame=0;
543 dma_q->ini_jiffies=jiffies;
544
545 dprintk(1,"%s\n",__FUNCTION__);
546 init_waitqueue_head(&dma_q->wq);
547
548 dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
549
550 if (dma_q->kthread == NULL) {
551 printk(KERN_ERR "vivi: kernel_thread() failed\n");
552 return -EINVAL;
553 }
554 dprintk(1,"returning from %s\n",__FUNCTION__);
555 return 0;
556}
557
558void vivi_stop_thread(struct vivi_dmaqueue *dma_q)
559{
560 dprintk(1,"%s\n",__FUNCTION__);
561 /* shutdown control thread */
562 if (dma_q->kthread) {
563 kthread_stop(dma_q->kthread);
564 dma_q->kthread=NULL;
565 }
566}
567
568static int restart_video_queue(struct vivi_dmaqueue *dma_q)
569{
570 struct vivi_buffer *buf, *prev;
571 struct list_head *item;
572
573 dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
574
575 if (!list_empty(&dma_q->active)) {
576 buf = list_entry(dma_q->active.next, struct vivi_buffer, vb.queue);
577 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
578 buf, buf->vb.i);
579
580 dprintk(1,"Restarting video dma\n");
581 vivi_stop_thread(dma_q);
582// vivi_start_thread(dma_q);
583
584 /* cancel all outstanding capture / vbi requests */
585 list_for_each(item,&dma_q->active) {
586 buf = list_entry(item, struct vivi_buffer, vb.queue);
587
588 list_del(&buf->vb.queue);
589 buf->vb.state = STATE_ERROR;
590 wake_up(&buf->vb.done);
591 }
592 mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
593
594 return 0;
595 }
596
597 prev = NULL;
598 for (;;) {
599 if (list_empty(&dma_q->queued))
600 return 0;
601 buf = list_entry(dma_q->queued.next, struct vivi_buffer, vb.queue);
602 if (NULL == prev) {
603 list_del(&buf->vb.queue);
604 list_add_tail(&buf->vb.queue,&dma_q->active);
605
606 dprintk(1,"Restarting video dma\n");
607 vivi_stop_thread(dma_q);
608 vivi_start_thread(dma_q);
609
610 buf->vb.state = STATE_ACTIVE;
611 mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
612 dprintk(2,"[%p/%d] restart_queue - first active\n",
613 buf,buf->vb.i);
614
615 } else if (prev->vb.width == buf->vb.width &&
616 prev->vb.height == buf->vb.height &&
617 prev->fmt == buf->fmt) {
618 list_del(&buf->vb.queue);
619 list_add_tail(&buf->vb.queue,&dma_q->active);
620 buf->vb.state = STATE_ACTIVE;
621 dprintk(2,"[%p/%d] restart_queue - move to active\n",
622 buf,buf->vb.i);
623 } else {
624 return 0;
625 }
626 prev = buf;
627 }
628}
629
630static void vivi_vid_timeout(unsigned long data)
631{
632 struct vivi_dev *dev = (struct vivi_dev*)data;
633 struct vivi_dmaqueue *vidq = &dev->vidq;
634 struct vivi_buffer *buf;
635
636 while (!list_empty(&vidq->active)) {
637 buf = list_entry(vidq->active.next, struct vivi_buffer, vb.queue);
638 list_del(&buf->vb.queue);
639 buf->vb.state = STATE_ERROR;
640 wake_up(&buf->vb.done);
641 printk("vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
642 }
643
644 restart_video_queue(vidq);
645}
646
647/* ------------------------------------------------------------------
648 Videobuf operations
649 ------------------------------------------------------------------*/
650static int
651buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
652{
653 struct vivi_fh *fh = vq->priv_data;
654
655 *size = fh->width*fh->height*2;
656
657 if (0 == *count)
658 *count = 32;
659 while (*size * *count > vid_limit * 1024 * 1024)
660 (*count)--;
661 return 0;
662}
663
664void
665free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
666{
667 dprintk(1,"%s\n",__FUNCTION__);
668
669 if (in_interrupt())
670 BUG();
671
672 /*FIXME: Maybe a spinlock is required here */
673 kfree(buf->to_addr);
674 buf->to_addr=NULL;
675
676 videobuf_waiton(&buf->vb,0,0);
677 videobuf_dma_unmap(vq, &buf->vb.dma);
678 videobuf_dma_free(&buf->vb.dma);
679 buf->vb.state = STATE_NEEDS_INIT;
680}
681
682#define norm_maxw() 1024
683#define norm_maxh() 768
684static int
685buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
686 enum v4l2_field field)
687{
688 struct vivi_fh *fh = vq->priv_data;
689 struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
690 int rc, init_buffer = 0;
691
692// dprintk(1,"%s, field=%d\n",__FUNCTION__,field);
693
694 BUG_ON(NULL == fh->fmt);
695 if (fh->width < 48 || fh->width > norm_maxw() ||
696 fh->height < 32 || fh->height > norm_maxh())
697 return -EINVAL;
698 buf->vb.size = fh->width*fh->height*2;
699 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
700 return -EINVAL;
701
702 if (buf->fmt != fh->fmt ||
703 buf->vb.width != fh->width ||
704 buf->vb.height != fh->height ||
705 buf->vb.field != field) {
706 buf->fmt = fh->fmt;
707 buf->vb.width = fh->width;
708 buf->vb.height = fh->height;
709 buf->vb.field = field;
710 init_buffer = 1;
711 }
712
713 if (STATE_NEEDS_INIT == buf->vb.state) {
714 if (0 != (rc = videobuf_iolock(vq,&buf->vb,NULL)))
715 goto fail;
716 }
717
718 buf->vb.state = STATE_PREPARED;
719
720 if (NULL == (buf->to_addr = kmalloc(sizeof(*buf->to_addr) * vb->dma.nr_pages,GFP_KERNEL))) {
721 rc=-ENOMEM;
722 goto fail;
723 }
724
725 return 0;
726
727fail:
728 free_buffer(vq,buf);
729 return rc;
730}
731
732static void
733buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
734{
735 struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
736 struct vivi_fh *fh = vq->priv_data;
737 struct vivi_dev *dev = fh->dev;
738 struct vivi_dmaqueue *vidq = &dev->vidq;
739 struct vivi_buffer *prev;
740
741 if (!list_empty(&vidq->queued)) {
742 dprintk(1,"adding vb queue=0x%08lx\n",(unsigned long)&buf->vb.queue);
743 list_add_tail(&buf->vb.queue,&vidq->queued);
744 buf->vb.state = STATE_QUEUED;
745 dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
746 buf, buf->vb.i);
747 } else if (list_empty(&vidq->active)) {
748 list_add_tail(&buf->vb.queue,&vidq->active);
749
750 buf->vb.state = STATE_ACTIVE;
751 mod_timer(&vidq->timeout, jiffies+BUFFER_TIMEOUT);
752 dprintk(2,"[%p/%d] buffer_queue - first active\n",
753 buf, buf->vb.i);
754
755 vivi_start_thread(vidq);
756 } else {
757 prev = list_entry(vidq->active.prev, struct vivi_buffer, vb.queue);
758 if (prev->vb.width == buf->vb.width &&
759 prev->vb.height == buf->vb.height &&
760 prev->fmt == buf->fmt) {
761 list_add_tail(&buf->vb.queue,&vidq->active);
762 buf->vb.state = STATE_ACTIVE;
763 dprintk(2,"[%p/%d] buffer_queue - append to active\n",
764 buf, buf->vb.i);
765
766 } else {
767 list_add_tail(&buf->vb.queue,&vidq->queued);
768 buf->vb.state = STATE_QUEUED;
769 dprintk(2,"[%p/%d] buffer_queue - first queued\n",
770 buf, buf->vb.i);
771 }
772 }
773}
774
775static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb)
776{
777 struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
778 struct vivi_fh *fh = vq->priv_data;
779 struct vivi_dev *dev = (struct vivi_dev*)fh->dev;
780 struct vivi_dmaqueue *vidq = &dev->vidq;
781
782 dprintk(1,"%s\n",__FUNCTION__);
783
784 vivi_stop_thread(vidq);
785
786 free_buffer(vq,buf);
787}
788
789int vivi_map_sg (void *dev, struct scatterlist *sg, int nents,
790 int direction)
791{
792 int i;
793
794 dprintk(1,"%s, number of pages=%d\n",__FUNCTION__,nents);
795 BUG_ON(direction == DMA_NONE);
796
797 for (i = 0; i < nents; i++ ) {
798 BUG_ON(!sg[i].page);
799
800 sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset;
801 }
802
803 return nents;
804}
805
806int vivi_unmap_sg(void *dev,struct scatterlist *sglist,int nr_pages,
807 int direction)
808{
809 dprintk(1,"%s\n",__FUNCTION__);
810 return 0;
811}
812
813int vivi_dma_sync_sg(void *dev,struct scatterlist *sglist,int nr_pages,
814 int direction)
815{
816// dprintk(1,"%s\n",__FUNCTION__);
817
818// flush_write_buffers();
819 return 0;
820}
821
822static struct videobuf_queue_ops vivi_video_qops = {
823 .buf_setup = buffer_setup,
824 .buf_prepare = buffer_prepare,
825 .buf_queue = buffer_queue,
826 .buf_release = buffer_release,
827
828 /* Non-pci handling routines */
829 .vb_map_sg = vivi_map_sg,
830 .vb_dma_sync_sg = vivi_dma_sync_sg,
831 .vb_unmap_sg = vivi_unmap_sg,
832};
833
834/* ------------------------------------------------------------------
835 IOCTL handling
836 ------------------------------------------------------------------*/
837
838static int vivi_try_fmt(struct vivi_dev *dev, struct vivi_fh *fh,
839 struct v4l2_format *f)
840{
841 struct vivi_fmt *fmt;
842 enum v4l2_field field;
843 unsigned int maxw, maxh;
844
845 if (format.fourcc != f->fmt.pix.pixelformat) {
846 dprintk(1,"Fourcc format invalid.\n");
847 return -EINVAL;
848 }
849 fmt=&format;
850
851 field = f->fmt.pix.field;
852
853 if (field == V4L2_FIELD_ANY) {
854// field=V4L2_FIELD_INTERLACED;
855 field=V4L2_FIELD_SEQ_TB;
856 } else if (V4L2_FIELD_INTERLACED != field) {
857 dprintk(1,"Field type invalid.\n");
858 return -EINVAL;
859 }
860
861 maxw = norm_maxw();
862 maxh = norm_maxh();
863
864 f->fmt.pix.field = field;
865 if (f->fmt.pix.height < 32)
866 f->fmt.pix.height = 32;
867 if (f->fmt.pix.height > maxh)
868 f->fmt.pix.height = maxh;
869 if (f->fmt.pix.width < 48)
870 f->fmt.pix.width = 48;
871 if (f->fmt.pix.width > maxw)
872 f->fmt.pix.width = maxw;
873 f->fmt.pix.width &= ~0x03;
874 f->fmt.pix.bytesperline =
875 (f->fmt.pix.width * fmt->depth) >> 3;
876 f->fmt.pix.sizeimage =
877 f->fmt.pix.height * f->fmt.pix.bytesperline;
878
879 return 0;
880}
881
882static int res_get(struct vivi_dev *dev, struct vivi_fh *fh)
883{
884 /* is it free? */
885 down(&dev->lock);
886 if (dev->resources) {
887 /* no, someone else uses it */
888 up(&dev->lock);
889 return 0;
890 }
891 /* it's free, grab it */
892 dev->resources =1;
893 dprintk(1,"res: get\n");
894 up(&dev->lock);
895 return 1;
896}
897
898static inline int res_locked(struct vivi_dev *dev)
899{
900 return (dev->resources);
901}
902
903static void res_free(struct vivi_dev *dev, struct vivi_fh *fh)
904{
905 down(&dev->lock);
906 dev->resources = 0;
907 dprintk(1,"res: put\n");
908 up(&dev->lock);
909}
910
911static int vivi_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg)
912{
913 struct vivi_fh *fh = file->private_data;
914 struct vivi_dev *dev = fh->dev;
915 int ret=0;
916
917 if (debug) {
918 if (_IOC_DIR(cmd) & _IOC_WRITE)
919 v4l_printk_ioctl_arg("vivi(w)",cmd, arg);
920 else if (!_IOC_DIR(cmd) & _IOC_READ) {
921 v4l_print_ioctl("vivi", cmd);
922 }
923 }
924
925 switch(cmd) {
926 /* --- capabilities ------------------------------------------ */
927 case VIDIOC_QUERYCAP:
928 {
929 struct v4l2_capability *cap = (struct v4l2_capability*)arg;
930
931 memset(cap, 0, sizeof(*cap));
932
933 strcpy(cap->driver, "vivi");
934 strcpy(cap->card, "vivi");
935 cap->version = VIVI_VERSION;
936 cap->capabilities =
937 V4L2_CAP_VIDEO_CAPTURE |
938 V4L2_CAP_STREAMING |
939 V4L2_CAP_READWRITE;
940 break;
941 }
942 /* --- capture ioctls ---------------------------------------- */
943 case VIDIOC_ENUM_FMT:
944 {
945 struct v4l2_fmtdesc *f = arg;
946 enum v4l2_buf_type type;
947 unsigned int index;
948
949 index = f->index;
950 type = f->type;
951
952 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
953 ret=-EINVAL;
954 break;
955 }
956
957 switch (type) {
958 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
959 if (index > 0){
960 ret=-EINVAL;
961 break;
962 }
963 memset(f,0,sizeof(*f));
964
965 f->index = index;
966 f->type = type;
967 strlcpy(f->description,format.name,sizeof(f->description));
968 f->pixelformat = format.fourcc;
969 break;
970 default:
971 ret=-EINVAL;
972 }
973 break;
974 }
975 case VIDIOC_G_FMT:
976 {
977 struct v4l2_format *f = (struct v4l2_format *)arg;
978
979 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
980 ret=-EINVAL;
981 break;
982 }
983
984 memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
985 f->fmt.pix.width = fh->width;
986 f->fmt.pix.height = fh->height;
987 f->fmt.pix.field = fh->vb_vidq.field;
988 f->fmt.pix.pixelformat = fh->fmt->fourcc;
989 f->fmt.pix.bytesperline =
990 (f->fmt.pix.width * fh->fmt->depth) >> 3;
991 f->fmt.pix.sizeimage =
992 f->fmt.pix.height * f->fmt.pix.bytesperline;
993 break;
994 }
995 case VIDIOC_S_FMT:
996 {
997 struct v4l2_format *f = arg;
998
999 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1000 dprintk(1,"Only capture supported.\n");
1001 ret=-EINVAL;
1002 break;
1003 }
1004
1005 ret = vivi_try_fmt(dev,fh,f);
1006 if (ret < 0)
1007 break;
1008
1009 fh->fmt = &format;
1010 fh->width = f->fmt.pix.width;
1011 fh->height = f->fmt.pix.height;
1012 fh->vb_vidq.field = f->fmt.pix.field;
1013 fh->type = f->type;
1014
1015 break;
1016 }
1017 case VIDIOC_TRY_FMT:
1018 {
1019 struct v4l2_format *f = arg;
1020 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1021 ret=-EINVAL;
1022 break;
1023 }
1024
1025 ret=vivi_try_fmt(dev,fh,f);
1026 break;
1027 }
1028 case VIDIOC_REQBUFS:
1029 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1030 ret=-EINVAL;
1031 break;
1032 }
1033 ret=videobuf_reqbufs(&fh->vb_vidq, arg);
1034 break;
1035 case VIDIOC_QUERYBUF:
1036 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1037 ret=-EINVAL;
1038 break;
1039 }
1040 ret=videobuf_querybuf(&fh->vb_vidq, arg);
1041 break;
1042 case VIDIOC_QBUF:
1043 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1044 ret=-EINVAL;
1045 break;
1046 }
1047 ret=videobuf_qbuf(&fh->vb_vidq, arg);
1048 break;
1049 case VIDIOC_DQBUF:
1050 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1051 ret=-EINVAL;
1052 break;
1053 }
1054 ret=videobuf_dqbuf(&fh->vb_vidq, arg,
1055 file->f_flags & O_NONBLOCK);
1056 break;
1057#ifdef HAVE_V4L1
1058 /* --- streaming capture ------------------------------------- */
1059 case VIDIOCGMBUF:
1060 {
1061 struct video_mbuf *mbuf = arg;
1062 struct videobuf_queue *q=&fh->vb_vidq;
1063 struct v4l2_requestbuffers req;
1064 unsigned int i;
1065
1066 memset(&req,0,sizeof(req));
1067 req.type = q->type;
1068 req.count = 8;
1069 req.memory = V4L2_MEMORY_MMAP;
1070 ret = videobuf_reqbufs(q,&req);
1071 if (ret < 0)
1072 break;
1073 memset(mbuf,0,sizeof(*mbuf));
1074 mbuf->frames = req.count;
1075 mbuf->size = 0;
1076 for (i = 0; i < mbuf->frames; i++) {
1077 mbuf->offsets[i] = q->bufs[i]->boff;
1078 mbuf->size += q->bufs[i]->bsize;
1079 }
1080 break;
1081 }
1082#endif
1083 case VIDIOC_STREAMON:
1084 {
1085 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1086 return -EINVAL;
1087 if (!res_get(dev,fh))
1088 return -EBUSY;
1089 ret=videobuf_streamon(&fh->vb_vidq);
1090 break;
1091 }
1092 case VIDIOC_STREAMOFF:
1093 {
1094 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1095 ret=-EINVAL;
1096 break;
1097 }
1098 ret = videobuf_streamoff(&fh->vb_vidq);
1099 if (ret < 0)
1100 break;
1101 res_free(dev,fh);
1102 break;
1103 }
1104 /* ---------- tv norms ---------- */
1105 case VIDIOC_ENUMSTD:
1106 {
1107 struct v4l2_standard *e = arg;
1108
1109 if (e->index>0) {
1110 ret=-EINVAL;
1111 break;
1112 }
1113 ret = v4l2_video_std_construct(e, V4L2_STD_NTSC_M, "NTSC-M");
1114
1115 /* Allows vivi to use different fps from video std */
1116 e->frameperiod.numerator = WAKE_NUMERATOR;
1117 e->frameperiod.denominator = WAKE_DENOMINATOR;
1118
1119 break;
1120 }
1121 case VIDIOC_G_STD:
1122 {
1123 v4l2_std_id *id = arg;
1124
1125 *id = V4L2_STD_NTSC_M;
1126 break;
1127 }
1128 case VIDIOC_S_STD:
1129 {
1130 break;
1131 }
1132 /* ------ input switching ---------- */
1133 case VIDIOC_ENUMINPUT:
1134 { /* only one input in this sample driver */
1135 struct v4l2_input *inp = arg;
1136
1137 if (inp->index != 0) {
1138 ret=-EINVAL;
1139 break;
1140 }
1141 memset(inp, 0, sizeof(*inp));
1142
1143 inp->index = 0;
1144 inp->type = V4L2_INPUT_TYPE_CAMERA;
1145 inp->std = V4L2_STD_NTSC_M;
1146 strcpy(inp->name,"Camera");
1147 break;
1148 }
1149 case VIDIOC_G_INPUT:
1150 {
1151 unsigned int *i = arg;
1152
1153 *i = 0;
1154 break;
1155 }
1156 case VIDIOC_S_INPUT:
1157 {
1158 unsigned int *i = arg;
1159
1160 if (*i > 0)
1161 ret=-EINVAL;
1162 break;
1163 }
1164
1165 /* --- controls ---------------------------------------------- */
1166 case VIDIOC_QUERYCTRL:
1167 {
1168 struct v4l2_queryctrl *qc = arg;
1169 int i;
1170
1171 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1172 if (qc->id && qc->id == vivi_qctrl[i].id) {
1173 memcpy(qc, &(vivi_qctrl[i]),
1174 sizeof(*qc));
1175 break;
1176 }
1177
1178 ret=-EINVAL;
1179 break;
1180 }
1181 case VIDIOC_G_CTRL:
1182 {
1183 struct v4l2_control *ctrl = arg;
1184 int i;
1185
1186 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1187 if (ctrl->id == vivi_qctrl[i].id) {
1188 ctrl->value=qctl_regs[i];
1189 break;
1190 }
1191
1192 ret=-EINVAL;
1193 break;
1194 }
1195 case VIDIOC_S_CTRL:
1196 {
1197 struct v4l2_control *ctrl = arg;
1198 int i;
1199 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1200 if (ctrl->id == vivi_qctrl[i].id) {
1201 if (ctrl->value <
1202 vivi_qctrl[i].minimum
1203 || ctrl->value >
1204 vivi_qctrl[i].maximum) {
1205 ret=-ERANGE;
1206 break;
1207 }
1208 qctl_regs[i]=ctrl->value;
1209 break;
1210 }
1211 ret=-EINVAL;
1212 break;
1213 }
1214 default:
1215 ret=v4l_compat_translate_ioctl(inode,file,cmd,arg,vivi_do_ioctl);
1216 }
1217
1218 if (debug) {
1219 if (ret<0) {
1220 v4l_print_ioctl("vivi(err)", cmd);
1221 dprintk(1,"errcode=%d\n",ret);
1222 } else if (_IOC_DIR(cmd) & _IOC_READ)
1223 v4l_printk_ioctl_arg("vivi(r)",cmd, arg);
1224 }
1225
1226 return ret;
1227}
1228
1229static int vivi_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
1230{
1231 return video_usercopy(inode, file, cmd, arg, vivi_do_ioctl);
1232}
1233
1234/* ------------------------------------------------------------------
1235 File operations for the device
1236 ------------------------------------------------------------------*/
1237
1238#define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8)
1239
1240static int vivi_open(struct inode *inode, struct file *file)
1241{
1242 int minor = iminor(inode);
1243 struct vivi_dev *h,*dev = NULL;
1244 struct vivi_fh *fh;
1245 struct list_head *list;
1246 enum v4l2_buf_type type = 0;
1247 int i;
1248
1249 printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
1250
1251 list_for_each(list,&vivi_devlist) {
1252 h = list_entry(list, struct vivi_dev, vivi_devlist);
1253 if (h->video_dev.minor == minor) {
1254 dev = h;
1255 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1256 }
1257 }
1258 if (NULL == dev)
1259 return -ENODEV;
1260
1261
1262 /* If more than one user, mutex should be added */
1263 dev->users++;
1264
1265 dprintk(1,"open minor=%d type=%s users=%d\n",
1266 minor,v4l2_type_names[type],dev->users);
1267
1268 /* allocate + initialize per filehandle data */
1269 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
1270 if (NULL == fh) {
1271 dev->users--;
1272 return -ENOMEM;
1273 }
1274
1275 file->private_data = fh;
1276 fh->dev = dev;
1277 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1278 fh->fmt = &format;
1279 fh->width = 640;
1280 fh->height = 480;
1281
1282 /* Put all controls at a sane state */
1283 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1284 qctl_regs[i] =vivi_qctrl[i].default_value;
1285
1286 dprintk(1,"Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
1287 (unsigned long)fh,(unsigned long)dev,(unsigned long)&dev->vidq);
1288 dprintk(1,"Open: list_empty queued=%d\n",list_empty(&dev->vidq.queued));
1289 dprintk(1,"Open: list_empty active=%d\n",list_empty(&dev->vidq.active));
1290
1291 /* Resets frame counters */
1292 dev->h=0;
1293 dev->m=0;
1294 dev->s=0;
1295 dev->us=0;
1296 dev->jiffies=jiffies;
1297 sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
1298 dev->h,dev->m,dev->s,(dev->us+500)/1000);
1299
1300 videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops,
1301 NULL, NULL,
1302 fh->type,
1303 V4L2_FIELD_INTERLACED,
1304 sizeof(struct vivi_buffer),fh);
1305
1306 return 0;
1307}
1308
1309static ssize_t
1310vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1311{
1312 struct vivi_fh *fh = file->private_data;
1313
1314 if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1315 if (res_locked(fh->dev))
1316 return -EBUSY;
1317 return videobuf_read_one(&fh->vb_vidq, data, count, ppos,
1318 file->f_flags & O_NONBLOCK);
1319 }
1320 return 0;
1321}
1322
1323static unsigned int
1324vivi_poll(struct file *file, struct poll_table_struct *wait)
1325{
1326 struct vivi_fh *fh = file->private_data;
1327 struct vivi_buffer *buf;
1328
1329 dprintk(1,"%s\n",__FUNCTION__);
1330
1331 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
1332 return POLLERR;
1333
1334 if (res_get(fh->dev,fh)) {
1335 dprintk(1,"poll: mmap interface\n");
1336 /* streaming capture */
1337 if (list_empty(&fh->vb_vidq.stream))
1338 return POLLERR;
1339 buf = list_entry(fh->vb_vidq.stream.next,struct vivi_buffer,vb.stream);
1340 } else {
1341 dprintk(1,"poll: read() interface\n");
1342 /* read() capture */
1343 buf = (struct vivi_buffer*)fh->vb_vidq.read_buf;
1344 if (NULL == buf)
1345 return POLLERR;
1346 }
1347 poll_wait(file, &buf->vb.done, wait);
1348 if (buf->vb.state == STATE_DONE ||
1349 buf->vb.state == STATE_ERROR)
1350 return POLLIN|POLLRDNORM;
1351 return 0;
1352}
1353
1354static int vivi_release(struct inode *inode, struct file *file)
1355{
1356 struct vivi_fh *fh = file->private_data;
1357 struct vivi_dev *dev = fh->dev;
1358 struct vivi_dmaqueue *vidq = &dev->vidq;
1359
1360 int minor = iminor(inode);
1361
1362 vivi_stop_thread(vidq);
1363 videobuf_mmap_free(&fh->vb_vidq);
1364
1365 kfree (fh);
1366
1367 dev->users--;
1368
1369 printk(KERN_DEBUG "vivi: close called (minor=%d, users=%d)\n",minor,dev->users);
1370
1371 return 0;
1372}
1373
1374static int
1375vivi_mmap(struct file *file, struct vm_area_struct * vma)
1376{
1377 struct vivi_fh *fh = file->private_data;
1378 int ret;
1379
1380 dprintk (1,"mmap called, vma=0x%08lx\n",(unsigned long)vma);
1381
1382 ret=videobuf_mmap_mapper(&fh->vb_vidq, vma);
1383
1384 dprintk (1,"vma start=0x%08lx, size=%ld, ret=%d\n",
1385 (unsigned long)vma->vm_start,
1386 (unsigned long)vma->vm_end-(unsigned long)vma->vm_start,
1387 ret);
1388
1389 return ret;
1390}
1391
1392static struct file_operations vivi_fops = {
1393 .owner = THIS_MODULE,
1394 .open = vivi_open,
1395 .release = vivi_release,
1396 .read = vivi_read,
1397 .poll = vivi_poll,
1398 .ioctl = vivi_ioctl,
1399 .mmap = vivi_mmap,
1400 .llseek = no_llseek,
1401};
1402
1403static struct video_device vivi = {
1404 .name = "VTM Virtual Video Capture Board",
1405 .type = VID_TYPE_CAPTURE,
1406 .hardware = 0,
1407 .fops = &vivi_fops,
1408 .minor = -1,
1409// .release = video_device_release,
1410};
1411/* ------------------------------------------------------------------
1412 Initialization and module stuff
1413 ------------------------------------------------------------------*/
1414
1415static int __init vivi_init(void)
1416{
1417 int ret;
1418 struct vivi_dev *dev;
1419
1420 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
1421 if (NULL == dev)
1422 return -ENOMEM;
1423 list_add_tail(&dev->vivi_devlist,&vivi_devlist);
1424
1425 /* init video dma queues */
1426 INIT_LIST_HEAD(&dev->vidq.active);
1427 INIT_LIST_HEAD(&dev->vidq.queued);
1428
1429 /* initialize locks */
1430 init_MUTEX(&dev->lock);
1431
1432 dev->vidq.timeout.function = vivi_vid_timeout;
1433 dev->vidq.timeout.data = (unsigned long)dev;
1434 init_timer(&dev->vidq.timeout);
1435
1436 ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr);
1437 printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret);
1438 return ret;
1439}
1440
1441static void __exit vivi_exit(void)
1442{
1443 struct vivi_dev *h;
1444 struct list_head *list;
1445
1446 list_for_each(list,&vivi_devlist) {
1447 h = list_entry(list, struct vivi_dev, vivi_devlist);
1448 kfree (h);
1449 }
1450 video_unregister_device(&vivi);
1451}
1452
1453module_init(vivi_init);
1454module_exit(vivi_exit);
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 4cd579967487..40b205b91481 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * vpx3220a, vpx3216b & vpx3214c video decoder driver version 0.0.1 2 * vpx3220a, vpx3216b & vpx3214c video decoder driver version 0.0.1
3 * 3 *
4 * Copyright (C) 2001 Laurent Pinchart <lpinchart@freegates.be> 4 * Copyright (C) 2001 Laurent Pinchart <lpinchart@freegates.be>
@@ -176,8 +176,8 @@ vpx3220_write_block (struct i2c_client *client,
176 176
177static int 177static int
178vpx3220_write_fp_block (struct i2c_client *client, 178vpx3220_write_fp_block (struct i2c_client *client,
179 const u16 *data, 179 const u16 *data,
180 unsigned int len) 180 unsigned int len)
181{ 181{
182 u8 reg; 182 u8 reg;
183 int ret = 0; 183 int ret = 0;
@@ -316,7 +316,7 @@ vpx3220_command (struct i2c_client *client,
316 vpx3220_write_fp_block(client, init_fp, 316 vpx3220_write_fp_block(client, init_fp,
317 sizeof(init_fp) >> 1); 317 sizeof(init_fp) >> 1);
318 switch (decoder->norm) { 318 switch (decoder->norm) {
319 319
320 case VIDEO_MODE_NTSC: 320 case VIDEO_MODE_NTSC:
321 vpx3220_write_fp_block(client, init_ntsc, 321 vpx3220_write_fp_block(client, init_ntsc,
322 sizeof(init_ntsc) >> 1); 322 sizeof(init_ntsc) >> 1);
@@ -324,7 +324,7 @@ vpx3220_command (struct i2c_client *client,
324 324
325 case VIDEO_MODE_PAL: 325 case VIDEO_MODE_PAL:
326 vpx3220_write_fp_block(client, init_pal, 326 vpx3220_write_fp_block(client, init_pal,
327 sizeof(init_pal) >> 1); 327 sizeof(init_pal) >> 1);
328 break; 328 break;
329 case VIDEO_MODE_SECAM: 329 case VIDEO_MODE_SECAM:
330 vpx3220_write_fp_block(client, init_secam, 330 vpx3220_write_fp_block(client, init_secam,
@@ -332,10 +332,10 @@ vpx3220_command (struct i2c_client *client,
332 break; 332 break;
333 default: 333 default:
334 vpx3220_write_fp_block(client, init_pal, 334 vpx3220_write_fp_block(client, init_pal,
335 sizeof(init_pal) >> 1); 335 sizeof(init_pal) >> 1);
336 break; 336 break;
337 } 337 }
338 } 338 }
339 break; 339 break;
340 340
341 case DECODER_DUMP: 341 case DECODER_DUMP:
@@ -411,7 +411,7 @@ vpx3220_command (struct i2c_client *client,
411 411
412 /* Here we back up the input selection because it gets 412 /* Here we back up the input selection because it gets
413 overwritten when we fill the registers with the 413 overwritten when we fill the registers with the
414 choosen video norm */ 414 choosen video norm */
415 temp_input = vpx3220_fp_read(client, 0xf2); 415 temp_input = vpx3220_fp_read(client, 0xf2);
416 416
417 dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n", 417 dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",
@@ -578,7 +578,7 @@ static unsigned short normal_i2c[] =
578}; 578};
579 579
580static unsigned short ignore = I2C_CLIENT_END; 580static unsigned short ignore = I2C_CLIENT_END;
581 581
582static struct i2c_client_address_data addr_data = { 582static struct i2c_client_address_data addr_data = {
583 .normal_i2c = normal_i2c, 583 .normal_i2c = normal_i2c,
584 .probe = &ignore, 584 .probe = &ignore,
@@ -661,7 +661,7 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
661 break; 661 break;
662 default: 662 default:
663 dprintk(1, 663 dprintk(1,
664 KERN_INFO 664 KERN_INFO
665 "%s: Wrong part number (0x%04x)\n", 665 "%s: Wrong part number (0x%04x)\n",
666 __func__, pn); 666 __func__, pn);
667 kfree(client); 667 kfree(client);
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index b7b0afffd214..80ef8a1b8f63 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -26,7 +26,7 @@
26 Does any other model using the w9966 interface chip exist ? 26 Does any other model using the w9966 interface chip exist ?
27 27
28 Todo: 28 Todo:
29 29
30 *Add a working EPP mode, since DMA ECP read isn't implemented 30 *Add a working EPP mode, since DMA ECP read isn't implemented
31 in the parport drivers. (That's why it's so sloow) 31 in the parport drivers. (That's why it's so sloow)
32 32
@@ -47,9 +47,9 @@
47 *Probably some bugs that I don't know of 47 *Probably some bugs that I don't know of
48 48
49 Please support me by sending feedback! 49 Please support me by sending feedback!
50 50
51 Changes: 51 Changes:
52 52
53 Alan Cox: Removed RGB mode for kernel merge, added THIS_MODULE 53 Alan Cox: Removed RGB mode for kernel merge, added THIS_MODULE
54 and owner support for newer module locks 54 and owner support for newer module locks
55*/ 55*/
@@ -204,7 +204,7 @@ static struct video_device w9966_template = {
204 */ 204 */
205 205
206 206
207// Set camera phase flags, so we know what to uninit when terminating 207// Set camera phase flags, so we know what to uninit when terminating
208static inline void w9966_setState(struct w9966_dev* cam, int mask, int val) 208static inline void w9966_setState(struct w9966_dev* cam, int mask, int val)
209{ 209{
210 cam->dev_state = (cam->dev_state & ~mask) ^ val; 210 cam->dev_state = (cam->dev_state & ~mask) ^ val;
@@ -233,7 +233,7 @@ static inline void w9966_pdev_release(struct w9966_dev* cam)
233 parport_release(cam->pdev); 233 parport_release(cam->pdev);
234 w9966_setState(cam, W9966_STATE_CLAIMED, 0); 234 w9966_setState(cam, W9966_STATE_CLAIMED, 0);
235} 235}
236 236
237// Read register from W9966 interface-chip 237// Read register from W9966 interface-chip
238// Expects a claimed pdev 238// Expects a claimed pdev
239// -1 on error, else register data (byte) 239// -1 on error, else register data (byte)
@@ -242,7 +242,7 @@ static int w9966_rReg(struct w9966_dev* cam, int reg)
242 // ECP, read, regtransfer, REG, REG, REG, REG, REG 242 // ECP, read, regtransfer, REG, REG, REG, REG, REG
243 const unsigned char addr = 0x80 | (reg & 0x1f); 243 const unsigned char addr = 0x80 | (reg & 0x1f);
244 unsigned char val; 244 unsigned char val;
245 245
246 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0) 246 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0)
247 return -1; 247 return -1;
248 if (parport_write(cam->pport, &addr, 1) != 1) 248 if (parport_write(cam->pport, &addr, 1) != 1)
@@ -263,7 +263,7 @@ static int w9966_wReg(struct w9966_dev* cam, int reg, int data)
263 // ECP, write, regtransfer, REG, REG, REG, REG, REG 263 // ECP, write, regtransfer, REG, REG, REG, REG, REG
264 const unsigned char addr = 0xc0 | (reg & 0x1f); 264 const unsigned char addr = 0xc0 | (reg & 0x1f);
265 const unsigned char val = data; 265 const unsigned char val = data;
266 266
267 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0) 267 if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0)
268 return -1; 268 return -1;
269 if (parport_write(cam->pport, &addr, 1) != 1) 269 if (parport_write(cam->pport, &addr, 1) != 1)
@@ -284,7 +284,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
284{ 284{
285 if (cam->dev_state != 0) 285 if (cam->dev_state != 0)
286 return -1; 286 return -1;
287 287
288 cam->pport = port; 288 cam->pport = port;
289 cam->brightness = 128; 289 cam->brightness = 128;
290 cam->contrast = 64; 290 cam->contrast = 64;
@@ -302,7 +302,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
302 cam->ppmode = IEEE1284_MODE_EPP; 302 cam->ppmode = IEEE1284_MODE_EPP;
303 else 303 else
304 cam->ppmode = IEEE1284_MODE_ECP; 304 cam->ppmode = IEEE1284_MODE_ECP;
305 break; 305 break;
306 case 1: // hw- or sw-ecp 306 case 1: // hw- or sw-ecp
307 cam->ppmode = IEEE1284_MODE_ECP; 307 cam->ppmode = IEEE1284_MODE_ECP;
308 break; 308 break;
@@ -310,7 +310,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
310 cam->ppmode = IEEE1284_MODE_EPP; 310 cam->ppmode = IEEE1284_MODE_EPP;
311 break; 311 break;
312 } 312 }
313 313
314// Tell the parport driver that we exists 314// Tell the parport driver that we exists
315 cam->pdev = parport_register_device(port, "w9966", NULL, NULL, NULL, 0, NULL); 315 cam->pdev = parport_register_device(port, "w9966", NULL, NULL, NULL, 0, NULL);
316 if (cam->pdev == NULL) { 316 if (cam->pdev == NULL) {
@@ -320,7 +320,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
320 w9966_setState(cam, W9966_STATE_PDEV, W9966_STATE_PDEV); 320 w9966_setState(cam, W9966_STATE_PDEV, W9966_STATE_PDEV);
321 321
322 w9966_pdev_claim(cam); 322 w9966_pdev_claim(cam);
323 323
324// Setup a default capture mode 324// Setup a default capture mode
325 if (w9966_setup(cam, 0, 0, 1023, 1023, 200, 160) != 0) { 325 if (w9966_setup(cam, 0, 0, 1023, 1023, 200, 160) != 0) {
326 DPRINTF("w9966_setup() failed.\n"); 326 DPRINTF("w9966_setup() failed.\n");
@@ -333,11 +333,11 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
333 memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device)); 333 memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device));
334 cam->vdev.priv = cam; 334 cam->vdev.priv = cam;
335 335
336 if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1) 336 if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1)
337 return -1; 337 return -1;
338 338
339 w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV); 339 w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV);
340 340
341 // All ok 341 // All ok
342 printk( 342 printk(
343 "w9966cf: Found and initialized a webcam on %s.\n", 343 "w9966cf: Found and initialized a webcam on %s.\n",
@@ -391,7 +391,7 @@ static int w9966_findlen(int near, int size, int maxlen)
391 // Only continue as long as we keep getting better values 391 // Only continue as long as we keep getting better values
392 if (err > besterr) 392 if (err > besterr)
393 break; 393 break;
394 394
395 besterr = err; 395 besterr = err;
396 bestlen = len; 396 bestlen = len;
397 } 397 }
@@ -399,7 +399,7 @@ static int w9966_findlen(int near, int size, int maxlen)
399 return bestlen; 399 return bestlen;
400} 400}
401 401
402// Modify capture window (if necessary) 402// Modify capture window (if necessary)
403// and calculate downscaling 403// and calculate downscaling
404// Return -1 on error 404// Return -1 on error
405static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsigned char* factor) 405static 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
407 int maxlen = max - min; 407 int maxlen = max - min;
408 int len = *end - *beg + 1; 408 int len = *end - *beg + 1;
409 int newlen = w9966_findlen(len, size, maxlen); 409 int newlen = w9966_findlen(len, size, maxlen);
410 int err = newlen - len; 410 int err = newlen - len;
411 411
412 // Check for bad format 412 // Check for bad format
413 if (newlen > maxlen || newlen < size) 413 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
452 0x48, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 452 0x48, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453 0x00, 0x00, 0x00, 0x71, 0xe7, 0x00, 0x00, 0xc0 453 0x00, 0x00, 0x00, 0x71, 0xe7, 0x00, 0x00, 0xc0
454 }; 454 };
455 455
456 456
457 if (w*h*2 > W9966_SRAMSIZE) 457 if (w*h*2 > W9966_SRAMSIZE)
458 { 458 {
459 DPRINTF("capture window exceeds SRAM size!.\n"); 459 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
469 cam->width = w; 469 cam->width = w;
470 cam->height = h; 470 cam->height = h;
471 471
472 enh_s = 0; 472 enh_s = 0;
473 enh_e = w*h*2; 473 enh_e = w*h*2;
474 474
475// Modify capture window if necessary and calculate downscaling 475// Modify capture window if necessary and calculate downscaling
476 if ( 476 if (
477 w9966_calcscale(w, W9966_WND_MIN_X, W9966_WND_MAX_X, &x1, &x2, &scale_x) != 0 || 477 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
482 "%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n", 482 "%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n",
483 w, h, x1, x2, y1, y2, scale_x&~0x80, scale_y&~0x80 483 w, h, x1, x2, y1, y2, scale_x&~0x80, scale_y&~0x80
484 ); 484 );
485 485
486// Setup registers 486// Setup registers
487 regs[0x00] = 0x00; // Set normal operation 487 regs[0x00] = 0x00; // Set normal operation
488 regs[0x01] = 0x18; // Capture mode 488 regs[0x01] = 0x18; // Capture mode
489 regs[0x02] = scale_y; // V-scaling 489 regs[0x02] = scale_y; // V-scaling
490 regs[0x03] = scale_x; // H-scaling 490 regs[0x03] = scale_x; // H-scaling
491 491
492 // Capture window 492 // Capture window
493 regs[0x04] = (x1 & 0x0ff); // X-start (8 low bits) 493 regs[0x04] = (x1 & 0x0ff); // X-start (8 low bits)
494 regs[0x05] = (x1 & 0x300)>>8; // X-start (2 high bits) 494 regs[0x05] = (x1 & 0x300)>>8; // X-start (2 high bits)
495 regs[0x06] = (y1 & 0x0ff); // Y-start (8 low bits) 495 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
499 regs[0x0a] = (y2 & 0x0ff); // Y-end (8 low bits) 499 regs[0x0a] = (y2 & 0x0ff); // Y-end (8 low bits)
500 500
501 regs[0x0c] = W9966_SRAMID; // SRAM-banks (1x 128kb) 501 regs[0x0c] = W9966_SRAMID; // SRAM-banks (1x 128kb)
502 502
503 // Enhancement layer 503 // Enhancement layer
504 regs[0x0d] = (enh_s& 0x000ff); // Enh. start (0-7) 504 regs[0x0d] = (enh_s& 0x000ff); // Enh. start (0-7)
505 regs[0x0e] = (enh_s& 0x0ff00)>>8; // Enh. start (8-15) 505 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
515 regs[0x19] = 0xff; // I/O port direction control 515 regs[0x19] = 0xff; // I/O port direction control
516 regs[0x1a] = 0xff; // I/O port data register 516 regs[0x1a] = 0xff; // I/O port data register
517 regs[0x1b] = 0x10; // ??? 517 regs[0x1b] = 0x10; // ???
518 518
519 // SAA7111 chip settings 519 // SAA7111 chip settings
520 saa7111_regs[0x0a] = cam->brightness; 520 saa7111_regs[0x0a] = cam->brightness;
521 saa7111_regs[0x0b] = cam->contrast; 521 saa7111_regs[0x0b] = cam->contrast;
@@ -551,7 +551,7 @@ static inline void w9966_i2c_setsda(struct w9966_dev* cam, int state)
551 cam->i2c_state |= W9966_I2C_W_DATA; 551 cam->i2c_state |= W9966_I2C_W_DATA;
552 else 552 else
553 cam->i2c_state &= ~W9966_I2C_W_DATA; 553 cam->i2c_state &= ~W9966_I2C_W_DATA;
554 554
555 w9966_wReg(cam, 0x18, cam->i2c_state); 555 w9966_wReg(cam, 0x18, cam->i2c_state);
556 udelay(5); 556 udelay(5);
557} 557}
@@ -577,7 +577,7 @@ static inline int w9966_i2c_setscl(struct w9966_dev* cam, int state)
577 577
578 w9966_wReg(cam, 0x18, cam->i2c_state); 578 w9966_wReg(cam, 0x18, cam->i2c_state);
579 udelay(5); 579 udelay(5);
580 580
581 // we go to high, we also expect the peripheral to ack. 581 // we go to high, we also expect the peripheral to ack.
582 if (state) { 582 if (state) {
583 timeout = jiffies + 100; 583 timeout = jiffies + 100;
@@ -607,16 +607,16 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data)
607 w9966_i2c_setsda(cam, (data >> i) & 0x01); 607 w9966_i2c_setsda(cam, (data >> i) & 0x01);
608 608
609 if (w9966_i2c_setscl(cam, 1) == -1) 609 if (w9966_i2c_setscl(cam, 1) == -1)
610 return -1; 610 return -1;
611 w9966_i2c_setscl(cam, 0); 611 w9966_i2c_setscl(cam, 0);
612 } 612 }
613 613
614 w9966_i2c_setsda(cam, 1); 614 w9966_i2c_setsda(cam, 1);
615 615
616 if (w9966_i2c_setscl(cam, 1) == -1) 616 if (w9966_i2c_setscl(cam, 1) == -1)
617 return -1; 617 return -1;
618 w9966_i2c_setscl(cam, 0); 618 w9966_i2c_setscl(cam, 0);
619 619
620 return 0; 620 return 0;
621} 621}
622 622
@@ -626,8 +626,8 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data)
626static int w9966_i2c_rbyte(struct w9966_dev* cam) 626static int w9966_i2c_rbyte(struct w9966_dev* cam)
627{ 627{
628 unsigned char data = 0x00; 628 unsigned char data = 0x00;
629 int i; 629 int i;
630 630
631 w9966_i2c_setsda(cam, 1); 631 w9966_i2c_setsda(cam, 1);
632 632
633 for (i = 0; i < 8; i++) 633 for (i = 0; i < 8; i++)
@@ -637,7 +637,7 @@ static int w9966_i2c_rbyte(struct w9966_dev* cam)
637 data = data << 1; 637 data = data << 1;
638 if (w9966_i2c_getsda(cam)) 638 if (w9966_i2c_getsda(cam))
639 data |= 0x01; 639 data |= 0x01;
640 640
641 w9966_i2c_setscl(cam, 0); 641 w9966_i2c_setscl(cam, 0);
642 } 642 }
643 return data; 643 return data;
@@ -673,11 +673,11 @@ static int w9966_rReg_i2c(struct w9966_dev* cam, int reg)
673 return -1; 673 return -1;
674 674
675 w9966_i2c_setsda(cam, 0); 675 w9966_i2c_setsda(cam, 0);
676 676
677 if (w9966_i2c_setscl(cam, 1) == -1) 677 if (w9966_i2c_setscl(cam, 1) == -1)
678 return -1; 678 return -1;
679 w9966_i2c_setsda(cam, 1); 679 w9966_i2c_setsda(cam, 1);
680 680
681 return data; 681 return data;
682} 682}
683#endif 683#endif
@@ -699,7 +699,7 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data)
699 w9966_i2c_setsda(cam, 0); 699 w9966_i2c_setsda(cam, 0);
700 if (w9966_i2c_setscl(cam, 1) == -1) 700 if (w9966_i2c_setscl(cam, 1) == -1)
701 return -1; 701 return -1;
702 702
703 w9966_i2c_setsda(cam, 1); 703 w9966_i2c_setsda(cam, 1);
704 704
705 return 0; 705 return 0;
@@ -714,7 +714,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
714{ 714{
715 struct video_device *vdev = video_devdata(file); 715 struct video_device *vdev = video_devdata(file);
716 struct w9966_dev *cam = vdev->priv; 716 struct w9966_dev *cam = vdev->priv;
717 717
718 switch(cmd) 718 switch(cmd)
719 { 719 {
720 case VIDIOCGCAP: 720 case VIDIOCGCAP:
@@ -790,14 +790,14 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
790 struct video_picture *vpic = arg; 790 struct video_picture *vpic = arg;
791 if (vpic->depth != 16 || vpic->palette != VIDEO_PALETTE_YUV422) 791 if (vpic->depth != 16 || vpic->palette != VIDEO_PALETTE_YUV422)
792 return -EINVAL; 792 return -EINVAL;
793 793
794 cam->brightness = vpic->brightness >> 8; 794 cam->brightness = vpic->brightness >> 8;
795 cam->hue = (vpic->hue >> 8) - 128; 795 cam->hue = (vpic->hue >> 8) - 128;
796 cam->color = vpic->colour >> 9; 796 cam->color = vpic->colour >> 9;
797 cam->contrast = vpic->contrast >> 9; 797 cam->contrast = vpic->contrast >> 9;
798 798
799 w9966_pdev_claim(cam); 799 w9966_pdev_claim(cam);
800 800
801 if ( 801 if (
802 w9966_wReg_i2c(cam, 0x0a, cam->brightness) == -1 || 802 w9966_wReg_i2c(cam, 0x0a, cam->brightness) == -1 ||
803 w9966_wReg_i2c(cam, 0x0b, cam->contrast) == -1 || 803 w9966_wReg_i2c(cam, 0x0b, cam->contrast) == -1 ||
@@ -807,7 +807,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
807 w9966_pdev_release(cam); 807 w9966_pdev_release(cam);
808 return -EIO; 808 return -EIO;
809 } 809 }
810 810
811 w9966_pdev_release(cam); 811 w9966_pdev_release(cam);
812 return 0; 812 return 0;
813 } 813 }
@@ -815,13 +815,13 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
815 { 815 {
816 int ret; 816 int ret;
817 struct video_window *vwin = arg; 817 struct video_window *vwin = arg;
818 818
819 if (vwin->flags != 0) 819 if (vwin->flags != 0)
820 return -EINVAL; 820 return -EINVAL;
821 if (vwin->clipcount != 0) 821 if (vwin->clipcount != 0)
822 return -EINVAL; 822 return -EINVAL;
823 if (vwin->width < 2 || vwin->width > W9966_WND_MAX_W) 823 if (vwin->width < 2 || vwin->width > W9966_WND_MAX_W)
824 return -EINVAL; 824 return -EINVAL;
825 if (vwin->height < 1 || vwin->height > W9966_WND_MAX_H) 825 if (vwin->height < 1 || vwin->height > W9966_WND_MAX_H)
826 return -EINVAL; 826 return -EINVAL;
827 827
@@ -829,12 +829,12 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
829 w9966_pdev_claim(cam); 829 w9966_pdev_claim(cam);
830 ret = w9966_setup(cam, 0, 0, 1023, 1023, vwin->width, vwin->height); 830 ret = w9966_setup(cam, 0, 0, 1023, 1023, vwin->width, vwin->height);
831 w9966_pdev_release(cam); 831 w9966_pdev_release(cam);
832 832
833 if (ret != 0) { 833 if (ret != 0) {
834 DPRINTF("VIDIOCSWIN: w9966_setup() failed.\n"); 834 DPRINTF("VIDIOCSWIN: w9966_setup() failed.\n");
835 return -EIO; 835 return -EIO;
836 } 836 }
837 837
838 return 0; 838 return 0;
839 } 839 }
840 case VIDIOCGWIN: 840 case VIDIOCGWIN:
@@ -846,7 +846,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
846 return 0; 846 return 0;
847 } 847 }
848 // Unimplemented 848 // Unimplemented
849 case VIDIOCCAPTURE: 849 case VIDIOCCAPTURE:
850 case VIDIOCGFBUF: 850 case VIDIOCGFBUF:
851 case VIDIOCSFBUF: 851 case VIDIOCSFBUF:
852 case VIDIOCKEY: 852 case VIDIOCKEY:
@@ -877,17 +877,17 @@ static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
877 unsigned char __user *dest = (unsigned char __user *)buf; 877 unsigned char __user *dest = (unsigned char __user *)buf;
878 unsigned long dleft = count; 878 unsigned long dleft = count;
879 unsigned char *tbuf; 879 unsigned char *tbuf;
880 880
881 // Why would anyone want more than this?? 881 // Why would anyone want more than this??
882 if (count > cam->width * cam->height * 2) 882 if (count > cam->width * cam->height * 2)
883 return -EINVAL; 883 return -EINVAL;
884 884
885 w9966_pdev_claim(cam); 885 w9966_pdev_claim(cam);
886 w9966_wReg(cam, 0x00, 0x02); // Reset ECP-FIFO buffer 886 w9966_wReg(cam, 0x00, 0x02); // Reset ECP-FIFO buffer
887 w9966_wReg(cam, 0x00, 0x00); // Return to normal operation 887 w9966_wReg(cam, 0x00, 0x00); // Return to normal operation
888 w9966_wReg(cam, 0x01, 0x98); // Enable capture 888 w9966_wReg(cam, 0x01, 0x98); // Enable capture
889 889
890 // write special capture-addr and negotiate into data transfer 890 // write special capture-addr and negotiate into data transfer
891 if ( 891 if (
892 (parport_negotiate(cam->pport, cam->ppmode|IEEE1284_ADDR) != 0 )|| 892 (parport_negotiate(cam->pport, cam->ppmode|IEEE1284_ADDR) != 0 )||
893 (parport_write(cam->pport, &addr, 1) != 1 )|| 893 (parport_write(cam->pport, &addr, 1) != 1 )||
@@ -906,7 +906,7 @@ static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
906 while(dleft > 0) 906 while(dleft > 0)
907 { 907 {
908 unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft; 908 unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft;
909 909
910 if (parport_read(cam->pport, tbuf, tsize) < tsize) { 910 if (parport_read(cam->pport, tbuf, tsize) < tsize) {
911 count = -EFAULT; 911 count = -EFAULT;
912 goto out; 912 goto out;
@@ -933,7 +933,7 @@ out:
933static void w9966_attach(struct parport *port) 933static void w9966_attach(struct parport *port)
934{ 934{
935 int i; 935 int i;
936 936
937 for (i = 0; i < W9966_MAXCAMS; i++) 937 for (i = 0; i < W9966_MAXCAMS; i++)
938 { 938 {
939 if (w9966_cams[i].dev_state != 0) // Cam is already assigned 939 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 b57dec3782e0..20f211b55ad4 100644
--- a/drivers/usb/media/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -71,39 +71,39 @@ MODULE_SUPPORTED_DEVICE("Video");
71static int ovmod_load = W9968CF_OVMOD_LOAD; 71static int ovmod_load = W9968CF_OVMOD_LOAD;
72static unsigned short simcams = W9968CF_SIMCAMS; 72static unsigned short simcams = W9968CF_SIMCAMS;
73static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/ 73static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/
74static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] = 74static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] =
75 W9968CF_PACKET_SIZE}; 75 W9968CF_PACKET_SIZE};
76static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] = 76static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] =
77 W9968CF_BUFFERS}; 77 W9968CF_BUFFERS};
78static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] = 78static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] =
79 W9968CF_DOUBLE_BUFFER}; 79 W9968CF_DOUBLE_BUFFER};
80static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING}; 80static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING};
81static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] = 81static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] =
82 W9968CF_FILTER_TYPE}; 82 W9968CF_FILTER_TYPE};
83static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW}; 83static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW};
84static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] = 84static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] =
85 W9968CF_DECOMPRESSION}; 85 W9968CF_DECOMPRESSION};
86static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING}; 86static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING};
87static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0}; 87static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0};
88static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB}; 88static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB};
89static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT}; 89static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT};
90static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP}; 90static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP};
91static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] = 91static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] =
92 W9968CF_LIGHTFREQ}; 92 W9968CF_LIGHTFREQ};
93static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]= 93static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]=
94 W9968CF_BANDINGFILTER}; 94 W9968CF_BANDINGFILTER};
95static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV}; 95static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV};
96static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT}; 96static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT};
97static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR}; 97static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR};
98static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME}; 98static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME};
99static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] = 99static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
100 W9968CF_BRIGHTNESS}; 100 W9968CF_BRIGHTNESS};
101static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE}; 101static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE};
102static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR}; 102static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR};
103static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] = 103static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] =
104 W9968CF_CONTRAST}; 104 W9968CF_CONTRAST};
105static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] = 105static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
106 W9968CF_WHITENESS}; 106 W9968CF_WHITENESS};
107#ifdef W9968CF_DEBUG 107#ifdef W9968CF_DEBUG
108static unsigned short debug = W9968CF_DEBUG_LEVEL; 108static unsigned short debug = W9968CF_DEBUG_LEVEL;
109static int specific_debug = W9968CF_SPECIFIC_DEBUG; 109static int specific_debug = W9968CF_SPECIFIC_DEBUG;
@@ -145,251 +145,251 @@ module_param(specific_debug, bool, 0644);
145#endif 145#endif
146 146
147#ifdef CONFIG_KMOD 147#ifdef CONFIG_KMOD
148MODULE_PARM_DESC(ovmod_load, 148MODULE_PARM_DESC(ovmod_load,
149 "\n<0|1> Automatic 'ovcamchip' module loading." 149 "\n<0|1> Automatic 'ovcamchip' module loading."
150 "\n0 disabled, 1 enabled." 150 "\n0 disabled, 1 enabled."
151 "\nIf enabled,'insmod' searches for the required 'ovcamchip'" 151 "\nIf enabled,'insmod' searches for the required 'ovcamchip'"
152 "\nmodule in the system, according to its configuration, and" 152 "\nmodule in the system, according to its configuration, and"
153 "\nattempts to load that module automatically. This action is" 153 "\nattempts to load that module automatically. This action is"
154 "\nperformed once as soon as the 'w9968cf' module is loaded" 154 "\nperformed once as soon as the 'w9968cf' module is loaded"
155 "\ninto memory." 155 "\ninto memory."
156 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"." 156 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"."
157 "\n"); 157 "\n");
158#endif 158#endif
159MODULE_PARM_DESC(simcams, 159MODULE_PARM_DESC(simcams,
160 "\n<n> Number of cameras allowed to stream simultaneously." 160 "\n<n> Number of cameras allowed to stream simultaneously."
161 "\nn may vary from 0 to " 161 "\nn may vary from 0 to "
162 __MODULE_STRING(W9968CF_MAX_DEVICES)"." 162 __MODULE_STRING(W9968CF_MAX_DEVICES)"."
163 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"." 163 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"."
164 "\n"); 164 "\n");
165MODULE_PARM_DESC(video_nr, 165MODULE_PARM_DESC(video_nr,
166 "\n<-1|n[,...]> Specify V4L minor mode number." 166 "\n<-1|n[,...]> Specify V4L minor mode number."
167 "\n -1 = use next available (default)" 167 "\n -1 = use next available (default)"
168 "\n n = use minor number n (integer >= 0)" 168 "\n n = use minor number n (integer >= 0)"
169 "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES) 169 "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES)
170 " cameras this way." 170 " cameras this way."
171 "\nFor example:" 171 "\nFor example:"
172 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 172 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
173 "\nthe second camera and use auto for the first" 173 "\nthe second camera and use auto for the first"
174 "\none and for every other camera." 174 "\none and for every other camera."
175 "\n"); 175 "\n");
176MODULE_PARM_DESC(packet_size, 176MODULE_PARM_DESC(packet_size,
177 "\n<n[,...]> Specify the maximum data payload" 177 "\n<n[,...]> Specify the maximum data payload"
178 "\nsize in bytes for alternate settings, for each device." 178 "\nsize in bytes for alternate settings, for each device."
179 "\nn is scaled between 63 and 1023 " 179 "\nn is scaled between 63 and 1023 "
180 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")." 180 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")."
181 "\n"); 181 "\n");
182MODULE_PARM_DESC(max_buffers, 182MODULE_PARM_DESC(max_buffers,
183 "\n<n[,...]> For advanced users." 183 "\n<n[,...]> For advanced users."
184 "\nSpecify the maximum number of video frame buffers" 184 "\nSpecify the maximum number of video frame buffers"
185 "\nto allocate for each device, from 2 to " 185 "\nto allocate for each device, from 2 to "
186 __MODULE_STRING(W9968CF_MAX_BUFFERS) 186 __MODULE_STRING(W9968CF_MAX_BUFFERS)
187 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")." 187 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")."
188 "\n"); 188 "\n");
189MODULE_PARM_DESC(double_buffer, 189MODULE_PARM_DESC(double_buffer,
190 "\n<0|1[,...]> " 190 "\n<0|1[,...]> "
191 "Hardware double buffering: 0 disabled, 1 enabled." 191 "Hardware double buffering: 0 disabled, 1 enabled."
192 "\nIt should be enabled if you want smooth video output: if" 192 "\nIt should be enabled if you want smooth video output: if"
193 "\nyou obtain out of sync. video, disable it, or try to" 193 "\nyou obtain out of sync. video, disable it, or try to"
194 "\ndecrease the 'clockdiv' module parameter value." 194 "\ndecrease the 'clockdiv' module parameter value."
195 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER) 195 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER)
196 " for every device." 196 " for every device."
197 "\n"); 197 "\n");
198MODULE_PARM_DESC(clamping, 198MODULE_PARM_DESC(clamping,
199 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled." 199 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled."
200 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING) 200 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING)
201 " for every device." 201 " for every device."
202 "\n"); 202 "\n");
203MODULE_PARM_DESC(filter_type, 203MODULE_PARM_DESC(filter_type,
204 "\n<0|1|2[,...]> Video filter type." 204 "\n<0|1|2[,...]> Video filter type."
205 "\n0 none, 1 (1-2-1) 3-tap filter, " 205 "\n0 none, 1 (1-2-1) 3-tap filter, "
206 "2 (2-3-6-3-2) 5-tap filter." 206 "2 (2-3-6-3-2) 5-tap filter."
207 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE) 207 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE)
208 " for every device." 208 " for every device."
209 "\nThe filter is used to reduce noise and aliasing artifacts" 209 "\nThe filter is used to reduce noise and aliasing artifacts"
210 "\nproduced by the CCD or CMOS image sensor, and the scaling" 210 "\nproduced by the CCD or CMOS image sensor, and the scaling"
211 " process." 211 " process."
212 "\n"); 212 "\n");
213MODULE_PARM_DESC(largeview, 213MODULE_PARM_DESC(largeview,
214 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled." 214 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled."
215 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW) 215 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW)
216 " for every device." 216 " for every device."
217 "\n"); 217 "\n");
218MODULE_PARM_DESC(upscaling, 218MODULE_PARM_DESC(upscaling,
219 "\n<0|1[,...]> Software scaling (for non-compressed video):" 219 "\n<0|1[,...]> Software scaling (for non-compressed video):"
220 "\n0 disabled, 1 enabled." 220 "\n0 disabled, 1 enabled."
221 "\nDisable it if you have a slow CPU or you don't have" 221 "\nDisable it if you have a slow CPU or you don't have"
222 " enough memory." 222 " enough memory."
223 "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING) 223 "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING)
224 " for every device." 224 " for every device."
225 "\nIf 'w9968cf-vpp' is not present, this parameter is" 225 "\nIf 'w9968cf-vpp' is not present, this parameter is"
226 " set to 0." 226 " set to 0."
227 "\n"); 227 "\n");
228MODULE_PARM_DESC(decompression, 228MODULE_PARM_DESC(decompression,
229 "\n<0|1|2[,...]> Software video decompression:" 229 "\n<0|1|2[,...]> Software video decompression:"
230 "\n- 0 disables decompression (doesn't allow formats needing" 230 "\n- 0 disables decompression (doesn't allow formats needing"
231 " decompression)" 231 " decompression)"
232 "\n- 1 forces decompression (allows formats needing" 232 "\n- 1 forces decompression (allows formats needing"
233 " decompression only);" 233 " decompression only);"
234 "\n- 2 allows any permitted formats." 234 "\n- 2 allows any permitted formats."
235 "\nFormats supporting compressed video are YUV422P and" 235 "\nFormats supporting compressed video are YUV422P and"
236 " YUV420P/YUV420 " 236 " YUV420P/YUV420 "
237 "\nin any resolutions where both width and height are " 237 "\nin any resolutions where both width and height are "
238 "a multiple of 16." 238 "a multiple of 16."
239 "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION) 239 "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION)
240 " for every device." 240 " for every device."
241 "\nIf 'w9968cf-vpp' is not present, forcing decompression is " 241 "\nIf 'w9968cf-vpp' is not present, forcing decompression is "
242 "\nnot allowed; in this case this parameter is set to 2." 242 "\nnot allowed; in this case this parameter is set to 2."
243 "\n"); 243 "\n");
244MODULE_PARM_DESC(force_palette, 244MODULE_PARM_DESC(force_palette,
245 "\n<0" 245 "\n<0"
246 "|" __MODULE_STRING(VIDEO_PALETTE_UYVY) 246 "|" __MODULE_STRING(VIDEO_PALETTE_UYVY)
247 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420) 247 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420)
248 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P) 248 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P)
249 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P) 249 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P)
250 "|" __MODULE_STRING(VIDEO_PALETTE_YUYV) 250 "|" __MODULE_STRING(VIDEO_PALETTE_YUYV)
251 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422) 251 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422)
252 "|" __MODULE_STRING(VIDEO_PALETTE_GREY) 252 "|" __MODULE_STRING(VIDEO_PALETTE_GREY)
253 "|" __MODULE_STRING(VIDEO_PALETTE_RGB555) 253 "|" __MODULE_STRING(VIDEO_PALETTE_RGB555)
254 "|" __MODULE_STRING(VIDEO_PALETTE_RGB565) 254 "|" __MODULE_STRING(VIDEO_PALETTE_RGB565)
255 "|" __MODULE_STRING(VIDEO_PALETTE_RGB24) 255 "|" __MODULE_STRING(VIDEO_PALETTE_RGB24)
256 "|" __MODULE_STRING(VIDEO_PALETTE_RGB32) 256 "|" __MODULE_STRING(VIDEO_PALETTE_RGB32)
257 "[,...]>" 257 "[,...]>"
258 " Force picture palette." 258 " Force picture palette."
259 "\nIn order:" 259 "\nIn order:"
260 "\n- 0 allows any of the following formats:" 260 "\n- 0 allows any of the following formats:"
261 "\n- UYVY 16 bpp - Original video, compression disabled" 261 "\n- UYVY 16 bpp - Original video, compression disabled"
262 "\n- YUV420 12 bpp - Original video, compression enabled" 262 "\n- YUV420 12 bpp - Original video, compression enabled"
263 "\n- YUV422P 16 bpp - Original video, compression enabled" 263 "\n- YUV422P 16 bpp - Original video, compression enabled"
264 "\n- YUV420P 12 bpp - Original video, compression enabled" 264 "\n- YUV420P 12 bpp - Original video, compression enabled"
265 "\n- YUVY 16 bpp - Software conversion from UYVY" 265 "\n- YUVY 16 bpp - Software conversion from UYVY"
266 "\n- YUV422 16 bpp - Software conversion from UYVY" 266 "\n- YUV422 16 bpp - Software conversion from UYVY"
267 "\n- GREY 8 bpp - Software conversion from UYVY" 267 "\n- GREY 8 bpp - Software conversion from UYVY"
268 "\n- RGB555 16 bpp - Software conversion from UYVY" 268 "\n- RGB555 16 bpp - Software conversion from UYVY"
269 "\n- RGB565 16 bpp - Software conversion from UYVY" 269 "\n- RGB565 16 bpp - Software conversion from UYVY"
270 "\n- RGB24 24 bpp - Software conversion from UYVY" 270 "\n- RGB24 24 bpp - Software conversion from UYVY"
271 "\n- RGB32 32 bpp - Software conversion from UYVY" 271 "\n- RGB32 32 bpp - Software conversion from UYVY"
272 "\nWhen not 0, this parameter will override 'decompression'." 272 "\nWhen not 0, this parameter will override 'decompression'."
273 "\nDefault value is 0 for every device." 273 "\nDefault value is 0 for every device."
274 "\nInitial palette is " 274 "\nInitial palette is "
275 __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"." 275 __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"."
276 "\nIf 'w9968cf-vpp' is not present, this parameter is" 276 "\nIf 'w9968cf-vpp' is not present, this parameter is"
277 " set to 9 (UYVY)." 277 " set to 9 (UYVY)."
278 "\n"); 278 "\n");
279MODULE_PARM_DESC(force_rgb, 279MODULE_PARM_DESC(force_rgb,
280 "\n<0|1[,...]> Read RGB video data instead of BGR:" 280 "\n<0|1[,...]> Read RGB video data instead of BGR:"
281 "\n 1 = use RGB component ordering." 281 "\n 1 = use RGB component ordering."
282 "\n 0 = use BGR component ordering." 282 "\n 0 = use BGR component ordering."
283 "\nThis parameter has effect when using RGBX palettes only." 283 "\nThis parameter has effect when using RGBX palettes only."
284 "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB) 284 "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB)
285 " for every device." 285 " for every device."
286 "\n"); 286 "\n");
287MODULE_PARM_DESC(autobright, 287MODULE_PARM_DESC(autobright,
288 "\n<0|1[,...]> Image sensor automatically changes brightness:" 288 "\n<0|1[,...]> Image sensor automatically changes brightness:"
289 "\n 0 = no, 1 = yes" 289 "\n 0 = no, 1 = yes"
290 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT) 290 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT)
291 " for every device." 291 " for every device."
292 "\n"); 292 "\n");
293MODULE_PARM_DESC(autoexp, 293MODULE_PARM_DESC(autoexp,
294 "\n<0|1[,...]> Image sensor automatically changes exposure:" 294 "\n<0|1[,...]> Image sensor automatically changes exposure:"
295 "\n 0 = no, 1 = yes" 295 "\n 0 = no, 1 = yes"
296 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP) 296 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP)
297 " for every device." 297 " for every device."
298 "\n"); 298 "\n");
299MODULE_PARM_DESC(lightfreq, 299MODULE_PARM_DESC(lightfreq,
300 "\n<50|60[,...]> Light frequency in Hz:" 300 "\n<50|60[,...]> Light frequency in Hz:"
301 "\n 50 for European and Asian lighting," 301 "\n 50 for European and Asian lighting,"
302 " 60 for American lighting." 302 " 60 for American lighting."
303 "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ) 303 "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ)
304 " for every device." 304 " for every device."
305 "\n"); 305 "\n");
306MODULE_PARM_DESC(bandingfilter, 306MODULE_PARM_DESC(bandingfilter,
307 "\n<0|1[,...]> Banding filter to reduce effects of" 307 "\n<0|1[,...]> Banding filter to reduce effects of"
308 " fluorescent lighting:" 308 " fluorescent lighting:"
309 "\n 0 disabled, 1 enabled." 309 "\n 0 disabled, 1 enabled."
310 "\nThis filter tries to reduce the pattern of horizontal" 310 "\nThis filter tries to reduce the pattern of horizontal"
311 "\nlight/dark bands caused by some (usually fluorescent)" 311 "\nlight/dark bands caused by some (usually fluorescent)"
312 " lighting." 312 " lighting."
313 "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER) 313 "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER)
314 " for every device." 314 " for every device."
315 "\n"); 315 "\n");
316MODULE_PARM_DESC(clockdiv, 316MODULE_PARM_DESC(clockdiv,
317 "\n<-1|n[,...]> " 317 "\n<-1|n[,...]> "
318 "Force pixel clock divisor to a specific value (for experts):" 318 "Force pixel clock divisor to a specific value (for experts):"
319 "\n n may vary from 0 to 127." 319 "\n n may vary from 0 to 127."
320 "\n -1 for automatic value." 320 "\n -1 for automatic value."
321 "\nSee also the 'double_buffer' module parameter." 321 "\nSee also the 'double_buffer' module parameter."
322 "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV) 322 "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV)
323 " for every device." 323 " for every device."
324 "\n"); 324 "\n");
325MODULE_PARM_DESC(backlight, 325MODULE_PARM_DESC(backlight,
326 "\n<0|1[,...]> Objects are lit from behind:" 326 "\n<0|1[,...]> Objects are lit from behind:"
327 "\n 0 = no, 1 = yes" 327 "\n 0 = no, 1 = yes"
328 "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT) 328 "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT)
329 " for every device." 329 " for every device."
330 "\n"); 330 "\n");
331MODULE_PARM_DESC(mirror, 331MODULE_PARM_DESC(mirror,
332 "\n<0|1[,...]> Reverse image horizontally:" 332 "\n<0|1[,...]> Reverse image horizontally:"
333 "\n 0 = no, 1 = yes" 333 "\n 0 = no, 1 = yes"
334 "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR) 334 "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR)
335 " for every device." 335 " for every device."
336 "\n"); 336 "\n");
337MODULE_PARM_DESC(monochrome, 337MODULE_PARM_DESC(monochrome,
338 "\n<0|1[,...]> Use image sensor as monochrome sensor:" 338 "\n<0|1[,...]> Use image sensor as monochrome sensor:"
339 "\n 0 = no, 1 = yes" 339 "\n 0 = no, 1 = yes"
340 "\nNot all the sensors support monochrome color." 340 "\nNot all the sensors support monochrome color."
341 "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME) 341 "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME)
342 " for every device." 342 " for every device."
343 "\n"); 343 "\n");
344MODULE_PARM_DESC(brightness, 344MODULE_PARM_DESC(brightness,
345 "\n<n[,...]> Set picture brightness (0-65535)." 345 "\n<n[,...]> Set picture brightness (0-65535)."
346 "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS) 346 "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS)
347 " for every device." 347 " for every device."
348 "\nThis parameter has no effect if 'autobright' is enabled." 348 "\nThis parameter has no effect if 'autobright' is enabled."
349 "\n"); 349 "\n");
350MODULE_PARM_DESC(hue, 350MODULE_PARM_DESC(hue,
351 "\n<n[,...]> Set picture hue (0-65535)." 351 "\n<n[,...]> Set picture hue (0-65535)."
352 "\nDefault value is "__MODULE_STRING(W9968CF_HUE) 352 "\nDefault value is "__MODULE_STRING(W9968CF_HUE)
353 " for every device." 353 " for every device."
354 "\n"); 354 "\n");
355MODULE_PARM_DESC(colour, 355MODULE_PARM_DESC(colour,
356 "\n<n[,...]> Set picture saturation (0-65535)." 356 "\n<n[,...]> Set picture saturation (0-65535)."
357 "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR) 357 "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR)
358 " for every device." 358 " for every device."
359 "\n"); 359 "\n");
360MODULE_PARM_DESC(contrast, 360MODULE_PARM_DESC(contrast,
361 "\n<n[,...]> Set picture contrast (0-65535)." 361 "\n<n[,...]> Set picture contrast (0-65535)."
362 "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST) 362 "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST)
363 " for every device." 363 " for every device."
364 "\n"); 364 "\n");
365MODULE_PARM_DESC(whiteness, 365MODULE_PARM_DESC(whiteness,
366 "\n<n[,...]> Set picture whiteness (0-65535)." 366 "\n<n[,...]> Set picture whiteness (0-65535)."
367 "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS) 367 "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS)
368 " for every device." 368 " for every device."
369 "\n"); 369 "\n");
370#ifdef W9968CF_DEBUG 370#ifdef W9968CF_DEBUG
371MODULE_PARM_DESC(debug, 371MODULE_PARM_DESC(debug,
372 "\n<n> Debugging information level, from 0 to 6:" 372 "\n<n> Debugging information level, from 0 to 6:"
373 "\n0 = none (use carefully)" 373 "\n0 = none (use carefully)"
374 "\n1 = critical errors" 374 "\n1 = critical errors"
375 "\n2 = significant informations" 375 "\n2 = significant informations"
376 "\n3 = configuration or general messages" 376 "\n3 = configuration or general messages"
377 "\n4 = warnings" 377 "\n4 = warnings"
378 "\n5 = called functions" 378 "\n5 = called functions"
379 "\n6 = function internals" 379 "\n6 = function internals"
380 "\nLevel 5 and 6 are useful for testing only, when only " 380 "\nLevel 5 and 6 are useful for testing only, when only "
381 "one device is used." 381 "one device is used."
382 "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"." 382 "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"."
383 "\n"); 383 "\n");
384MODULE_PARM_DESC(specific_debug, 384MODULE_PARM_DESC(specific_debug,
385 "\n<0|1> Enable or disable specific debugging messages:" 385 "\n<0|1> Enable or disable specific debugging messages:"
386 "\n0 = print messages concerning every level" 386 "\n0 = print messages concerning every level"
387 " <= 'debug' level." 387 " <= 'debug' level."
388 "\n1 = print messages concerning the level" 388 "\n1 = print messages concerning the level"
389 " indicated by 'debug'." 389 " indicated by 'debug'."
390 "\nDefault value is " 390 "\nDefault value is "
391 __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"." 391 __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"."
392 "\n"); 392 "\n");
393#endif /* W9968CF_DEBUG */ 393#endif /* W9968CF_DEBUG */
394 394
395 395
@@ -406,7 +406,7 @@ static int w9968cf_mmap(struct file*, struct vm_area_struct*);
406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long); 406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long);
407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*); 407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*);
408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int, 408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int,
409 void __user *); 409 void __user *);
410 410
411/* USB-specific */ 411/* USB-specific */
412static int w9968cf_start_transfer(struct w9968cf_device*); 412static int w9968cf_start_transfer(struct w9968cf_device*);
@@ -428,25 +428,25 @@ static int w9968cf_smbus_write_ack(struct w9968cf_device*);
428static int w9968cf_smbus_read_ack(struct w9968cf_device*); 428static int w9968cf_smbus_read_ack(struct w9968cf_device*);
429static int w9968cf_smbus_refresh_bus(struct w9968cf_device*); 429static int w9968cf_smbus_refresh_bus(struct w9968cf_device*);
430static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam, 430static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
431 u16 address, u8* value); 431 u16 address, u8* value);
432static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address, 432static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address,
433 u8 subaddress, u8* value); 433 u8 subaddress, u8* value);
434static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*, 434static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*,
435 u16 address, u8 subaddress); 435 u16 address, u8 subaddress);
436static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*, 436static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*,
437 u16 address, u8 subaddress, 437 u16 address, u8 subaddress,
438 u8 value); 438 u8 value);
439 439
440/* I2C interface to kernel */ 440/* I2C interface to kernel */
441static int w9968cf_i2c_init(struct w9968cf_device*); 441static int w9968cf_i2c_init(struct w9968cf_device*);
442static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr, 442static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr,
443 unsigned short flags, char read_write, 443 unsigned short flags, char read_write,
444 u8 command, int size, union i2c_smbus_data*); 444 u8 command, int size, union i2c_smbus_data*);
445static u32 w9968cf_i2c_func(struct i2c_adapter*); 445static u32 w9968cf_i2c_func(struct i2c_adapter*);
446static int w9968cf_i2c_attach_inform(struct i2c_client*); 446static int w9968cf_i2c_attach_inform(struct i2c_client*);
447static int w9968cf_i2c_detach_inform(struct i2c_client*); 447static int w9968cf_i2c_detach_inform(struct i2c_client*);
448static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd, 448static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd,
449 unsigned long arg); 449 unsigned long arg);
450 450
451/* Memory management */ 451/* Memory management */
452static void* rvmalloc(unsigned long size); 452static void* rvmalloc(unsigned long size);
@@ -458,17 +458,17 @@ static int w9968cf_allocate_memory(struct w9968cf_device*);
458static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val); 458static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val);
459static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val); 459static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val);
460static int w9968cf_sensor_cmd(struct w9968cf_device*, 460static int w9968cf_sensor_cmd(struct w9968cf_device*,
461 unsigned int cmd, void *arg); 461 unsigned int cmd, void *arg);
462static int w9968cf_sensor_init(struct w9968cf_device*); 462static int w9968cf_sensor_init(struct w9968cf_device*);
463static int w9968cf_sensor_update_settings(struct w9968cf_device*); 463static int w9968cf_sensor_update_settings(struct w9968cf_device*);
464static int w9968cf_sensor_get_picture(struct w9968cf_device*); 464static int w9968cf_sensor_get_picture(struct w9968cf_device*);
465static int w9968cf_sensor_update_picture(struct w9968cf_device*, 465static int w9968cf_sensor_update_picture(struct w9968cf_device*,
466 struct video_picture pict); 466 struct video_picture pict);
467 467
468/* Other helper functions */ 468/* Other helper functions */
469static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*, 469static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*,
470 enum w9968cf_model_id, 470 enum w9968cf_model_id,
471 const unsigned short dev_nr); 471 const unsigned short dev_nr);
472static void w9968cf_adjust_configuration(struct w9968cf_device*); 472static void w9968cf_adjust_configuration(struct w9968cf_device*);
473static int w9968cf_turn_on_led(struct w9968cf_device*); 473static int w9968cf_turn_on_led(struct w9968cf_device*);
474static int w9968cf_init_chip(struct w9968cf_device*); 474static int w9968cf_init_chip(struct w9968cf_device*);
@@ -477,8 +477,8 @@ static inline u16 w9968cf_valid_depth(u16 palette);
477static inline u8 w9968cf_need_decompression(u16 palette); 477static inline u8 w9968cf_need_decompression(u16 palette);
478static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture); 478static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture);
479static int w9968cf_set_window(struct w9968cf_device*, struct video_window); 479static int w9968cf_set_window(struct w9968cf_device*, struct video_window);
480static int w9968cf_postprocess_frame(struct w9968cf_device*, 480static int w9968cf_postprocess_frame(struct w9968cf_device*,
481 struct w9968cf_frame_t*); 481 struct w9968cf_frame_t*);
482static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h); 482static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h);
483static void w9968cf_init_framelist(struct w9968cf_device*); 483static void w9968cf_init_framelist(struct w9968cf_device*);
484static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num); 484static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num);
@@ -497,11 +497,11 @@ struct w9968cf_symbolic_list {
497 const char *name; 497 const char *name;
498}; 498};
499 499
500/*-------------------------------------------------------------------------- 500/*--------------------------------------------------------------------------
501 Returns the name of the matching element in the symbolic_list array. The 501 Returns the name of the matching element in the symbolic_list array. The
502 end of the list must be marked with an element that has a NULL name. 502 end of the list must be marked with an element that has a NULL name.
503 --------------------------------------------------------------------------*/ 503 --------------------------------------------------------------------------*/
504static inline const char * 504static inline const char *
505symbolic(struct w9968cf_symbolic_list list[], const int num) 505symbolic(struct w9968cf_symbolic_list list[], const int num)
506{ 506{
507 int i; 507 int i;
@@ -568,7 +568,7 @@ static struct w9968cf_symbolic_list v4l1_plist[] = {
568static struct w9968cf_symbolic_list decoder_errlist[] = { 568static struct w9968cf_symbolic_list decoder_errlist[] = {
569 { W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" }, 569 { W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" },
570 { W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" }, 570 { W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" },
571 { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" }, 571 { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" },
572 { W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" }, 572 { W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" },
573 { W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" }, 573 { W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" },
574 { W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" }, 574 { W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" },
@@ -695,7 +695,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
695 bpp = (w9968cf_vpp) ? 4 : 2; 695 bpp = (w9968cf_vpp) ? 4 : 2;
696 if (cam->upscaling) 696 if (cam->upscaling)
697 vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp, 697 vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp,
698 cam->maxwidth*cam->maxheight*bpp); 698 cam->maxwidth*cam->maxheight*bpp);
699 else 699 else
700 vpp_bufsize = cam->maxwidth*cam->maxheight*bpp; 700 vpp_bufsize = cam->maxwidth*cam->maxheight*bpp;
701 701
@@ -704,7 +704,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
704 if (!(cam->transfer_buffer[i] = 704 if (!(cam->transfer_buffer[i] =
705 kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) { 705 kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) {
706 DBG(1, "Couldn't allocate memory for the isochronous " 706 DBG(1, "Couldn't allocate memory for the isochronous "
707 "transfer buffers (%u bytes)", 707 "transfer buffers (%u bytes)",
708 p_size * W9968CF_ISO_PACKETS) 708 p_size * W9968CF_ISO_PACKETS)
709 return -ENOMEM; 709 return -ENOMEM;
710 } 710 }
@@ -780,7 +780,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
780 of the next video frame; if an error is encountered in a packet, the entire 780 of the next video frame; if an error is encountered in a packet, the entire
781 video frame is discarded and grabbed again. 781 video frame is discarded and grabbed again.
782 If there are no requested frames in the FIFO list, packets are collected into 782 If there are no requested frames in the FIFO list, packets are collected into
783 a temporary buffer. 783 a temporary buffer.
784 --------------------------------------------------------------------------*/ 784 --------------------------------------------------------------------------*/
785static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs) 785static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
786{ 786{
@@ -799,7 +799,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
799 /* "(*f)" will be used instead of "cam->frame_current" */ 799 /* "(*f)" will be used instead of "cam->frame_current" */
800 f = &cam->frame_current; 800 f = &cam->frame_current;
801 801
802 /* If a frame has been requested and we are grabbing into 802 /* If a frame has been requested and we are grabbing into
803 the temporary frame, we'll switch to that requested frame */ 803 the temporary frame, we'll switch to that requested frame */
804 if ((*f) == &cam->frame_tmp && *cam->requested_frame) { 804 if ((*f) == &cam->frame_tmp && *cam->requested_frame) {
805 if (cam->frame_tmp.status == F_GRABBING) { 805 if (cam->frame_tmp.status == F_GRABBING) {
@@ -808,7 +808,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
808 (*f)->length = cam->frame_tmp.length; 808 (*f)->length = cam->frame_tmp.length;
809 memcpy((*f)->buffer, cam->frame_tmp.buffer, 809 memcpy((*f)->buffer, cam->frame_tmp.buffer,
810 (*f)->length); 810 (*f)->length);
811 DBG(6, "Switched from temp. frame to frame #%d", 811 DBG(6, "Switched from temp. frame to frame #%d",
812 (*f)->number) 812 (*f)->number)
813 } 813 }
814 } 814 }
@@ -850,7 +850,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
850 850
851 if (cam->vpp_flag & VPP_DECOMPRESSION) { 851 if (cam->vpp_flag & VPP_DECOMPRESSION) {
852 err = w9968cf_vpp->check_headers((*f)->buffer, 852 err = w9968cf_vpp->check_headers((*f)->buffer,
853 (*f)->length); 853 (*f)->length);
854 if (err) { 854 if (err) {
855 DBG(4, "Skip corrupted frame: %s", 855 DBG(4, "Skip corrupted frame: %s",
856 symbolic(decoder_errlist, err)) 856 symbolic(decoder_errlist, err))
@@ -975,7 +975,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
975 cam->frame_current = &cam->frame_tmp; 975 cam->frame_current = &cam->frame_tmp;
976 976
977 if (!(cam->vpp_flag & VPP_DECOMPRESSION)) 977 if (!(cam->vpp_flag & VPP_DECOMPRESSION))
978 DBG(5, "Isochronous transfer size: %lu bytes/frame", 978 DBG(5, "Isochronous transfer size: %lu bytes/frame",
979 (unsigned long)t_size*2) 979 (unsigned long)t_size*2)
980 980
981 DBG(5, "Starting the isochronous transfer...") 981 DBG(5, "Starting the isochronous transfer...")
@@ -992,7 +992,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
992 usb_free_urb(cam->urb[j]); 992 usb_free_urb(cam->urb[j]);
993 } 993 }
994 DBG(1, "Couldn't send a transfer request to the " 994 DBG(1, "Couldn't send a transfer request to the "
995 "USB core (error #%d, %s)", err, 995 "USB core (error #%d, %s)", err,
996 symbolic(urb_errlist, err)) 996 symbolic(urb_errlist, err))
997 return err; 997 return err;
998 } 998 }
@@ -1016,7 +1016,7 @@ static int w9968cf_stop_transfer(struct w9968cf_device* cam)
1016 if (!cam->streaming) 1016 if (!cam->streaming)
1017 return 0; 1017 return 0;
1018 1018
1019 /* This avoids race conditions with usb_submit_urb() 1019 /* This avoids race conditions with usb_submit_urb()
1020 in the URB completition handler */ 1020 in the URB completition handler */
1021 spin_lock_irqsave(&cam->urb_lock, lock_flags); 1021 spin_lock_irqsave(&cam->urb_lock, lock_flags);
1022 cam->streaming = 0; 1022 cam->streaming = 0;
@@ -1050,7 +1050,7 @@ exit:
1050 1050
1051 1051
1052/*-------------------------------------------------------------------------- 1052/*--------------------------------------------------------------------------
1053 Write a W9968CF register. 1053 Write a W9968CF register.
1054 Return 0 on success, -1 otherwise. 1054 Return 0 on success, -1 otherwise.
1055 --------------------------------------------------------------------------*/ 1055 --------------------------------------------------------------------------*/
1056static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index) 1056static 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)
1059 int res; 1059 int res;
1060 1060
1061 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 1061 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
1062 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 1062 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
1063 value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT); 1063 value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT);
1064 1064
1065 if (res < 0) 1065 if (res < 0)
1066 DBG(4, "Failed to write a register " 1066 DBG(4, "Failed to write a register "
@@ -1072,7 +1072,7 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
1072 1072
1073 1073
1074/*-------------------------------------------------------------------------- 1074/*--------------------------------------------------------------------------
1075 Read a W9968CF register. 1075 Read a W9968CF register.
1076 Return the register value on success, -1 otherwise. 1076 Return the register value on success, -1 otherwise.
1077 --------------------------------------------------------------------------*/ 1077 --------------------------------------------------------------------------*/
1078static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index) 1078static 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)
1082 int res; 1082 int res;
1083 1083
1084 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1, 1084 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1,
1085 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1085 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1086 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT); 1086 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT);
1087 1087
1088 if (res < 0) 1088 if (res < 0)
1089 DBG(4, "Failed to read a register " 1089 DBG(4, "Failed to read a register "
@@ -1107,8 +1107,8 @@ static int w9968cf_write_fsb(struct w9968cf_device* cam, u16* data)
1107 value = *data++; 1107 value = *data++;
1108 1108
1109 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 1109 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
1110 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 1110 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
1111 value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT); 1111 value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT);
1112 1112
1113 if (res < 0) 1113 if (res < 0)
1114 DBG(4, "Failed to write the FSB registers " 1114 DBG(4, "Failed to write the FSB registers "
@@ -1287,9 +1287,9 @@ static int w9968cf_smbus_refresh_bus(struct w9968cf_device* cam)
1287 1287
1288 1288
1289/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ 1289/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */
1290static int 1290static int
1291w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam, 1291w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1292 u16 address, u8 subaddress,u8 value) 1292 u16 address, u8 subaddress,u8 value)
1293{ 1293{
1294 u16* data = cam->data_buffer; 1294 u16* data = cam->data_buffer;
1295 int err = 0; 1295 int err = 0;
@@ -1348,7 +1348,7 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1348 "value 0x%02X", address, subaddress, value) 1348 "value 0x%02X", address, subaddress, value)
1349 else 1349 else
1350 DBG(5, "I2C write byte data failed, addr.0x%04X, " 1350 DBG(5, "I2C write byte data failed, addr.0x%04X, "
1351 "subaddr.0x%02X, value 0x%02X", 1351 "subaddr.0x%02X, value 0x%02X",
1352 address, subaddress, value) 1352 address, subaddress, value)
1353 1353
1354 return err; 1354 return err;
@@ -1356,10 +1356,10 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1356 1356
1357 1357
1358/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ 1358/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */
1359static int 1359static int
1360w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam, 1360w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1361 u16 address, u8 subaddress, 1361 u16 address, u8 subaddress,
1362 u8* value) 1362 u8* value)
1363{ 1363{
1364 int err = 0; 1364 int err = 0;
1365 1365
@@ -1384,7 +1384,7 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1384 1384
1385 if (!err) 1385 if (!err)
1386 DBG(5, "I2C read byte data done, addr.0x%04X, " 1386 DBG(5, "I2C read byte data done, addr.0x%04X, "
1387 "subaddr.0x%02X, value 0x%02X", 1387 "subaddr.0x%02X, value 0x%02X",
1388 address, subaddress, *value) 1388 address, subaddress, *value)
1389 else 1389 else
1390 DBG(5, "I2C read byte data failed, addr.0x%04X, " 1390 DBG(5, "I2C read byte data failed, addr.0x%04X, "
@@ -1396,9 +1396,9 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1396 1396
1397 1397
1398/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */ 1398/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */
1399static int 1399static int
1400w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam, 1400w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1401 u16 address, u8* value) 1401 u16 address, u8* value)
1402{ 1402{
1403 int err = 0; 1403 int err = 0;
1404 1404
@@ -1411,7 +1411,7 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1411 err += w9968cf_smbus_read_byte(cam, value); 1411 err += w9968cf_smbus_read_byte(cam, value);
1412 err += w9968cf_smbus_write_ack(cam); 1412 err += w9968cf_smbus_write_ack(cam);
1413 err += w9968cf_smbus_stop(cam); 1413 err += w9968cf_smbus_stop(cam);
1414 1414
1415 /* Serial data disable */ 1415 /* Serial data disable */
1416 err += w9968cf_write_sb(cam, 0x0000); 1416 err += w9968cf_write_sb(cam, 0x0000);
1417 1417
@@ -1427,9 +1427,9 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1427 1427
1428 1428
1429/* SMBus protocol: S Addr Wr [A] Value [A] P */ 1429/* SMBus protocol: S Addr Wr [A] Value [A] P */
1430static int 1430static int
1431w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam, 1431w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
1432 u16 address, u8 value) 1432 u16 address, u8 value)
1433{ 1433{
1434 DBG(4, "i2c_write_byte() is an unsupported transfer mode") 1434 DBG(4, "i2c_write_byte() is an unsupported transfer mode")
1435 return -EINVAL; 1435 return -EINVAL;
@@ -1442,13 +1442,13 @@ w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
1442 ****************************************************************************/ 1442 ****************************************************************************/
1443 1443
1444static int 1444static int
1445w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 1445w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
1446 unsigned short flags, char read_write, u8 command, 1446 unsigned short flags, char read_write, u8 command,
1447 int size, union i2c_smbus_data *data) 1447 int size, union i2c_smbus_data *data)
1448{ 1448{
1449 struct w9968cf_device* cam = i2c_get_adapdata(adapter); 1449 struct w9968cf_device* cam = i2c_get_adapdata(adapter);
1450 u8 i; 1450 u8 i;
1451 int err = 0; 1451 int err = 0;
1452 1452
1453 switch (addr) { 1453 switch (addr) {
1454 case OV6xx0_SID: 1454 case OV6xx0_SID:
@@ -1464,20 +1464,20 @@ w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
1464 addr <<= 1; 1464 addr <<= 1;
1465 1465
1466 if (read_write == I2C_SMBUS_WRITE) 1466 if (read_write == I2C_SMBUS_WRITE)
1467 err = w9968cf_i2c_adap_write_byte(cam, addr, command); 1467 err = w9968cf_i2c_adap_write_byte(cam, addr, command);
1468 else if (read_write == I2C_SMBUS_READ) 1468 else if (read_write == I2C_SMBUS_READ)
1469 err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte); 1469 err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte);
1470 1470
1471 } else if (size == I2C_SMBUS_BYTE_DATA) { 1471 } else if (size == I2C_SMBUS_BYTE_DATA) {
1472 addr <<= 1; 1472 addr <<= 1;
1473 1473
1474 if (read_write == I2C_SMBUS_WRITE) 1474 if (read_write == I2C_SMBUS_WRITE)
1475 err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr, 1475 err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr,
1476 command, data->byte); 1476 command, data->byte);
1477 else if (read_write == I2C_SMBUS_READ) { 1477 else if (read_write == I2C_SMBUS_READ) {
1478 for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) { 1478 for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) {
1479 err = w9968cf_i2c_adap_read_byte_data(cam,addr, 1479 err = w9968cf_i2c_adap_read_byte_data(cam,addr,
1480 command, &data->byte); 1480 command, &data->byte);
1481 if (err) { 1481 if (err) {
1482 if (w9968cf_smbus_refresh_bus(cam)) { 1482 if (w9968cf_smbus_refresh_bus(cam)) {
1483 err = -EIO; 1483 err = -EIO;
@@ -1520,7 +1520,7 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1520 return err; 1520 return err;
1521 } 1521 }
1522 } else { 1522 } else {
1523 DBG(4, "Rejected client [%s] with driver [%s]", 1523 DBG(4, "Rejected client [%s] with driver [%s]",
1524 client->name, client->driver->driver.name) 1524 client->name, client->driver->driver.name)
1525 return -EINVAL; 1525 return -EINVAL;
1526 } 1526 }
@@ -1545,9 +1545,9 @@ static int w9968cf_i2c_detach_inform(struct i2c_client* client)
1545} 1545}
1546 1546
1547 1547
1548static int 1548static int
1549w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd, 1549w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd,
1550 unsigned long arg) 1550 unsigned long arg)
1551{ 1551{
1552 return 0; 1552 return 0;
1553} 1553}
@@ -1625,12 +1625,12 @@ static int w9968cf_turn_on_led(struct w9968cf_device* cam)
1625static int w9968cf_init_chip(struct w9968cf_device* cam) 1625static int w9968cf_init_chip(struct w9968cf_device* cam)
1626{ 1626{
1627 unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2, 1627 unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2,
1628 y0 = 0x0000, 1628 y0 = 0x0000,
1629 u0 = y0 + hw_bufsize/2, 1629 u0 = y0 + hw_bufsize/2,
1630 v0 = u0 + hw_bufsize/4, 1630 v0 = u0 + hw_bufsize/4,
1631 y1 = v0 + hw_bufsize/4, 1631 y1 = v0 + hw_bufsize/4,
1632 u1 = y1 + hw_bufsize/2, 1632 u1 = y1 + hw_bufsize/2,
1633 v1 = u1 + hw_bufsize/4; 1633 v1 = u1 + hw_bufsize/4;
1634 int err = 0; 1634 int err = 0;
1635 1635
1636 err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */ 1636 err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */
@@ -1762,7 +1762,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
1762 cam->vpp_flag = VPP_SWAP_YUV_BYTES; 1762 cam->vpp_flag = VPP_SWAP_YUV_BYTES;
1763 hw_palette = VIDEO_PALETTE_UYVY; 1763 hw_palette = VIDEO_PALETTE_UYVY;
1764 break; 1764 break;
1765 /* Original video is used instead of RGBX palettes. 1765 /* Original video is used instead of RGBX palettes.
1766 Software conversion later. */ 1766 Software conversion later. */
1767 case VIDEO_PALETTE_GREY: 1767 case VIDEO_PALETTE_GREY:
1768 case VIDEO_PALETTE_RGB555: 1768 case VIDEO_PALETTE_RGB555:
@@ -1777,7 +1777,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
1777 } 1777 }
1778 1778
1779 /* NOTE: due to memory issues, it is better to disable the hardware 1779 /* NOTE: due to memory issues, it is better to disable the hardware
1780 double buffering during compression */ 1780 double buffering during compression */
1781 if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION)) 1781 if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION))
1782 reg_v |= 0x0080; 1782 reg_v |= 0x0080;
1783 1783
@@ -1832,8 +1832,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1832 #define __UNSC(x) ((x) >> 10) 1832 #define __UNSC(x) ((x) >> 10)
1833 1833
1834 /* Make sure we are using a supported resolution */ 1834 /* Make sure we are using a supported resolution */
1835 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 1835 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
1836 (u16*)&win.height))) 1836 (u16*)&win.height)))
1837 goto error; 1837 goto error;
1838 1838
1839 /* Scaling factors */ 1839 /* Scaling factors */
@@ -1962,7 +1962,7 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1962 /* Settings changed, so we clear the frame buffers */ 1962 /* Settings changed, so we clear the frame buffers */
1963 memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size); 1963 memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size);
1964 1964
1965 DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)", 1965 DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)",
1966 win.width, win.height, win.x, win.y) 1966 win.width, win.height, win.x, win.y)
1967 1967
1968 PDBGG("x=%u ,y=%u, w=%u, h=%u, ax=%u, ay=%u, s_win.x=%u, s_win.y=%u, " 1968 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:
1978} 1978}
1979 1979
1980 1980
1981/*-------------------------------------------------------------------------- 1981/*--------------------------------------------------------------------------
1982 Adjust the asked values for window width and height. 1982 Adjust the asked values for window width and height.
1983 Return 0 on success, -1 otherwise. 1983 Return 0 on success, -1 otherwise.
1984 --------------------------------------------------------------------------*/ 1984 --------------------------------------------------------------------------*/
1985static int 1985static int
1986w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height) 1986w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
1987{ 1987{
1988 u16 maxw, maxh; 1988 u16 maxw, maxh;
@@ -1992,10 +1992,10 @@ w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
1992 1992
1993 maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && 1993 maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
1994 w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 1994 w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
1995 : cam->maxwidth; 1995 : cam->maxwidth;
1996 maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && 1996 maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
1997 w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) 1997 w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
1998 : cam->maxheight; 1998 : cam->maxheight;
1999 1999
2000 if (*width > maxw) 2000 if (*width > maxw)
2001 *width = maxw; 2001 *width = maxw;
@@ -2054,7 +2054,7 @@ static void w9968cf_push_frame(struct w9968cf_device* cam, u8 f_num)
2054 Read, store and remove the first pointer in the FIFO list of requested 2054 Read, store and remove the first pointer in the FIFO list of requested
2055 frames. This function is called in interrupt context. 2055 frames. This function is called in interrupt context.
2056 --------------------------------------------------------------------------*/ 2056 --------------------------------------------------------------------------*/
2057static void 2057static void
2058w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep) 2058w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
2059{ 2059{
2060 u8 i; 2060 u8 i;
@@ -2078,9 +2078,9 @@ w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
2078 High-level video post-processing routine on grabbed frames. 2078 High-level video post-processing routine on grabbed frames.
2079 Return 0 on success, a negative number otherwise. 2079 Return 0 on success, a negative number otherwise.
2080 --------------------------------------------------------------------------*/ 2080 --------------------------------------------------------------------------*/
2081static int 2081static int
2082w9968cf_postprocess_frame(struct w9968cf_device* cam, 2082w9968cf_postprocess_frame(struct w9968cf_device* cam,
2083 struct w9968cf_frame_t* fr) 2083 struct w9968cf_frame_t* fr)
2084{ 2084{
2085 void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp; 2085 void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp;
2086 u16 w = cam->window.width, 2086 u16 w = cam->window.width,
@@ -2127,7 +2127,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
2127 w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb); 2127 w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb);
2128 fr->length = (w*h*d)/8; 2128 fr->length = (w*h*d)/8;
2129 _PSWAP(pIn, pOut) 2129 _PSWAP(pIn, pOut)
2130 DBG(6, "UYVY-16bit to %s conversion done", 2130 DBG(6, "UYVY-16bit to %s conversion done",
2131 symbolic(v4l1_plist, fmt)) 2131 symbolic(v4l1_plist, fmt))
2132 } 2132 }
2133 2133
@@ -2143,7 +2143,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
2143 * Image sensor control routines * 2143 * Image sensor control routines *
2144 ****************************************************************************/ 2144 ****************************************************************************/
2145 2145
2146static int 2146static int
2147w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val) 2147w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
2148{ 2148{
2149 struct ovcamchip_control ctl; 2149 struct ovcamchip_control ctl;
@@ -2158,7 +2158,7 @@ w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
2158} 2158}
2159 2159
2160 2160
2161static int 2161static int
2162w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val) 2162w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val)
2163{ 2163{
2164 struct ovcamchip_control ctl; 2164 struct ovcamchip_control ctl;
@@ -2198,38 +2198,38 @@ static int w9968cf_sensor_update_settings(struct w9968cf_device* cam)
2198 int err = 0; 2198 int err = 0;
2199 2199
2200 /* Auto brightness */ 2200 /* Auto brightness */
2201 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT, 2201 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT,
2202 cam->auto_brt); 2202 cam->auto_brt);
2203 if (err) 2203 if (err)
2204 return err; 2204 return err;
2205 2205
2206 /* Auto exposure */ 2206 /* Auto exposure */
2207 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP, 2207 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP,
2208 cam->auto_exp); 2208 cam->auto_exp);
2209 if (err) 2209 if (err)
2210 return err; 2210 return err;
2211 2211
2212 /* Banding filter */ 2212 /* Banding filter */
2213 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT, 2213 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT,
2214 cam->bandfilt); 2214 cam->bandfilt);
2215 if (err) 2215 if (err)
2216 return err; 2216 return err;
2217 2217
2218 /* Light frequency */ 2218 /* Light frequency */
2219 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ, 2219 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ,
2220 cam->lightfreq); 2220 cam->lightfreq);
2221 if (err) 2221 if (err)
2222 return err; 2222 return err;
2223 2223
2224 /* Back light */ 2224 /* Back light */
2225 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT, 2225 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT,
2226 cam->backlight); 2226 cam->backlight);
2227 if (err) 2227 if (err)
2228 return err; 2228 return err;
2229 2229
2230 /* Mirror */ 2230 /* Mirror */
2231 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR, 2231 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR,
2232 cam->mirror); 2232 cam->mirror);
2233 if (err) 2233 if (err)
2234 return err; 2234 return err;
2235 2235
@@ -2281,15 +2281,15 @@ static int w9968cf_sensor_get_picture(struct w9968cf_device* cam)
2281 Returns: 0 on success, a negative number otherwise. 2281 Returns: 0 on success, a negative number otherwise.
2282 --------------------------------------------------------------------------*/ 2282 --------------------------------------------------------------------------*/
2283static int 2283static int
2284w9968cf_sensor_update_picture(struct w9968cf_device* cam, 2284w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2285 struct video_picture pict) 2285 struct video_picture pict)
2286{ 2286{
2287 int err = 0; 2287 int err = 0;
2288 2288
2289 if ((!cam->sensor_initialized) 2289 if ((!cam->sensor_initialized)
2290 || pict.contrast != cam->picture.contrast) { 2290 || pict.contrast != cam->picture.contrast) {
2291 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT, 2291 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT,
2292 pict.contrast); 2292 pict.contrast);
2293 if (err) 2293 if (err)
2294 goto fail; 2294 goto fail;
2295 DBG(4, "Contrast changed from %u to %u", 2295 DBG(4, "Contrast changed from %u to %u",
@@ -2297,10 +2297,10 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2297 cam->picture.contrast = pict.contrast; 2297 cam->picture.contrast = pict.contrast;
2298 } 2298 }
2299 2299
2300 if (((!cam->sensor_initialized) || 2300 if (((!cam->sensor_initialized) ||
2301 pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) { 2301 pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) {
2302 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT, 2302 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT,
2303 pict.brightness); 2303 pict.brightness);
2304 if (err) 2304 if (err)
2305 goto fail; 2305 goto fail;
2306 DBG(4, "Brightness changed from %u to %u", 2306 DBG(4, "Brightness changed from %u to %u",
@@ -2309,8 +2309,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2309 } 2309 }
2310 2310
2311 if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) { 2311 if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) {
2312 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT, 2312 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT,
2313 pict.colour); 2313 pict.colour);
2314 if (err) 2314 if (err)
2315 goto fail; 2315 goto fail;
2316 DBG(4, "Colour changed from %u to %u", 2316 DBG(4, "Colour changed from %u to %u",
@@ -2319,8 +2319,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2319 } 2319 }
2320 2320
2321 if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) { 2321 if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) {
2322 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE, 2322 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE,
2323 pict.hue); 2323 pict.hue);
2324 if (err) 2324 if (err)
2325 goto fail; 2325 goto fail;
2326 DBG(4, "Hue changed from %u to %u", 2326 DBG(4, "Hue changed from %u to %u",
@@ -2349,12 +2349,12 @@ static int w9968cf_sensor_init(struct w9968cf_device* cam)
2349{ 2349{
2350 int err = 0; 2350 int err = 0;
2351 2351
2352 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE, 2352 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE,
2353 &cam->monochrome))) 2353 &cam->monochrome)))
2354 goto error; 2354 goto error;
2355 2355
2356 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE, 2356 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE,
2357 &cam->sensor))) 2357 &cam->sensor)))
2358 goto error; 2358 goto error;
2359 2359
2360 /* NOTE: Make sure width and height are a multiple of 16 */ 2360 /* NOTE: Make sure width and height are a multiple of 16 */
@@ -2416,14 +2416,14 @@ error:
2416 2416
2417/*-------------------------------------------------------------------------- 2417/*--------------------------------------------------------------------------
2418 Fill some basic fields in the main device data structure. 2418 Fill some basic fields in the main device data structure.
2419 This function is called once on w9968cf_usb_probe() for each recognized 2419 This function is called once on w9968cf_usb_probe() for each recognized
2420 camera. 2420 camera.
2421 --------------------------------------------------------------------------*/ 2421 --------------------------------------------------------------------------*/
2422static void 2422static void
2423w9968cf_configure_camera(struct w9968cf_device* cam, 2423w9968cf_configure_camera(struct w9968cf_device* cam,
2424 struct usb_device* udev, 2424 struct usb_device* udev,
2425 enum w9968cf_model_id mod_id, 2425 enum w9968cf_model_id mod_id,
2426 const unsigned short dev_nr) 2426 const unsigned short dev_nr)
2427{ 2427{
2428 mutex_init(&cam->fileop_mutex); 2428 mutex_init(&cam->fileop_mutex);
2429 init_waitqueue_head(&cam->open); 2429 init_waitqueue_head(&cam->open);
@@ -2444,60 +2444,60 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2444 packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1]; 2444 packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1];
2445 cam->altsetting++); 2445 cam->altsetting++);
2446 2446
2447 cam->max_buffers = (max_buffers[dev_nr] < 2 || 2447 cam->max_buffers = (max_buffers[dev_nr] < 2 ||
2448 max_buffers[dev_nr] > W9968CF_MAX_BUFFERS) 2448 max_buffers[dev_nr] > W9968CF_MAX_BUFFERS)
2449 ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr]; 2449 ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr];
2450 2450
2451 cam->double_buffer = (double_buffer[dev_nr] == 0 || 2451 cam->double_buffer = (double_buffer[dev_nr] == 0 ||
2452 double_buffer[dev_nr] == 1) 2452 double_buffer[dev_nr] == 1)
2453 ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER; 2453 ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER;
2454 2454
2455 cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1) 2455 cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1)
2456 ? (u8)clamping[dev_nr] : W9968CF_CLAMPING; 2456 ? (u8)clamping[dev_nr] : W9968CF_CLAMPING;
2457 2457
2458 cam->filter_type = (filter_type[dev_nr] == 0 || 2458 cam->filter_type = (filter_type[dev_nr] == 0 ||
2459 filter_type[dev_nr] == 1 || 2459 filter_type[dev_nr] == 1 ||
2460 filter_type[dev_nr] == 2) 2460 filter_type[dev_nr] == 2)
2461 ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE; 2461 ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE;
2462 2462
2463 cam->capture = 1; 2463 cam->capture = 1;
2464 2464
2465 cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1) 2465 cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1)
2466 ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW; 2466 ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW;
2467 2467
2468 cam->decompression = (decompression[dev_nr] == 0 || 2468 cam->decompression = (decompression[dev_nr] == 0 ||
2469 decompression[dev_nr] == 1 || 2469 decompression[dev_nr] == 1 ||
2470 decompression[dev_nr] == 2) 2470 decompression[dev_nr] == 2)
2471 ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION; 2471 ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION;
2472 2472
2473 cam->upscaling = (upscaling[dev_nr] == 0 || 2473 cam->upscaling = (upscaling[dev_nr] == 0 ||
2474 upscaling[dev_nr] == 1) 2474 upscaling[dev_nr] == 1)
2475 ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING; 2475 ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING;
2476 2476
2477 cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1) 2477 cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1)
2478 ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT; 2478 ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT;
2479 2479
2480 cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1) 2480 cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1)
2481 ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP; 2481 ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP;
2482 2482
2483 cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60) 2483 cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60)
2484 ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ; 2484 ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ;
2485 2485
2486 cam->bandfilt = (bandingfilter[dev_nr] == 0 || 2486 cam->bandfilt = (bandingfilter[dev_nr] == 0 ||
2487 bandingfilter[dev_nr] == 1) 2487 bandingfilter[dev_nr] == 1)
2488 ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER; 2488 ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER;
2489 2489
2490 cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1) 2490 cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1)
2491 ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT; 2491 ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT;
2492 2492
2493 cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0) 2493 cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0)
2494 ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV; 2494 ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV;
2495 2495
2496 cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1) 2496 cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1)
2497 ? (u8)mirror[dev_nr] : W9968CF_MIRROR; 2497 ? (u8)mirror[dev_nr] : W9968CF_MIRROR;
2498 2498
2499 cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1) 2499 cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1)
2500 ? monochrome[dev_nr] : W9968CF_MONOCHROME; 2500 ? monochrome[dev_nr] : W9968CF_MONOCHROME;
2501 2501
2502 cam->picture.brightness = (u16)brightness[dev_nr]; 2502 cam->picture.brightness = (u16)brightness[dev_nr];
2503 cam->picture.hue = (u16)hue[dev_nr]; 2503 cam->picture.hue = (u16)hue[dev_nr];
@@ -2519,7 +2519,7 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2519 cam->picture.depth = w9968cf_valid_depth(cam->picture.palette); 2519 cam->picture.depth = w9968cf_valid_depth(cam->picture.palette);
2520 2520
2521 cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1) 2521 cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1)
2522 ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB; 2522 ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB;
2523 2523
2524 cam->window.x = 0; 2524 cam->window.x = 0;
2525 cam->window.y = 0; 2525 cam->window.y = 0;
@@ -2531,16 +2531,16 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2531 2531
2532 DBG(3, "%s configured with settings #%u:", 2532 DBG(3, "%s configured with settings #%u:",
2533 symbolic(camlist, cam->id), dev_nr) 2533 symbolic(camlist, cam->id), dev_nr)
2534 2534
2535 DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes", 2535 DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes",
2536 wMaxPacketSize[cam->altsetting-1]) 2536 wMaxPacketSize[cam->altsetting-1])
2537 2537
2538 DBG(3, "- Number of requested video frame buffers: %u", 2538 DBG(3, "- Number of requested video frame buffers: %u",
2539 cam->max_buffers) 2539 cam->max_buffers)
2540 2540
2541 if (cam->double_buffer) 2541 if (cam->double_buffer)
2542 DBG(3, "- Hardware double buffering enabled") 2542 DBG(3, "- Hardware double buffering enabled")
2543 else 2543 else
2544 DBG(3, "- Hardware double buffering disabled") 2544 DBG(3, "- Hardware double buffering disabled")
2545 2545
2546 if (cam->filter_type == 0) 2546 if (cam->filter_type == 0)
@@ -2648,7 +2648,7 @@ static void w9968cf_adjust_configuration(struct w9968cf_device* cam)
2648 2648
2649/*-------------------------------------------------------------------------- 2649/*--------------------------------------------------------------------------
2650 Release the resources used by the driver. 2650 Release the resources used by the driver.
2651 This function is called on disconnect 2651 This function is called on disconnect
2652 (or on close if deallocation has been deferred) 2652 (or on close if deallocation has been deferred)
2653 --------------------------------------------------------------------------*/ 2653 --------------------------------------------------------------------------*/
2654static void w9968cf_release_resources(struct w9968cf_device* cam) 2654static void w9968cf_release_resources(struct w9968cf_device* cam)
@@ -2706,8 +2706,8 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2706 } 2706 }
2707 mutex_unlock(&cam->dev_mutex); 2707 mutex_unlock(&cam->dev_mutex);
2708 err = wait_event_interruptible_exclusive(cam->open, 2708 err = wait_event_interruptible_exclusive(cam->open,
2709 cam->disconnected || 2709 cam->disconnected ||
2710 !cam->users); 2710 !cam->users);
2711 if (err) { 2711 if (err) {
2712 up_read(&w9968cf_disconnect); 2712 up_read(&w9968cf_disconnect);
2713 return err; 2713 return err;
@@ -2820,9 +2820,9 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
2820 w9968cf_push_frame(cam, 1); 2820 w9968cf_push_frame(cam, 1);
2821 2821
2822 err = wait_event_interruptible(cam->wait_queue, 2822 err = wait_event_interruptible(cam->wait_queue,
2823 cam->frame[0].status == F_READY || 2823 cam->frame[0].status == F_READY ||
2824 cam->frame[1].status == F_READY || 2824 cam->frame[1].status == F_READY ||
2825 cam->disconnected); 2825 cam->disconnected);
2826 if (err) { 2826 if (err) {
2827 mutex_unlock(&cam->fileop_mutex); 2827 mutex_unlock(&cam->fileop_mutex);
2828 return err; 2828 return err;
@@ -2859,12 +2859,12 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
2859static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma) 2859static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2860{ 2860{
2861 struct w9968cf_device* cam = (struct w9968cf_device*) 2861 struct w9968cf_device* cam = (struct w9968cf_device*)
2862 video_get_drvdata(video_devdata(filp)); 2862 video_get_drvdata(video_devdata(filp));
2863 unsigned long vsize = vma->vm_end - vma->vm_start, 2863 unsigned long vsize = vma->vm_end - vma->vm_start,
2864 psize = cam->nbuffers * cam->frame[0].size, 2864 psize = cam->nbuffers * cam->frame[0].size,
2865 start = vma->vm_start, 2865 start = vma->vm_start,
2866 pos = (unsigned long)cam->frame[0].buffer, 2866 pos = (unsigned long)cam->frame[0].buffer,
2867 page; 2867 page;
2868 2868
2869 if (cam->disconnected) { 2869 if (cam->disconnected) {
2870 DBG(2, "Device not present") 2870 DBG(2, "Device not present")
@@ -2898,7 +2898,7 @@ static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2898 2898
2899static int 2899static int
2900w9968cf_ioctl(struct inode* inode, struct file* filp, 2900w9968cf_ioctl(struct inode* inode, struct file* filp,
2901 unsigned int cmd, unsigned long arg) 2901 unsigned int cmd, unsigned long arg)
2902{ 2902{
2903 struct w9968cf_device* cam; 2903 struct w9968cf_device* cam;
2904 int err; 2904 int err;
@@ -2928,21 +2928,21 @@ w9968cf_ioctl(struct inode* inode, struct file* filp,
2928 2928
2929 2929
2930static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp, 2930static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2931 unsigned int cmd, void __user * arg) 2931 unsigned int cmd, void __user * arg)
2932{ 2932{
2933 struct w9968cf_device* cam; 2933 struct w9968cf_device* cam;
2934 const char* v4l1_ioctls[] = { 2934 const char* v4l1_ioctls[] = {
2935 "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", 2935 "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER",
2936 "GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF", 2936 "GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF",
2937 "SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO", 2937 "SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO",
2938 "SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE", 2938 "SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE",
2939 "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE", 2939 "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE",
2940 "GVBIFMT", "SVBIFMT" 2940 "GVBIFMT", "SVBIFMT"
2941 }; 2941 };
2942 2942
2943 #define V4L1_IOCTL(cmd) \ 2943 #define V4L1_IOCTL(cmd) \
2944 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \ 2944 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
2945 v4l1_ioctls[_IOC_NR((cmd))] : "?") 2945 v4l1_ioctls[_IOC_NR((cmd))] : "?")
2946 2946
2947 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); 2947 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
2948 2948
@@ -2957,14 +2957,14 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2957 .minwidth = cam->minwidth, 2957 .minwidth = cam->minwidth,
2958 .minheight = cam->minheight, 2958 .minheight = cam->minheight,
2959 }; 2959 };
2960 sprintf(cap.name, "W996[87]CF USB Camera #%d", 2960 sprintf(cap.name, "W996[87]CF USB Camera #%d",
2961 cam->v4ldev->minor); 2961 cam->v4ldev->minor);
2962 cap.maxwidth = (cam->upscaling && w9968cf_vpp) 2962 cap.maxwidth = (cam->upscaling && w9968cf_vpp)
2963 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 2963 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
2964 : cam->maxwidth; 2964 : cam->maxwidth;
2965 cap.maxheight = (cam->upscaling && w9968cf_vpp) 2965 cap.maxheight = (cam->upscaling && w9968cf_vpp)
2966 ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) 2966 ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
2967 : cam->maxheight; 2967 : cam->maxheight;
2968 2968
2969 if (copy_to_user(arg, &cap, sizeof(cap))) 2969 if (copy_to_user(arg, &cap, sizeof(cap)))
2970 return -EFAULT; 2970 return -EFAULT;
@@ -3029,7 +3029,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3029 if (copy_from_user(&pict, arg, sizeof(pict))) 3029 if (copy_from_user(&pict, arg, sizeof(pict)))
3030 return -EFAULT; 3030 return -EFAULT;
3031 3031
3032 if ( (cam->force_palette || !w9968cf_vpp) 3032 if ( (cam->force_palette || !w9968cf_vpp)
3033 && pict.palette != cam->picture.palette ) { 3033 && pict.palette != cam->picture.palette ) {
3034 DBG(4, "Palette %s rejected: only %s is allowed", 3034 DBG(4, "Palette %s rejected: only %s is allowed",
3035 symbolic(v4l1_plist, pict.palette), 3035 symbolic(v4l1_plist, pict.palette),
@@ -3046,24 +3046,24 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3046 if (!cam->force_palette) { 3046 if (!cam->force_palette) {
3047 if (cam->decompression == 0) { 3047 if (cam->decompression == 0) {
3048 if (w9968cf_need_decompression(pict.palette)) { 3048 if (w9968cf_need_decompression(pict.palette)) {
3049 DBG(4, "Decompression disabled: palette %s is not " 3049 DBG(4, "Decompression disabled: palette %s is not "
3050 "allowed. VIDIOCSPICT failed", 3050 "allowed. VIDIOCSPICT failed",
3051 symbolic(v4l1_plist, pict.palette)) 3051 symbolic(v4l1_plist, pict.palette))
3052 return -EINVAL; 3052 return -EINVAL;
3053 } 3053 }
3054 } else if (cam->decompression == 1) { 3054 } else if (cam->decompression == 1) {
3055 if (!w9968cf_need_decompression(pict.palette)) { 3055 if (!w9968cf_need_decompression(pict.palette)) {
3056 DBG(4, "Decompression forced: palette %s is not " 3056 DBG(4, "Decompression forced: palette %s is not "
3057 "allowed. VIDIOCSPICT failed", 3057 "allowed. VIDIOCSPICT failed",
3058 symbolic(v4l1_plist, pict.palette)) 3058 symbolic(v4l1_plist, pict.palette))
3059 return -EINVAL; 3059 return -EINVAL;
3060 } 3060 }
3061 } 3061 }
3062 } 3062 }
3063 3063
3064 if (pict.depth != w9968cf_valid_depth(pict.palette)) { 3064 if (pict.depth != w9968cf_valid_depth(pict.palette)) {
3065 DBG(4, "Requested depth %u bpp is not valid for %s " 3065 DBG(4, "Requested depth %u bpp is not valid for %s "
3066 "palette: ignored and changed to %u bpp", 3066 "palette: ignored and changed to %u bpp",
3067 pict.depth, symbolic(v4l1_plist, pict.palette), 3067 pict.depth, symbolic(v4l1_plist, pict.palette),
3068 w9968cf_valid_depth(pict.palette)) 3068 w9968cf_valid_depth(pict.palette))
3069 pict.depth = w9968cf_valid_depth(pict.palette); 3069 pict.depth = w9968cf_valid_depth(pict.palette);
@@ -3074,9 +3074,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3074 || cam->frame_current->queued) { 3074 || cam->frame_current->queued) {
3075 err = wait_event_interruptible 3075 err = wait_event_interruptible
3076 ( cam->wait_queue, 3076 ( cam->wait_queue,
3077 cam->disconnected || 3077 cam->disconnected ||
3078 (!*cam->requested_frame && 3078 (!*cam->requested_frame &&
3079 !cam->frame_current->queued) ); 3079 !cam->frame_current->queued) );
3080 if (err) 3080 if (err)
3081 return err; 3081 return err;
3082 if (cam->disconnected) 3082 if (cam->disconnected)
@@ -3116,7 +3116,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3116 return -EINVAL; 3116 return -EINVAL;
3117 3117
3118 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 3118 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
3119 (u16*)&win.height))) { 3119 (u16*)&win.height))) {
3120 DBG(4, "Resolution not supported (%ux%u). " 3120 DBG(4, "Resolution not supported (%ux%u). "
3121 "VIDIOCSWIN failed", win.width, win.height) 3121 "VIDIOCSWIN failed", win.width, win.height)
3122 return err; 3122 return err;
@@ -3130,9 +3130,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3130 || cam->frame_current->queued) { 3130 || cam->frame_current->queued) {
3131 err = wait_event_interruptible 3131 err = wait_event_interruptible
3132 ( cam->wait_queue, 3132 ( cam->wait_queue,
3133 cam->disconnected || 3133 cam->disconnected ||
3134 (!*cam->requested_frame && 3134 (!*cam->requested_frame &&
3135 !cam->frame_current->queued) ); 3135 !cam->frame_current->queued) );
3136 if (err) 3136 if (err)
3137 return err; 3137 return err;
3138 if (cam->disconnected) 3138 if (cam->disconnected)
@@ -3175,7 +3175,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3175 mbuf.frames = cam->nbuffers; 3175 mbuf.frames = cam->nbuffers;
3176 for (i = 0; i < cam->nbuffers; i++) 3176 for (i = 0; i < cam->nbuffers; i++)
3177 mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer - 3177 mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer -
3178 (unsigned long)cam->frame[0].buffer; 3178 (unsigned long)cam->frame[0].buffer;
3179 3179
3180 if (copy_to_user(arg, &mbuf, sizeof(mbuf))) 3180 if (copy_to_user(arg, &mbuf, sizeof(mbuf)))
3181 return -EFAULT; 3181 return -EFAULT;
@@ -3194,7 +3194,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3194 return -EFAULT; 3194 return -EFAULT;
3195 3195
3196 DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d", 3196 DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d",
3197 mmap.frame, symbolic(v4l1_plist, mmap.format), 3197 mmap.frame, symbolic(v4l1_plist, mmap.format),
3198 mmap.width, mmap.height) 3198 mmap.width, mmap.height)
3199 3199
3200 if (mmap.frame >= cam->nbuffers) { 3200 if (mmap.frame >= cam->nbuffers) {
@@ -3203,7 +3203,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3203 return -EINVAL; 3203 return -EINVAL;
3204 } 3204 }
3205 3205
3206 if (mmap.format!=cam->picture.palette && 3206 if (mmap.format!=cam->picture.palette &&
3207 (cam->force_palette || !w9968cf_vpp)) { 3207 (cam->force_palette || !w9968cf_vpp)) {
3208 DBG(4, "Palette %s rejected: only %s is allowed", 3208 DBG(4, "Palette %s rejected: only %s is allowed",
3209 symbolic(v4l1_plist, mmap.format), 3209 symbolic(v4l1_plist, mmap.format),
@@ -3213,7 +3213,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3213 3213
3214 if (!w9968cf_valid_palette(mmap.format)) { 3214 if (!w9968cf_valid_palette(mmap.format)) {
3215 DBG(4, "Palette %s not supported. " 3215 DBG(4, "Palette %s not supported. "
3216 "VIDIOCMCAPTURE failed", 3216 "VIDIOCMCAPTURE failed",
3217 symbolic(v4l1_plist, mmap.format)) 3217 symbolic(v4l1_plist, mmap.format))
3218 return -EINVAL; 3218 return -EINVAL;
3219 } 3219 }
@@ -3221,23 +3221,23 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3221 if (!cam->force_palette) { 3221 if (!cam->force_palette) {
3222 if (cam->decompression == 0) { 3222 if (cam->decompression == 0) {
3223 if (w9968cf_need_decompression(mmap.format)) { 3223 if (w9968cf_need_decompression(mmap.format)) {
3224 DBG(4, "Decompression disabled: palette %s is not " 3224 DBG(4, "Decompression disabled: palette %s is not "
3225 "allowed. VIDIOCSPICT failed", 3225 "allowed. VIDIOCSPICT failed",
3226 symbolic(v4l1_plist, mmap.format)) 3226 symbolic(v4l1_plist, mmap.format))
3227 return -EINVAL; 3227 return -EINVAL;
3228 } 3228 }
3229 } else if (cam->decompression == 1) { 3229 } else if (cam->decompression == 1) {
3230 if (!w9968cf_need_decompression(mmap.format)) { 3230 if (!w9968cf_need_decompression(mmap.format)) {
3231 DBG(4, "Decompression forced: palette %s is not " 3231 DBG(4, "Decompression forced: palette %s is not "
3232 "allowed. VIDIOCSPICT failed", 3232 "allowed. VIDIOCSPICT failed",
3233 symbolic(v4l1_plist, mmap.format)) 3233 symbolic(v4l1_plist, mmap.format))
3234 return -EINVAL; 3234 return -EINVAL;
3235 } 3235 }
3236 } 3236 }
3237 } 3237 }
3238 3238
3239 if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width, 3239 if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width,
3240 (u16*)&mmap.height))) { 3240 (u16*)&mmap.height))) {
3241 DBG(4, "Resolution not supported (%dx%d). " 3241 DBG(4, "Resolution not supported (%dx%d). "
3242 "VIDIOCMCAPTURE failed", 3242 "VIDIOCMCAPTURE failed",
3243 mmap.width, mmap.height) 3243 mmap.width, mmap.height)
@@ -3258,12 +3258,12 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3258 DBG(6, "VIDIOCMCAPTURE. Change settings for " 3258 DBG(6, "VIDIOCMCAPTURE. Change settings for "
3259 "frame #%u: %dx%d, format %s. Wait...", 3259 "frame #%u: %dx%d, format %s. Wait...",
3260 mmap.frame, mmap.width, mmap.height, 3260 mmap.frame, mmap.width, mmap.height,
3261 symbolic(v4l1_plist, mmap.format)) 3261 symbolic(v4l1_plist, mmap.format))
3262 err = wait_event_interruptible 3262 err = wait_event_interruptible
3263 ( cam->wait_queue, 3263 ( cam->wait_queue,
3264 cam->disconnected || 3264 cam->disconnected ||
3265 (!*cam->requested_frame && 3265 (!*cam->requested_frame &&
3266 !cam->frame_current->queued) ); 3266 !cam->frame_current->queued) );
3267 if (err) 3267 if (err)
3268 return err; 3268 return err;
3269 if (cam->disconnected) 3269 if (cam->disconnected)
@@ -3280,7 +3280,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3280 goto ioctl_fail; 3280 goto ioctl_fail;
3281 3281
3282 /* This before set_window */ 3282 /* This before set_window */
3283 if (w9968cf_set_picture(cam, pict)) 3283 if (w9968cf_set_picture(cam, pict))
3284 goto ioctl_fail; 3284 goto ioctl_fail;
3285 3285
3286 if (w9968cf_set_window(cam, win)) 3286 if (w9968cf_set_window(cam, win))
@@ -3292,10 +3292,10 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3292 } else if (fr->queued) { 3292 } else if (fr->queued) {
3293 3293
3294 DBG(6, "Wait until frame #%u is free", mmap.frame) 3294 DBG(6, "Wait until frame #%u is free", mmap.frame)
3295 3295
3296 err = wait_event_interruptible(cam->wait_queue, 3296 err = wait_event_interruptible(cam->wait_queue,
3297 cam->disconnected || 3297 cam->disconnected ||
3298 (!fr->queued)); 3298 (!fr->queued));
3299 if (err) 3299 if (err)
3300 return err; 3300 return err;
3301 if (cam->disconnected) 3301 if (cam->disconnected)
@@ -3335,9 +3335,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3335 } 3335 }
3336 case F_ERROR: 3336 case F_ERROR:
3337 case F_GRABBING: 3337 case F_GRABBING:
3338 err = wait_event_interruptible(cam->wait_queue, 3338 err = wait_event_interruptible(cam->wait_queue,
3339 (fr->status == F_READY) 3339 (fr->status == F_READY)
3340 || cam->disconnected); 3340 || cam->disconnected);
3341 if (err) 3341 if (err)
3342 return err; 3342 return err;
3343 if (cam->disconnected) 3343 if (cam->disconnected)
@@ -3439,7 +3439,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3439 DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s " 3439 DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s "
3440 "(type 0x%01X, " 3440 "(type 0x%01X, "
3441 "n. 0x%01X, " 3441 "n. 0x%01X, "
3442 "dir. 0x%01X, " 3442 "dir. 0x%01X, "
3443 "size 0x%02X)", 3443 "size 0x%02X)",
3444 V4L1_IOCTL(cmd), 3444 V4L1_IOCTL(cmd),
3445 _IOC_TYPE(cmd),_IOC_NR(cmd),_IOC_DIR(cmd),_IOC_SIZE(cmd)) 3445 _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)
3499 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct) 3499 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct)
3500 mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */ 3500 mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */
3501 else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor && 3501 else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor &&
3502 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct) 3502 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct)
3503 mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */ 3503 mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */
3504 else 3504 else
3505 return -ENODEV; 3505 return -ENODEV;
3506 3506
3507 cam = (struct w9968cf_device*) 3507 cam = (struct w9968cf_device*)
3508 kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL); 3508 kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL);
3509 if (!cam) 3509 if (!cam)
3510 return -ENOMEM; 3510 return -ENOMEM;
3511 3511
@@ -3569,7 +3569,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3569 cam->v4ldev->dev = &cam->dev; 3569 cam->v4ldev->dev = &cam->dev;
3570 3570
3571 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 3571 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
3572 video_nr[dev_nr]); 3572 video_nr[dev_nr]);
3573 if (err) { 3573 if (err) {
3574 DBG(1, "V4L device registration failed") 3574 DBG(1, "V4L device registration failed")
3575 if (err == -ENFILE && video_nr[dev_nr] == -1) 3575 if (err == -ENFILE && video_nr[dev_nr] == -1)
@@ -3611,7 +3611,7 @@ fail: /* Free unused memory */
3611 3611
3612static void w9968cf_usb_disconnect(struct usb_interface* intf) 3612static void w9968cf_usb_disconnect(struct usb_interface* intf)
3613{ 3613{
3614 struct w9968cf_device* cam = 3614 struct w9968cf_device* cam =
3615 (struct w9968cf_device*)usb_get_intfdata(intf); 3615 (struct w9968cf_device*)usb_get_intfdata(intf);
3616 3616
3617 down_write(&w9968cf_disconnect); 3617 down_write(&w9968cf_disconnect);
diff --git a/drivers/usb/media/w9968cf.h b/drivers/media/video/w9968cf.h
index a87be719a281..2836b45ec206 100644
--- a/drivers/usb/media/w9968cf.h
+++ b/drivers/media/video/w9968cf.h
@@ -61,7 +61,7 @@
61 61
62/* Maximum data payload sizes in bytes for alternate settings */ 62/* Maximum data payload sizes in bytes for alternate settings */
63static const u16 wMaxPacketSize[] = {1023, 959, 895, 831, 767, 703, 639, 575, 63static const u16 wMaxPacketSize[] = {1023, 959, 895, 831, 767, 703, 639, 575,
64 511, 447, 383, 319, 255, 191, 127, 63}; 64 511, 447, 383, 319, 255, 191, 127, 63};
65#define W9968CF_PACKET_SIZE 1023 /* according to wMaxPacketSizes[] */ 65#define W9968CF_PACKET_SIZE 1023 /* according to wMaxPacketSizes[] */
66#define W9968CF_MIN_PACKET_SIZE 63 /* minimum value */ 66#define W9968CF_MIN_PACKET_SIZE 63 /* minimum value */
67#define W9968CF_ISO_PACKETS 5 /* n.of packets for isochronous transfers */ 67#define W9968CF_ISO_PACKETS 5 /* n.of packets for isochronous transfers */
@@ -134,7 +134,7 @@ static const struct w9968cf_format w9968cf_formatlist[] = {
134 ****************************************************************************/ 134 ****************************************************************************/
135 135
136#define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \ 136#define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \
137 "Dual Mode Camera Chip" 137 "Dual Mode Camera Chip"
138#define W9968CF_MODULE_VERSION "1:1.33-basic" 138#define W9968CF_MODULE_VERSION "1:1.33-basic"
139#define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia" 139#define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia"
140#define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 140#define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
@@ -270,9 +270,9 @@ struct w9968cf_device {
270 270
271 /* Locks */ 271 /* Locks */
272 struct mutex dev_mutex, /* for probe, disconnect,open and close */ 272 struct mutex dev_mutex, /* for probe, disconnect,open and close */
273 fileop_mutex; /* for read and ioctl */ 273 fileop_mutex; /* for read and ioctl */
274 spinlock_t urb_lock, /* for submit_urb() and unlink_urb() */ 274 spinlock_t urb_lock, /* for submit_urb() and unlink_urb() */
275 flist_lock; /* for requested frame list accesses */ 275 flist_lock; /* for requested frame list accesses */
276 wait_queue_head_t open, wait_queue; 276 wait_queue_head_t open, wait_queue;
277 277
278 char command[16]; /* name of the program holding the device */ 278 char command[16]; /* name of the program holding the device */
@@ -299,7 +299,7 @@ struct w9968cf_device {
299 dev_warn(&cam->dev, fmt "\n", ## args); \ 299 dev_warn(&cam->dev, fmt "\n", ## args); \
300 else if ((level) >= 5) \ 300 else if ((level) >= 5) \
301 dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ 301 dev_info(&cam->dev, "[%s:%d] " fmt "\n", \
302 __FUNCTION__, __LINE__ , ## args); \ 302 __FUNCTION__, __LINE__ , ## args); \
303 } \ 303 } \
304} 304}
305/* For generic kernel (not device specific) messages */ 305/* For generic kernel (not device specific) messages */
@@ -311,7 +311,7 @@ struct w9968cf_device {
311 pr_info("w9968cf: " fmt "\n", ## args); \ 311 pr_info("w9968cf: " fmt "\n", ## args); \
312 else if ((level) >= 5) \ 312 else if ((level) >= 5) \
313 pr_debug("w9968cf: [%s:%d] " fmt "\n", __FUNCTION__, \ 313 pr_debug("w9968cf: [%s:%d] " fmt "\n", __FUNCTION__, \
314 __LINE__ , ## args); \ 314 __LINE__ , ## args); \
315 } \ 315 } \
316} 316}
317#else 317#else
diff --git a/drivers/usb/media/w9968cf_decoder.h b/drivers/media/video/w9968cf_decoder.h
index 31faccbe8f03..59decbfc540a 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] = {
78#define W9968CF_DEC_ERR_NO_EOI -6 78#define W9968CF_DEC_ERR_NO_EOI -6
79 79
80extern void w9968cf_init_decoder(void); 80extern void w9968cf_init_decoder(void);
81extern int w9968cf_check_headers(const unsigned char* Pin, 81extern int w9968cf_check_headers(const unsigned char* Pin,
82 const unsigned long BUF_SIZE); 82 const unsigned long BUF_SIZE);
83extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE, 83extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE,
84 const unsigned W, const unsigned H, char* Pout); 84 const unsigned W, const unsigned H, char* Pout);
85 85
86#endif /* _W9968CF_DECODER_H_ */ 86#endif /* _W9968CF_DECODER_H_ */
diff --git a/drivers/usb/media/w9968cf_vpp.h b/drivers/media/video/w9968cf_vpp.h
index f3b91b782671..88c9b6c0cc36 100644
--- a/drivers/usb/media/w9968cf_vpp.h
+++ b/drivers/media/video/w9968cf_vpp.h
@@ -29,7 +29,7 @@ struct w9968cf_vpp_t {
29 struct module* owner; 29 struct module* owner;
30 int (*check_headers)(const unsigned char*, const unsigned long); 30 int (*check_headers)(const unsigned char*, const unsigned long);
31 int (*decode)(const char*, const unsigned long, const unsigned, 31 int (*decode)(const char*, const unsigned long, const unsigned,
32 const unsigned, char*); 32 const unsigned, char*);
33 void (*swap_yuvbytes)(void*, unsigned long); 33 void (*swap_yuvbytes)(void*, unsigned long);
34 void (*uyvy_to_rgbx)(u8*, unsigned long, u8*, u16, u8); 34 void (*uyvy_to_rgbx)(u8*, unsigned long, u8*, u16, u8);
35 void (*scale_up)(u8*, u8*, u16, u16, u16, u16, u16); 35 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 8cb64f8a8a91..d81a88bbe43d 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,
79 void *arg) 79 void *arg)
80{ 80{
81 struct wm8775_state *state = i2c_get_clientdata(client); 81 struct wm8775_state *state = i2c_get_clientdata(client);
82 struct v4l2_audio *input = arg; 82 struct v4l2_routing *route = arg;
83 struct v4l2_control *ctrl = arg; 83 struct v4l2_control *ctrl = arg;
84 84
85 switch (cmd) { 85 switch (cmd) {
86 case VIDIOC_S_AUDIO: 86 case VIDIOC_INT_G_AUDIO_ROUTING:
87 route->input = state->input;
88 route->output = 0;
89 break;
90
91 case VIDIOC_INT_S_AUDIO_ROUTING:
87 /* There are 4 inputs and one output. Zero or more inputs 92 /* There are 4 inputs and one output. Zero or more inputs
88 are multiplexed together to the output. Hence there are 93 are multiplexed together to the output. Hence there are
89 16 combinations. 94 16 combinations.
90 If only one input is active (the normal case) then the 95 If only one input is active (the normal case) then the
91 input values 1, 2, 4 or 8 should be used. */ 96 input values 1, 2, 4 or 8 should be used. */
92 if (input->index > 15) { 97 if (route->input > 15) {
93 v4l_err(client, "Invalid input %d.\n", input->index); 98 v4l_err(client, "Invalid input %d.\n", route->input);
94 return -EINVAL; 99 return -EINVAL;
95 } 100 }
96 state->input = input->index; 101 state->input = route->input;
97 if (state->muted) 102 if (state->muted)
98 break; 103 break;
99 wm8775_write(client, R21, 0x0c0); 104 wm8775_write(client, R21, 0x0c0);
@@ -102,11 +107,6 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
102 wm8775_write(client, R21, 0x100 + state->input); 107 wm8775_write(client, R21, 0x100 + state->input);
103 break; 108 break;
104 109
105 case VIDIOC_G_AUDIO:
106 memset(input, 0, sizeof(*input));
107 input->index = state->input;
108 break;
109
110 case VIDIOC_G_CTRL: 110 case VIDIOC_G_CTRL:
111 if (ctrl->id != V4L2_CID_AUDIO_MUTE) 111 if (ctrl->id != V4L2_CID_AUDIO_MUTE)
112 return -EINVAL; 112 return -EINVAL;
diff --git a/drivers/media/video/zc0301/Makefile b/drivers/media/video/zc0301/Makefile
new file mode 100644
index 000000000000..d749199d8f06
--- /dev/null
+++ b/drivers/media/video/zc0301/Makefile
@@ -0,0 +1,3 @@
1zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
2
3obj-$(CONFIG_USB_ZC0301) += zc0301.o
diff --git a/drivers/usb/media/zc0301.h b/drivers/media/video/zc0301/zc0301.h
index 8e0655140e60..b9c93b8c16f7 100644
--- a/drivers/usb/media/zc0301.h
+++ b/drivers/media/video/zc0301/zc0301.h
@@ -157,7 +157,7 @@ do { \
157 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 157 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
158 else if ((level) >= 3) \ 158 else if ((level) >= 3) \
159 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 159 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
160 __FUNCTION__, __LINE__ , ## args); \ 160 __FUNCTION__, __LINE__ , ## args); \
161 } \ 161 } \
162} while (0) 162} while (0)
163# define KDBG(level, fmt, args...) \ 163# define KDBG(level, fmt, args...) \
@@ -167,7 +167,7 @@ do { \
167 pr_info("zc0301: " fmt "\n", ## args); \ 167 pr_info("zc0301: " fmt "\n", ## args); \
168 else if ((level) == 3) \ 168 else if ((level) == 3) \
169 pr_debug("zc0301: [%s:%d] " fmt "\n", __FUNCTION__, \ 169 pr_debug("zc0301: [%s:%d] " fmt "\n", __FUNCTION__, \
170 __LINE__ , ## args); \ 170 __LINE__ , ## args); \
171 } \ 171 } \
172} while (0) 172} while (0)
173# define V4LDBG(level, name, cmd) \ 173# define V4LDBG(level, name, cmd) \
@@ -184,7 +184,7 @@ do { \
184#undef PDBG 184#undef PDBG
185#define PDBG(fmt, args...) \ 185#define PDBG(fmt, args...) \
186dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 186dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
187 __FUNCTION__, __LINE__ , ## args) 187 __FUNCTION__, __LINE__ , ## args)
188 188
189#undef PDBGG 189#undef PDBGG
190#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 190#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 4036c6268bff..0fad39754f7a 100644
--- a/drivers/usb/media/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -48,7 +48,7 @@
48/*****************************************************************************/ 48/*****************************************************************************/
49 49
50#define ZC0301_MODULE_NAME "V4L2 driver for ZC0301 " \ 50#define ZC0301_MODULE_NAME "V4L2 driver for ZC0301 " \
51 "Image Processor and Control Chip" 51 "Image Processor and Control Chip"
52#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia" 52#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia"
53#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 53#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
54#define ZC0301_MODULE_LICENSE "GPL" 54#define ZC0301_MODULE_LICENSE "GPL"
@@ -67,67 +67,67 @@ MODULE_LICENSE(ZC0301_MODULE_LICENSE);
67static short video_nr[] = {[0 ... ZC0301_MAX_DEVICES-1] = -1}; 67static short video_nr[] = {[0 ... ZC0301_MAX_DEVICES-1] = -1};
68module_param_array(video_nr, short, NULL, 0444); 68module_param_array(video_nr, short, NULL, 0444);
69MODULE_PARM_DESC(video_nr, 69MODULE_PARM_DESC(video_nr,
70 "\n<-1|n[,...]> Specify V4L2 minor mode number." 70 "\n<-1|n[,...]> Specify V4L2 minor mode number."
71 "\n -1 = use next available (default)" 71 "\n -1 = use next available (default)"
72 "\n n = use minor number n (integer >= 0)" 72 "\n n = use minor number n (integer >= 0)"
73 "\nYou can specify up to " 73 "\nYou can specify up to "
74 __MODULE_STRING(ZC0301_MAX_DEVICES) " cameras this way." 74 __MODULE_STRING(ZC0301_MAX_DEVICES) " cameras this way."
75 "\nFor example:" 75 "\nFor example:"
76 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 76 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
77 "\nthe second registered camera and use auto for the first" 77 "\nthe second registered camera and use auto for the first"
78 "\none and for every other camera." 78 "\none and for every other camera."
79 "\n"); 79 "\n");
80 80
81static short force_munmap[] = {[0 ... ZC0301_MAX_DEVICES-1] = 81static short force_munmap[] = {[0 ... ZC0301_MAX_DEVICES-1] =
82 ZC0301_FORCE_MUNMAP}; 82 ZC0301_FORCE_MUNMAP};
83module_param_array(force_munmap, bool, NULL, 0444); 83module_param_array(force_munmap, bool, NULL, 0444);
84MODULE_PARM_DESC(force_munmap, 84MODULE_PARM_DESC(force_munmap,
85 "\n<0|1[,...]> Force the application to unmap previously" 85 "\n<0|1[,...]> Force the application to unmap previously"
86 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 86 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
87 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 87 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
88 "\nthis feature. This parameter is specific for each" 88 "\nthis feature. This parameter is specific for each"
89 "\ndetected camera." 89 "\ndetected camera."
90 "\n 0 = do not force memory unmapping" 90 "\n 0 = do not force memory unmapping"
91 "\n 1 = force memory unmapping (save memory)" 91 "\n 1 = force memory unmapping (save memory)"
92 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 92 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
93 "\n"); 93 "\n");
94 94
95static unsigned int frame_timeout[] = {[0 ... ZC0301_MAX_DEVICES-1] = 95static unsigned int frame_timeout[] = {[0 ... ZC0301_MAX_DEVICES-1] =
96 ZC0301_FRAME_TIMEOUT}; 96 ZC0301_FRAME_TIMEOUT};
97module_param_array(frame_timeout, uint, NULL, 0644); 97module_param_array(frame_timeout, uint, NULL, 0644);
98MODULE_PARM_DESC(frame_timeout, 98MODULE_PARM_DESC(frame_timeout,
99 "\n<n[,...]> Timeout for a video frame in seconds." 99 "\n<n[,...]> Timeout for a video frame in seconds."
100 "\nThis parameter is specific for each detected camera." 100 "\nThis parameter is specific for each detected camera."
101 "\nDefault value is "__MODULE_STRING(ZC0301_FRAME_TIMEOUT)"." 101 "\nDefault value is "__MODULE_STRING(ZC0301_FRAME_TIMEOUT)"."
102 "\n"); 102 "\n");
103 103
104#ifdef ZC0301_DEBUG 104#ifdef ZC0301_DEBUG
105static unsigned short debug = ZC0301_DEBUG_LEVEL; 105static unsigned short debug = ZC0301_DEBUG_LEVEL;
106module_param(debug, ushort, 0644); 106module_param(debug, ushort, 0644);
107MODULE_PARM_DESC(debug, 107MODULE_PARM_DESC(debug,
108 "\n<n> Debugging information level, from 0 to 3:" 108 "\n<n> Debugging information level, from 0 to 3:"
109 "\n0 = none (use carefully)" 109 "\n0 = none (use carefully)"
110 "\n1 = critical errors" 110 "\n1 = critical errors"
111 "\n2 = significant informations" 111 "\n2 = significant informations"
112 "\n3 = more verbose messages" 112 "\n3 = more verbose messages"
113 "\nLevel 3 is useful for testing only, when only " 113 "\nLevel 3 is useful for testing only, when only "
114 "one device is used." 114 "one device is used."
115 "\nDefault value is "__MODULE_STRING(ZC0301_DEBUG_LEVEL)"." 115 "\nDefault value is "__MODULE_STRING(ZC0301_DEBUG_LEVEL)"."
116 "\n"); 116 "\n");
117#endif 117#endif
118 118
119/*****************************************************************************/ 119/*****************************************************************************/
120 120
121static u32 121static u32
122zc0301_request_buffers(struct zc0301_device* cam, u32 count, 122zc0301_request_buffers(struct zc0301_device* cam, u32 count,
123 enum zc0301_io_method io) 123 enum zc0301_io_method io)
124{ 124{
125 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 125 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
126 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 126 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
127 const size_t imagesize = cam->module_param.force_munmap || 127 const size_t imagesize = cam->module_param.force_munmap ||
128 io == IO_READ ? 128 io == IO_READ ?
129 (p->width * p->height * p->priv) / 8 : 129 (p->width * p->height * p->priv) / 8 :
130 (r->width * r->height * p->priv) / 8; 130 (r->width * r->height * p->priv) / 8;
131 void* buff = NULL; 131 void* buff = NULL;
132 u32 i; 132 u32 i;
133 133
@@ -216,7 +216,7 @@ int zc0301_write_reg(struct zc0301_device* cam, u16 index, u16 value)
216 int res; 216 int res;
217 217
218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0xa0, 0x40, 218 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0xa0, 0x40,
219 value, index, NULL, 0, ZC0301_CTRL_TIMEOUT); 219 value, index, NULL, 0, ZC0301_CTRL_TIMEOUT);
220 if (res < 0) { 220 if (res < 0) {
221 DBG(3, "Failed to write a register (index 0x%04X, " 221 DBG(3, "Failed to write a register (index 0x%04X, "
222 "value 0x%02X, error %d)",index, value, res); 222 "value 0x%02X, error %d)",index, value, res);
@@ -234,7 +234,7 @@ int zc0301_read_reg(struct zc0301_device* cam, u16 index)
234 int res; 234 int res;
235 235
236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0xa1, 0xc0, 236 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0xa1, 0xc0,
237 0x0001, index, buff, 1, ZC0301_CTRL_TIMEOUT); 237 0x0001, index, buff, 1, ZC0301_CTRL_TIMEOUT);
238 if (res < 0) 238 if (res < 0)
239 DBG(3, "Failed to read a register (index 0x%04X, error %d)", 239 DBG(3, "Failed to read a register (index 0x%04X, error %d)",
240 index, res); 240 index, res);
@@ -337,11 +337,11 @@ static void zc0301_urb_complete(struct urb *urb, struct pt_regs* regs)
337 337
338 if (!(*f)) 338 if (!(*f))
339 (*f) = list_entry(cam->inqueue.next, struct zc0301_frame_t, 339 (*f) = list_entry(cam->inqueue.next, struct zc0301_frame_t,
340 frame); 340 frame);
341 341
342 imagesize = (cam->sensor.pix_format.width * 342 imagesize = (cam->sensor.pix_format.width *
343 cam->sensor.pix_format.height * 343 cam->sensor.pix_format.height *
344 cam->sensor.pix_format.priv) / 8; 344 cam->sensor.pix_format.priv) / 8;
345 345
346 for (i = 0; i < urb->number_of_packets; i++) { 346 for (i = 0; i < urb->number_of_packets; i++) {
347 unsigned int len, status; 347 unsigned int len, status;
@@ -395,8 +395,8 @@ end_of_frame:
395 list_move_tail(&(*f)->frame, &cam->outqueue); 395 list_move_tail(&(*f)->frame, &cam->outqueue);
396 if (!list_empty(&cam->inqueue)) 396 if (!list_empty(&cam->inqueue))
397 (*f) = list_entry(cam->inqueue.next, 397 (*f) = list_entry(cam->inqueue.next,
398 struct zc0301_frame_t, 398 struct zc0301_frame_t,
399 frame); 399 frame);
400 else 400 else
401 (*f) = NULL; 401 (*f) = NULL;
402 spin_unlock(&cam->queue_lock); 402 spin_unlock(&cam->queue_lock);
@@ -429,14 +429,14 @@ static int zc0301_start_transfer(struct zc0301_device* cam)
429 struct usb_device *udev = cam->usbdev; 429 struct usb_device *udev = cam->usbdev;
430 struct urb* urb; 430 struct urb* urb;
431 const unsigned int wMaxPacketSize[] = {0, 128, 192, 256, 384, 431 const unsigned int wMaxPacketSize[] = {0, 128, 192, 256, 384,
432 512, 768, 1023}; 432 512, 768, 1023};
433 const unsigned int psz = wMaxPacketSize[ZC0301_ALTERNATE_SETTING]; 433 const unsigned int psz = wMaxPacketSize[ZC0301_ALTERNATE_SETTING];
434 s8 i, j; 434 s8 i, j;
435 int err = 0; 435 int err = 0;
436 436
437 for (i = 0; i < ZC0301_URBS; i++) { 437 for (i = 0; i < ZC0301_URBS; i++) {
438 cam->transfer_buffer[i] = kzalloc(ZC0301_ISO_PACKETS * psz, 438 cam->transfer_buffer[i] = kzalloc(ZC0301_ISO_PACKETS * psz,
439 GFP_KERNEL); 439 GFP_KERNEL);
440 if (!cam->transfer_buffer[i]) { 440 if (!cam->transfer_buffer[i]) {
441 err = -ENOMEM; 441 err = -ENOMEM;
442 DBG(1, "Not enough memory"); 442 DBG(1, "Not enough memory");
@@ -528,9 +528,9 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
528 528
529 cam->stream = STREAM_INTERRUPT; 529 cam->stream = STREAM_INTERRUPT;
530 timeout = wait_event_timeout(cam->wait_stream, 530 timeout = wait_event_timeout(cam->wait_stream,
531 (cam->stream == STREAM_OFF) || 531 (cam->stream == STREAM_OFF) ||
532 (cam->state & DEV_DISCONNECTED), 532 (cam->state & DEV_DISCONNECTED),
533 ZC0301_URB_TIMEOUT); 533 ZC0301_URB_TIMEOUT);
534 if (cam->state & DEV_DISCONNECTED) 534 if (cam->state & DEV_DISCONNECTED)
535 return -ENODEV; 535 return -ENODEV;
536 else if (cam->stream != STREAM_OFF) { 536 else if (cam->stream != STREAM_OFF) {
@@ -548,7 +548,7 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
548 548
549static int 549static int
550zc0301_set_compression(struct zc0301_device* cam, 550zc0301_set_compression(struct zc0301_device* cam,
551 struct v4l2_jpegcompression* compression) 551 struct v4l2_jpegcompression* compression)
552{ 552{
553 int r, err = 0; 553 int r, err = 0;
554 554
@@ -670,8 +670,8 @@ static int zc0301_open(struct inode* inode, struct file* filp)
670 } 670 }
671 mutex_unlock(&cam->dev_mutex); 671 mutex_unlock(&cam->dev_mutex);
672 err = wait_event_interruptible_exclusive(cam->open, 672 err = wait_event_interruptible_exclusive(cam->open,
673 cam->state & DEV_DISCONNECTED 673 cam->state & DEV_DISCONNECTED
674 || !cam->users); 674 || !cam->users);
675 if (err) { 675 if (err) {
676 up_read(&zc0301_disconnect); 676 up_read(&zc0301_disconnect);
677 return err; 677 return err;
@@ -802,12 +802,12 @@ zc0301_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
802 return -EAGAIN; 802 return -EAGAIN;
803 } 803 }
804 timeout = wait_event_interruptible_timeout 804 timeout = wait_event_interruptible_timeout
805 ( cam->wait_frame, 805 ( cam->wait_frame,
806 (!list_empty(&cam->outqueue)) || 806 (!list_empty(&cam->outqueue)) ||
807 (cam->state & DEV_DISCONNECTED) || 807 (cam->state & DEV_DISCONNECTED) ||
808 (cam->state & DEV_MISCONFIGURED), 808 (cam->state & DEV_MISCONFIGURED),
809 cam->module_param.frame_timeout * 809 cam->module_param.frame_timeout *
810 1000 * msecs_to_jiffies(1) ); 810 1000 * msecs_to_jiffies(1) );
811 if (timeout < 0) { 811 if (timeout < 0) {
812 mutex_unlock(&cam->fileop_mutex); 812 mutex_unlock(&cam->fileop_mutex);
813 return timeout; 813 return timeout;
@@ -930,7 +930,7 @@ static int zc0301_mmap(struct file* filp, struct vm_area_struct *vma)
930{ 930{
931 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp)); 931 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
932 unsigned long size = vma->vm_end - vma->vm_start, 932 unsigned long size = vma->vm_end - vma->vm_start,
933 start = vma->vm_start; 933 start = vma->vm_start;
934 void *pos; 934 void *pos;
935 u32 i; 935 u32 i;
936 936
@@ -998,13 +998,13 @@ zc0301_vidioc_querycap(struct zc0301_device* cam, void __user * arg)
998 .driver = "zc0301", 998 .driver = "zc0301",
999 .version = ZC0301_MODULE_VERSION_CODE, 999 .version = ZC0301_MODULE_VERSION_CODE,
1000 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1000 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1001 V4L2_CAP_STREAMING, 1001 V4L2_CAP_STREAMING,
1002 }; 1002 };
1003 1003
1004 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1004 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1005 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1005 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1006 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1006 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1007 sizeof(cap.bus_info)); 1007 sizeof(cap.bus_info));
1008 1008
1009 if (copy_to_user(arg, &cap, sizeof(cap))) 1009 if (copy_to_user(arg, &cap, sizeof(cap)))
1010 return -EFAULT; 1010 return -EFAULT;
@@ -1337,7 +1337,7 @@ zc0301_vidioc_g_fmt(struct zc0301_device* cam, void __user * arg)
1337 1337
1338static int 1338static int
1339zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd, 1339zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
1340 void __user * arg) 1340 void __user * arg)
1341{ 1341{
1342 struct zc0301_sensor* s = &cam->sensor; 1342 struct zc0301_sensor* s = &cam->sensor;
1343 struct v4l2_format format; 1343 struct v4l2_format format;
@@ -1600,7 +1600,7 @@ zc0301_vidioc_qbuf(struct zc0301_device* cam, void __user * arg)
1600 1600
1601static int 1601static int
1602zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp, 1602zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp,
1603 void __user * arg) 1603 void __user * arg)
1604{ 1604{
1605 struct v4l2_buffer b; 1605 struct v4l2_buffer b;
1606 struct zc0301_frame_t *f; 1606 struct zc0301_frame_t *f;
@@ -1619,12 +1619,12 @@ zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp,
1619 if (filp->f_flags & O_NONBLOCK) 1619 if (filp->f_flags & O_NONBLOCK)
1620 return -EAGAIN; 1620 return -EAGAIN;
1621 timeout = wait_event_interruptible_timeout 1621 timeout = wait_event_interruptible_timeout
1622 ( cam->wait_frame, 1622 ( cam->wait_frame,
1623 (!list_empty(&cam->outqueue)) || 1623 (!list_empty(&cam->outqueue)) ||
1624 (cam->state & DEV_DISCONNECTED) || 1624 (cam->state & DEV_DISCONNECTED) ||
1625 (cam->state & DEV_MISCONFIGURED), 1625 (cam->state & DEV_MISCONFIGURED),
1626 cam->module_param.frame_timeout * 1626 cam->module_param.frame_timeout *
1627 1000 * msecs_to_jiffies(1) ); 1627 1000 * msecs_to_jiffies(1) );
1628 if (timeout < 0) 1628 if (timeout < 0)
1629 return timeout; 1629 return timeout;
1630 if (cam->state & DEV_DISCONNECTED) 1630 if (cam->state & DEV_DISCONNECTED)
@@ -1748,7 +1748,7 @@ zc0301_vidioc_s_parm(struct zc0301_device* cam, void __user * arg)
1748 1748
1749 1749
1750static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp, 1750static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
1751 unsigned int cmd, void __user * arg) 1751 unsigned int cmd, void __user * arg)
1752{ 1752{
1753 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp)); 1753 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
1754 1754
@@ -1842,7 +1842,7 @@ static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
1842 1842
1843 1843
1844static int zc0301_ioctl(struct inode* inode, struct file* filp, 1844static int zc0301_ioctl(struct inode* inode, struct file* filp,
1845 unsigned int cmd, unsigned long arg) 1845 unsigned int cmd, unsigned long arg)
1846{ 1846{
1847 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp)); 1847 struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
1848 int err = 0; 1848 int err = 0;
@@ -1948,7 +1948,7 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
1948 mutex_lock(&cam->dev_mutex); 1948 mutex_lock(&cam->dev_mutex);
1949 1949
1950 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 1950 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
1951 video_nr[dev_nr]); 1951 video_nr[dev_nr]);
1952 if (err) { 1952 if (err) {
1953 DBG(1, "V4L2 device registration failed"); 1953 DBG(1, "V4L2 device registration failed");
1954 if (err == -ENFILE && video_nr[dev_nr] == -1) 1954 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 9d282a22c15f..eaadf0252049 100644
--- a/drivers/usb/media/zc0301_pas202bcb.c
+++ b/drivers/media/video/zc0301/zc0301_pas202bcb.c
@@ -24,10 +24,10 @@
24 24
25/* 25/*
26 NOTE: Sensor controls are disabled for now, becouse changing them while 26 NOTE: Sensor controls are disabled for now, becouse changing them while
27 streaming sometimes results in out-of-sync video frames. We'll use 27 streaming sometimes results in out-of-sync video frames. We'll use
28 the default initialization, until we know how to stop and start video 28 the default initialization, until we know how to stop and start video
29 in the chip. However, the image quality still looks good under various 29 in the chip. However, the image quality still looks good under various
30 light conditions. 30 light conditions.
31*/ 31*/
32 32
33#include <linux/delay.h> 33#include <linux/delay.h>
@@ -165,7 +165,7 @@ static int pas202bcb_init(struct zc0301_device* cam)
165 165
166 166
167static int pas202bcb_get_ctrl(struct zc0301_device* cam, 167static int pas202bcb_get_ctrl(struct zc0301_device* cam,
168 struct v4l2_control* ctrl) 168 struct v4l2_control* ctrl)
169{ 169{
170 switch (ctrl->id) { 170 switch (ctrl->id) {
171 case V4L2_CID_EXPOSURE: 171 case V4L2_CID_EXPOSURE:
@@ -208,7 +208,7 @@ static int pas202bcb_get_ctrl(struct zc0301_device* cam,
208 208
209 209
210static int pas202bcb_set_ctrl(struct zc0301_device* cam, 210static int pas202bcb_set_ctrl(struct zc0301_device* cam,
211 const struct v4l2_control* ctrl) 211 const struct v4l2_control* ctrl)
212{ 212{
213 int err = 0; 213 int err = 0;
214 214
diff --git a/drivers/usb/media/zc0301_sensor.h b/drivers/media/video/zc0301/zc0301_sensor.h
index cf0965a81d01..1f95c28b1015 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);
51 51
52#define ZC0301_USB_DEVICE(vend, prod, intclass) \ 52#define ZC0301_USB_DEVICE(vend, prod, intclass) \
53 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 53 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
54 USB_DEVICE_ID_MATCH_INT_CLASS, \ 54 USB_DEVICE_ID_MATCH_INT_CLASS, \
55 .idVendor = (vend), \ 55 .idVendor = (vend), \
56 .idProduct = (prod), \ 56 .idProduct = (prod), \
57 .bInterfaceClass = (intclass) 57 .bInterfaceClass = (intclass)
@@ -92,7 +92,7 @@ struct zc0301_sensor {
92 int (*init)(struct zc0301_device*); 92 int (*init)(struct zc0301_device*);
93 int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl); 93 int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl);
94 int (*set_ctrl)(struct zc0301_device*, 94 int (*set_ctrl)(struct zc0301_device*,
95 const struct v4l2_control* ctrl); 95 const struct v4l2_control* ctrl);
96 int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect); 96 int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect);
97 97
98 /* Private */ 98 /* Private */
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index ad04a129499d..0166f555a5ca 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * zoran - Iomega Buz driver 2 * zoran - Iomega Buz driver
3 * 3 *
4 * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de> 4 * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de>
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index b22dbb6d18f6..0a85c9e7fb48 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
index e5b6acd3eedc..ad997c30bee5 100644
--- a/drivers/media/video/zoran_card.h
+++ b/drivers/media/video/zoran_card.h
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 4e15afdec4c9..c690b2ee880a 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles device access (PCI/I2C/codec/...) 6 * This part handles device access (PCI/I2C/codec/...)
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
@@ -492,7 +492,7 @@ zr36057_set_vfe (struct zoran *zr,
492 /* (Ronald) don't write this if overlay_mask = NULL */ 492 /* (Ronald) don't write this if overlay_mask = NULL */
493 if (zr->overlay_mask) { 493 if (zr->overlay_mask) {
494 /* Write overlay clipping mask data, but don't enable overlay clipping */ 494 /* Write overlay clipping mask data, but don't enable overlay clipping */
495 /* RJ: since this makes only sense on the screen, we use 495 /* RJ: since this makes only sense on the screen, we use
496 * zr->overlay_settings.width instead of video_width */ 496 * zr->overlay_settings.width instead of video_width */
497 497
498 mask_line_size = (BUZ_MAX_WIDTH + 31) / 32; 498 mask_line_size = (BUZ_MAX_WIDTH + 31) / 32;
@@ -819,12 +819,12 @@ zr36057_set_jpg (struct zoran *zr,
819 if (zr->card.vfe_pol.hsync_pol) 819 if (zr->card.vfe_pol.hsync_pol)
820 btor(ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR); 820 btor(ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
821 else 821 else
822 btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR); 822 btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
823 reg = ((tvn->HSyncStart) << ZR36057_HSP_HsyncStart) | 823 reg = ((tvn->HSyncStart) << ZR36057_HSP_HsyncStart) |
824 (tvn->Wt << ZR36057_HSP_LineTot); 824 (tvn->Wt << ZR36057_HSP_LineTot);
825 btwrite(reg, ZR36057_HSP); 825 btwrite(reg, ZR36057_HSP);
826 reg = ((zr->jpg_settings.img_x + 826 reg = ((zr->jpg_settings.img_x +
827 tvn->HStart + 4) << ZR36057_FHAP_NAX) | 827 tvn->HStart + 4) << ZR36057_FHAP_NAX) |
828 (zr->jpg_settings.img_width << ZR36057_FHAP_PAX); 828 (zr->jpg_settings.img_width << ZR36057_FHAP_PAX);
829 btwrite(reg, ZR36057_FHAP); 829 btwrite(reg, ZR36057_FHAP);
830 830
@@ -1272,15 +1272,15 @@ error_handler (struct zoran *zr,
1272 if (zr->JPEG_error != 1) { 1272 if (zr->JPEG_error != 1) {
1273 /* 1273 /*
1274 * First entry: error just happened during normal operation 1274 * First entry: error just happened during normal operation
1275 * 1275 *
1276 * In BUZ_MODE_MOTION_COMPRESS: 1276 * In BUZ_MODE_MOTION_COMPRESS:
1277 * 1277 *
1278 * Possible glitch in TV signal. In this case we should 1278 * Possible glitch in TV signal. In this case we should
1279 * stop the codec and wait for good quality signal before 1279 * stop the codec and wait for good quality signal before
1280 * restarting it to avoid further problems 1280 * restarting it to avoid further problems
1281 * 1281 *
1282 * In BUZ_MODE_MOTION_DECOMPRESS: 1282 * In BUZ_MODE_MOTION_DECOMPRESS:
1283 * 1283 *
1284 * Bad JPEG frame: we have to mark it as processed (codec crashed 1284 * Bad JPEG frame: we have to mark it as processed (codec crashed
1285 * and was not able to do it itself), and to remove it from queue. 1285 * and was not able to do it itself), and to remove it from queue.
1286 */ 1286 */
diff --git a/drivers/media/video/zoran_device.h b/drivers/media/video/zoran_device.h
index f315203d7105..f19705cbdb39 100644
--- a/drivers/media/video/zoran_device.h
+++ b/drivers/media/video/zoran_device.h
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index b2c6e01e3923..b5a576a37fd2 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -94,7 +94,7 @@
94 V4L2_CAP_VIDEO_CAPTURE |\ 94 V4L2_CAP_VIDEO_CAPTURE |\
95 V4L2_CAP_VIDEO_OUTPUT |\ 95 V4L2_CAP_VIDEO_OUTPUT |\
96 V4L2_CAP_VIDEO_OVERLAY \ 96 V4L2_CAP_VIDEO_OVERLAY \
97 ) 97 )
98#endif 98#endif
99 99
100#include <asm/byteorder.h> 100#include <asm/byteorder.h>
@@ -165,7 +165,7 @@ const struct zoran_format zoran_formats[] = {
165#endif 165#endif
166 .depth = 16, 166 .depth = 16,
167 .flags = ZORAN_FORMAT_CAPTURE | 167 .flags = ZORAN_FORMAT_CAPTURE |
168 ZORAN_FORMAT_OVERLAY, 168 ZORAN_FORMAT_OVERLAY,
169 }, { 169 }, {
170 .name = "Hardware-encoded Motion-JPEG", 170 .name = "Hardware-encoded Motion-JPEG",
171 .palette = -1, 171 .palette = -1,
@@ -670,7 +670,7 @@ jpg_fbuffer_free (struct file *file)
670 j])))); 670 j]))));
671 free_page((unsigned long) 671 free_page((unsigned long)
672 bus_to_virt 672 bus_to_virt
673 (le32_to_cpu 673 (le32_to_cpu
674 (fh->jpg_buffers. 674 (fh->jpg_buffers.
675 buffer[i]. 675 buffer[i].
676 frag_tab[2 * j]))); 676 frag_tab[2 * j])));
@@ -1871,7 +1871,7 @@ zoran_v4l2_buffer_status (struct file *file,
1871 1871
1872static int 1872static int
1873zoran_set_norm (struct zoran *zr, 1873zoran_set_norm (struct zoran *zr,
1874 int norm) /* VIDEO_MODE_* */ 1874 int norm) /* VIDEO_MODE_* */
1875{ 1875{
1876 int norm_encoder, on; 1876 int norm_encoder, on;
1877 1877
@@ -2006,9 +2006,9 @@ zoran_set_input (struct zoran *zr,
2006 2006
2007static int 2007static int
2008zoran_do_ioctl (struct inode *inode, 2008zoran_do_ioctl (struct inode *inode,
2009 struct file *file, 2009 struct file *file,
2010 unsigned int cmd, 2010 unsigned int cmd,
2011 void *arg) 2011 void *arg)
2012{ 2012{
2013 struct zoran_fh *fh = file->private_data; 2013 struct zoran_fh *fh = file->private_data;
2014 struct zoran *zr = fh->zr; 2014 struct zoran *zr = fh->zr;
@@ -2095,7 +2095,7 @@ zoran_do_ioctl (struct inode *inode,
2095 break; 2095 break;
2096 2096
2097 /* RJ: the documentation at http://roadrunner.swansea.linux.org.uk/v4lapi.shtml says: 2097 /* RJ: the documentation at http://roadrunner.swansea.linux.org.uk/v4lapi.shtml says:
2098 * 2098 *
2099 * * "The VIDIOCSCHAN ioctl takes an integer argument and switches the capture to this input." 2099 * * "The VIDIOCSCHAN ioctl takes an integer argument and switches the capture to this input."
2100 * * ^^^^^^^ 2100 * * ^^^^^^^
2101 * * The famos BTTV driver has it implemented with a struct video_channel argument 2101 * * The famos BTTV driver has it implemented with a struct video_channel argument
diff --git a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
index f0d9b13c3c6c..a00fae90229a 100644
--- a/drivers/media/video/zoran_procfs.c
+++ b/drivers/media/video/zoran_procfs.c
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles the procFS entries (/proc/ZORAN[%d]) 6 * This part handles the procFS entries (/proc/ZORAN[%d])
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zoran_procfs.h b/drivers/media/video/zoran_procfs.h
index 8904fc959555..f2d5b1ba448f 100644
--- a/drivers/media/video/zoran_procfs.h
+++ b/drivers/media/video/zoran_procfs.h
@@ -4,7 +4,7 @@
4 * Media Labs LML33/LML33R10. 4 * Media Labs LML33/LML33R10.
5 * 5 *
6 * This part handles card-specific data and detection 6 * This part handles card-specific data and detection
7 * 7 *
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx> 8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9 * 9 *
10 * Currently maintained by: 10 * Currently maintained by:
diff --git a/drivers/media/video/zr36016.c b/drivers/media/video/zr36016.c
index 10130ef67ea7..62f77584fb85 100644
--- a/drivers/media/video/zr36016.c
+++ b/drivers/media/video/zr36016.c
@@ -34,7 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36 36
37/* includes for structures and defines regarding video 37/* includes for structures and defines regarding video
38 #include<linux/videodev.h> */ 38 #include<linux/videodev.h> */
39 39
40/* I/O commands, error codes */ 40/* I/O commands, error codes */
@@ -143,8 +143,8 @@ zr36016_readi (struct zr36016 *ptr,
143 143
144static void 144static void
145zr36016_writei (struct zr36016 *ptr, 145zr36016_writei (struct zr36016 *ptr,
146 u16 reg, 146 u16 reg,
147 u8 value) 147 u8 value)
148{ 148{
149 dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name, 149 dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
150 value, reg); 150 value, reg);
@@ -192,7 +192,7 @@ zr36016_basic_test (struct zr36016 *ptr)
192 dprintk(1, "\n"); 192 dprintk(1, "\n");
193 } 193 }
194 // for testing just write 0, then the default value to a register and read 194 // for testing just write 0, then the default value to a register and read
195 // it back in both cases 195 // it back in both cases
196 zr36016_writei(ptr, ZR016I_PAX_LO, 0x00); 196 zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
197 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) { 197 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
198 dprintk(1, 198 dprintk(1,
@@ -232,17 +232,17 @@ zr36016_basic_test (struct zr36016 *ptr)
232static int zr36016_pushit (struct zr36016 *ptr, 232static int zr36016_pushit (struct zr36016 *ptr,
233 u16 startreg, 233 u16 startreg,
234 u16 len, 234 u16 len,
235 const char *data) 235 const char *data)
236{ 236{
237 int i=0; 237 int i=0;
238 238
239 dprintk(4, "%s: write data block to 0x%04x (len=%d)\n", 239 dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
240 ptr->name, startreg,len); 240 ptr->name, startreg,len);
241 while (i<len) { 241 while (i<len) {
242 zr36016_writei(ptr, startreg++, data[i++]); 242 zr36016_writei(ptr, startreg++, data[i++]);
243 } 243 }
244 244
245 return i; 245 return i;
246} 246}
247#endif 247#endif
248 248
diff --git a/drivers/media/video/zr36050.c b/drivers/media/video/zr36050.c
index 6699725be605..a6bbd125631c 100644
--- a/drivers/media/video/zr36050.c
+++ b/drivers/media/video/zr36050.c
@@ -34,7 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36 36
37/* includes for structures and defines regarding video 37/* includes for structures and defines regarding video
38 #include<linux/videodev.h> */ 38 #include<linux/videodev.h> */
39 39
40/* I/O commands, error codes */ 40/* I/O commands, error codes */
@@ -171,7 +171,7 @@ zr36050_wait_end (struct zr36050 *ptr)
171/* ========================================================================= 171/* =========================================================================
172 Local helper function: 172 Local helper function:
173 173
174 basic test of "connectivity", writes/reads to/from memory the SOF marker 174 basic test of "connectivity", writes/reads to/from memory the SOF marker
175 ========================================================================= */ 175 ========================================================================= */
176 176
177static int 177static int
@@ -218,9 +218,9 @@ zr36050_basic_test (struct zr36050 *ptr)
218 218
219static int 219static int
220zr36050_pushit (struct zr36050 *ptr, 220zr36050_pushit (struct zr36050 *ptr,
221 u16 startreg, 221 u16 startreg,
222 u16 len, 222 u16 len,
223 const char *data) 223 const char *data)
224{ 224{
225 int i = 0; 225 int i = 0;
226 226
@@ -345,7 +345,7 @@ static const char zr36050_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 };
345/* ------------------------------------------------------------------------- */ 345/* ------------------------------------------------------------------------- */
346 346
347/* SOF (start of frame) segment depends on width, height and sampling ratio 347/* SOF (start of frame) segment depends on width, height and sampling ratio
348 of each color component */ 348 of each color component */
349 349
350static int 350static int
351zr36050_set_sof (struct zr36050 *ptr) 351zr36050_set_sof (struct zr36050 *ptr)
@@ -376,8 +376,8 @@ zr36050_set_sof (struct zr36050 *ptr)
376 376
377/* ------------------------------------------------------------------------- */ 377/* ------------------------------------------------------------------------- */
378 378
379/* SOS (start of scan) segment depends on the used scan components 379/* SOS (start of scan) segment depends on the used scan components
380 of each color component */ 380 of each color component */
381 381
382static int 382static int
383zr36050_set_sos (struct zr36050 *ptr) 383zr36050_set_sos (struct zr36050 *ptr)
diff --git a/drivers/media/video/zr36057.h b/drivers/media/video/zr36057.h
index 159abfa034d9..54c9362aa980 100644
--- a/drivers/media/video/zr36057.h
+++ b/drivers/media/video/zr36057.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * zr36057.h - zr36057 register offsets 2 * zr36057.h - zr36057 register offsets
3 * 3 *
4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net> 4 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -27,14 +27,14 @@
27#define ZR36057_VFEHCR 0x000 /* Video Front End, Horizontal Configuration Register */ 27#define ZR36057_VFEHCR 0x000 /* Video Front End, Horizontal Configuration Register */
28#define ZR36057_VFEHCR_HSPol (1<<30) 28#define ZR36057_VFEHCR_HSPol (1<<30)
29#define ZR36057_VFEHCR_HStart 10 29#define ZR36057_VFEHCR_HStart 10
30#define ZR36057_VFEHCR_HEnd 0 30#define ZR36057_VFEHCR_HEnd 0
31#define ZR36057_VFEHCR_Hmask 0x3ff 31#define ZR36057_VFEHCR_Hmask 0x3ff
32 32
33#define ZR36057_VFEVCR 0x004 /* Video Front End, Vertical Configuration Register */ 33#define ZR36057_VFEVCR 0x004 /* Video Front End, Vertical Configuration Register */
34#define ZR36057_VFEVCR_VSPol (1<<30) 34#define ZR36057_VFEVCR_VSPol (1<<30)
35#define ZR36057_VFEVCR_VStart 10 35#define ZR36057_VFEVCR_VStart 10
36#define ZR36057_VFEVCR_VEnd 0 36#define ZR36057_VFEVCR_VEnd 0
37#define ZR36057_VFEVCR_Vmask 0x3ff 37#define ZR36057_VFEVCR_Vmask 0x3ff
38 38
39#define ZR36057_VFESPFR 0x008 /* Video Front End, Scaler and Pixel Format Register */ 39#define ZR36057_VFESPFR 0x008 /* Video Front End, Scaler and Pixel Format Register */
40#define ZR36057_VFESPFR_ExtFl (1<<26) 40#define ZR36057_VFESPFR_ExtFl (1<<26)
diff --git a/drivers/media/video/zr36060.c b/drivers/media/video/zr36060.c
index d8dd003a7aad..97c8f9b9dc12 100644
--- a/drivers/media/video/zr36060.c
+++ b/drivers/media/video/zr36060.c
@@ -34,7 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36 36
37/* includes for structures and defines regarding video 37/* includes for structures and defines regarding video
38 #include<linux/videodev.h> */ 38 #include<linux/videodev.h> */
39 39
40/* I/O commands, error codes */ 40/* I/O commands, error codes */
@@ -173,7 +173,7 @@ zr36060_wait_end (struct zr36060 *ptr)
173/* ========================================================================= 173/* =========================================================================
174 Local helper function: 174 Local helper function:
175 175
176 basic test of "connectivity", writes/reads to/from memory the SOF marker 176 basic test of "connectivity", writes/reads to/from memory the SOF marker
177 ========================================================================= */ 177 ========================================================================= */
178 178
179static int 179static int
@@ -208,9 +208,9 @@ zr36060_basic_test (struct zr36060 *ptr)
208 208
209static int 209static int
210zr36060_pushit (struct zr36060 *ptr, 210zr36060_pushit (struct zr36060 *ptr,
211 u16 startreg, 211 u16 startreg,
212 u16 len, 212 u16 len,
213 const char *data) 213 const char *data)
214{ 214{
215 int i = 0; 215 int i = 0;
216 216
@@ -335,7 +335,7 @@ static const char zr36060_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 };
335/* ------------------------------------------------------------------------- */ 335/* ------------------------------------------------------------------------- */
336 336
337/* SOF (start of frame) segment depends on width, height and sampling ratio 337/* SOF (start of frame) segment depends on width, height and sampling ratio
338 of each color component */ 338 of each color component */
339 339
340static int 340static int
341zr36060_set_sof (struct zr36060 *ptr) 341zr36060_set_sof (struct zr36060 *ptr)
@@ -367,8 +367,8 @@ zr36060_set_sof (struct zr36060 *ptr)
367 367
368/* ------------------------------------------------------------------------- */ 368/* ------------------------------------------------------------------------- */
369 369
370/* SOS (start of scan) segment depends on the used scan components 370/* SOS (start of scan) segment depends on the used scan components
371 of each color component */ 371 of each color component */
372 372
373static int 373static int
374zr36060_set_sos (struct zr36060 *ptr) 374zr36060_set_sos (struct zr36060 *ptr)
@@ -385,7 +385,7 @@ zr36060_set_sos (struct zr36060 *ptr)
385 for (i = 0; i < NO_OF_COMPONENTS; i++) { 385 for (i = 0; i < NO_OF_COMPONENTS; i++) {
386 sos_data[5 + (i * 2)] = i; // index 386 sos_data[5 + (i * 2)] = i; // index
387 sos_data[6 + (i * 2)] = (zr36060_td[i] << 4) | 387 sos_data[6 + (i * 2)] = (zr36060_td[i] << 4) |
388 zr36060_ta[i]; // AC/DC tbl.sel. 388 zr36060_ta[i]; // AC/DC tbl.sel.
389 } 389 }
390 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00; // scan start 390 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00; // scan start
391 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3f; 391 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3f;
@@ -999,7 +999,7 @@ zr36060_cleanup_module (void)
999 dprintk(1, 999 dprintk(1,
1000 "zr36060: something's wrong - %d codecs left somehow.\n", 1000 "zr36060: something's wrong - %d codecs left somehow.\n",
1001 zr36060_codecs); 1001 zr36060_codecs);
1002 } 1002 }
1003 1003
1004 /* however, we can't just stay alive */ 1004 /* however, we can't just stay alive */
1005 videocodec_unregister(&zr36060_codec); 1005 videocodec_unregister(&zr36060_codec);
diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
index d4c633b8a7f5..6ac3b6740089 100644
--- a/drivers/media/video/zr36120.c
+++ b/drivers/media/video/zr36120.c
@@ -70,10 +70,10 @@ MODULE_AUTHOR("Pauline Middelink <middelin@polyware.nl>");
70MODULE_DESCRIPTION("Zoran ZR36120 based framegrabber"); 70MODULE_DESCRIPTION("Zoran ZR36120 based framegrabber");
71MODULE_LICENSE("GPL"); 71MODULE_LICENSE("GPL");
72 72
73MODULE_PARM(triton1,"i"); 73module_param(triton1, uint, 0);
74MODULE_PARM(cardtype,"1-" __MODULE_STRING(ZORAN_MAX) "i"); 74module_param_array(cardtype, uint, NULL, 0);
75MODULE_PARM(video_nr,"i"); 75module_param(video_nr, int, 0);
76MODULE_PARM(vbi_nr,"i"); 76module_param(vbi_nr, int, 0);
77 77
78static int zoran_cards; 78static int zoran_cards;
79static struct zoran zorans[ZORAN_MAX]; 79static struct zoran zorans[ZORAN_MAX];
@@ -316,7 +316,7 @@ DEBUG(printk(CARD_DEBUG "%p added to queue\n",CARD,item));
316 item->status = FBUFFER_BUSY; 316 item->status = FBUFFER_BUSY;
317 if (!lastitem) 317 if (!lastitem)
318 ztv->workqueue = item; 318 ztv->workqueue = item;
319 else 319 else
320 lastitem->next = item; 320 lastitem->next = item;
321 lastitem = item; 321 lastitem = item;
322 } 322 }
@@ -516,7 +516,7 @@ DEBUG(printk(KERN_DEBUG " %d: clip(%d,%d,%d,%d)\n", i,vp->x,vp->y,vp->widt
516 zraor((ztv->vidInterlace*ystep)<<0,~ZORAN_OCR_MASKSTRIDE,ZORAN_OCR); 516 zraor((ztv->vidInterlace*ystep)<<0,~ZORAN_OCR_MASKSTRIDE,ZORAN_OCR);
517} 517}
518 518
519struct tvnorm 519struct tvnorm
520{ 520{
521 u16 Wt, Wa, Ht, Ha, HStart, VStart; 521 u16 Wt, Wa, Ht, Ha, HStart, VStart;
522}; 522};
@@ -660,7 +660,7 @@ DEBUG(printk(KERN_DEBUG " Y: scale=0, start=%d, end=%d\n", Hstart, Hend));
660 int HorDcm = 64-X; 660 int HorDcm = 64-X;
661 int hcrop1 = 2*(Wa-We)/4; 661 int hcrop1 = 2*(Wa-We)/4;
662 /* 662 /*
663 * BUGFIX: Juha Nurmela <junki@qn-lpr2-165.quicknet.inet.fi> 663 * BUGFIX: Juha Nurmela <junki@qn-lpr2-165.quicknet.inet.fi>
664 * found the solution to the color phase shift. 664 * found the solution to the color phase shift.
665 * See ChangeLog for the full explanation) 665 * See ChangeLog for the full explanation)
666 */ 666 */
@@ -812,12 +812,12 @@ void zoran_close(struct video_device* dev)
812 812
813 zoran_common_close(ztv); 813 zoran_common_close(ztv);
814 814
815 /* 815 /*
816 * This is sucky but right now I can't find a good way to 816 * This is sucky but right now I can't find a good way to
817 * be sure its safe to free the buffer. We wait 5-6 fields 817 * be sure its safe to free the buffer. We wait 5-6 fields
818 * which is more than sufficient to be sure. 818 * which is more than sufficient to be sure.
819 */ 819 */
820 msleep(100); /* Wait 1/10th of a second */ 820 msleep(100); /* Wait 1/10th of a second */
821 821
822 /* free the allocated framebuffer */ 822 /* free the allocated framebuffer */
823 bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE); 823 bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
@@ -1436,7 +1436,7 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg)
1436 1436
1437 /* Why isn't this in the API? 1437 /* Why isn't this in the API?
1438 * And why doesn't it take a buffer number? 1438 * And why doesn't it take a buffer number?
1439 case BTTV_FIELDNR: 1439 case BTTV_FIELDNR:
1440 { 1440 {
1441 unsigned long v = ztv->lastfieldnr; 1441 unsigned long v = ztv->lastfieldnr;
1442 if (copy_to_user(arg,&v,sizeof(v))) 1442 if (copy_to_user(arg,&v,sizeof(v)))
@@ -1557,12 +1557,12 @@ void vbi_close(struct video_device *dev)
1557 1557
1558 zoran_common_close(ztv); 1558 zoran_common_close(ztv);
1559 1559
1560 /* 1560 /*
1561 * This is sucky but right now I can't find a good way to 1561 * This is sucky but right now I can't find a good way to
1562 * be sure its safe to free the buffer. We wait 5-6 fields 1562 * be sure its safe to free the buffer. We wait 5-6 fields
1563 * which is more than sufficient to be sure. 1563 * which is more than sufficient to be sure.
1564 */ 1564 */
1565 msleep(100); /* Wait 1/10th of a second */ 1565 msleep(100); /* Wait 1/10th of a second */
1566 1566
1567 for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++) 1567 for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++)
1568 { 1568 {
@@ -1620,7 +1620,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
1620 write_unlock_irq(&ztv->lock); 1620 write_unlock_irq(&ztv->lock);
1621 return -EWOULDBLOCK; 1621 return -EWOULDBLOCK;
1622 } 1622 }
1623 1623
1624 /* mark the unused buffer as wanted */ 1624 /* mark the unused buffer as wanted */
1625 unused->status = FBUFFER_BUSY; 1625 unused->status = FBUFFER_BUSY;
1626 unused->next = 0; 1626 unused->next = 0;
@@ -1671,7 +1671,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
1671 if (count == 2*19*2048) { 1671 if (count == 2*19*2048) {
1672 /* 1672 /*
1673 * Extreme HACK, old VBI programs expect 2048 points 1673 * Extreme HACK, old VBI programs expect 2048 points
1674 * of data, and we only got 864 orso. Double each 1674 * of data, and we only got 864 orso. Double each
1675 * datapoint and clear the rest of the line. 1675 * datapoint and clear the rest of the line.
1676 * This way we have appear to have a 1676 * This way we have appear to have a
1677 * sample_frequency of 29.5 Mc. 1677 * sample_frequency of 29.5 Mc.
@@ -1956,7 +1956,7 @@ int __init init_zoran(int card)
1956 zrand(~ZORAN_VDC_TRICOM, ZORAN_VDC); 1956 zrand(~ZORAN_VDC_TRICOM, ZORAN_VDC);
1957 1957
1958 /* external FL determines TOP frame */ 1958 /* external FL determines TOP frame */
1959 zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC); 1959 zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC);
1960 1960
1961 /* set HSpol */ 1961 /* set HSpol */
1962 if (ztv->card->hsync_pos) 1962 if (ztv->card->hsync_pos)
@@ -2012,7 +2012,7 @@ void release_zoran(int max)
2012 struct zoran *ztv; 2012 struct zoran *ztv;
2013 int i; 2013 int i;
2014 2014
2015 for (i=0;i<max; i++) 2015 for (i=0;i<max; i++)
2016 { 2016 {
2017 ztv = &zorans[i]; 2017 ztv = &zorans[i];
2018 2018
@@ -2029,7 +2029,7 @@ void release_zoran(int max)
2029 2029
2030 /* free it */ 2030 /* free it */
2031 free_irq(ztv->dev->irq,ztv); 2031 free_irq(ztv->dev->irq,ztv);
2032 2032
2033 /* unregister i2c_bus */ 2033 /* unregister i2c_bus */
2034 i2c_unregister_bus((&ztv->i2c)); 2034 i2c_unregister_bus((&ztv->i2c));
2035 2035
@@ -2050,7 +2050,7 @@ void __exit zr36120_exit(void)
2050int __init zr36120_init(void) 2050int __init zr36120_init(void)
2051{ 2051{
2052 int card; 2052 int card;
2053 2053
2054 handle_chipset(); 2054 handle_chipset();
2055 zoran_cards = find_zoran(); 2055 zoran_cards = find_zoran();
2056 if (zoran_cards<0) 2056 if (zoran_cards<0)
@@ -2063,7 +2063,7 @@ int __init zr36120_init(void)
2063 /* only release the zorans we have registered */ 2063 /* only release the zorans we have registered */
2064 release_zoran(card); 2064 release_zoran(card);
2065 return -EIO; 2065 return -EIO;
2066 } 2066 }
2067 } 2067 }
2068 return 0; 2068 return 0;
2069} 2069}
diff --git a/drivers/media/video/zr36120.h b/drivers/media/video/zr36120.h
index 571f8e84b58a..a71e485b0f98 100644
--- a/drivers/media/video/zr36120.h
+++ b/drivers/media/video/zr36120.h
@@ -1,4 +1,4 @@
1/* 1/*
2 zr36120.h - Zoran 36120/36125 based framegrabbers 2 zr36120.h - Zoran 36120/36125 based framegrabbers
3 3
4 Copyright (C) 1998-1999 Pauline Middelink (middelin@polyware.nl) 4 Copyright (C) 1998-1999 Pauline Middelink (middelin@polyware.nl)
@@ -89,7 +89,7 @@ struct vidinfo {
89 ulong* overlay; /* kernel addr of overlay mask */ 89 ulong* overlay; /* kernel addr of overlay mask */
90}; 90};
91 91
92struct zoran 92struct zoran
93{ 93{
94 struct video_device video_dev; 94 struct video_device video_dev;
95#define CARD_DEBUG KERN_DEBUG "%s(%lu): " 95#define CARD_DEBUG KERN_DEBUG "%s(%lu): "
@@ -106,7 +106,7 @@ struct zoran
106 uint norm; /* 0=PAL, 1=NTSC, 2=SECAM */ 106 uint norm; /* 0=PAL, 1=NTSC, 2=SECAM */
107 uint tuner_freq; /* Current freq in kHz */ 107 uint tuner_freq; /* Current freq in kHz */
108 struct video_picture picture; /* Current picture params */ 108 struct video_picture picture; /* Current picture params */
109 109
110 /* videocard details */ 110 /* videocard details */
111 uint swidth; /* screen width */ 111 uint swidth; /* screen width */
112 uint sheight; /* screen height */ 112 uint sheight; /* screen height */
diff --git a/drivers/message/i2o/debug.c b/drivers/message/i2o/debug.c
index 40d4ea898dbc..5a6cca8e8c45 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)
419 d = (u8 *) (rows + 2); 419 d = (u8 *) (rows + 2);
420 state = p[1] << 8 | p[0]; 420 state = p[1] << 8 | p[0];
421 421
422 printk(KERN_DEBUG "TID %04X:[", state & 0xFFF); 422 printk("TID %04X:[", state & 0xFFF);
423 state >>= 12; 423 state >>= 12;
424 if (state & (1 << 0)) 424 if (state & (1 << 0))
425 printk(KERN_DEBUG "H"); /* Hidden */ 425 printk("H"); /* Hidden */
426 if (state & (1 << 2)) { 426 if (state & (1 << 2)) {
427 printk(KERN_DEBUG "P"); /* Present */ 427 printk("P"); /* Present */
428 if (state & (1 << 1)) 428 if (state & (1 << 1))
429 printk(KERN_DEBUG "C"); /* Controlled */ 429 printk("C"); /* Controlled */
430 } 430 }
431 if (state > 9) 431 if (state > 9)
432 printk(KERN_DEBUG "*"); /* Hard */ 432 printk("*"); /* Hard */
433 433
434 printk(KERN_DEBUG "]:"); 434 printk("]:");
435 435
436 switch (p[3] & 0xFFFF) { 436 switch (p[3] & 0xFFFF) {
437 case 0: 437 case 0:
438 /* Adapter private bus - easy */ 438 /* Adapter private bus - easy */
439 printk(KERN_DEBUG 439 printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
440 "Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
441 d[1] << 8 | d[0], *(u32 *) (d + 4)); 440 d[1] << 8 | d[0], *(u32 *) (d + 4));
442 break; 441 break;
443 case 1: 442 case 1:
444 /* ISA bus */ 443 /* ISA bus */
445 printk(KERN_DEBUG 444 printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
446 "ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
447 d[2], d[1] << 8 | d[0], *(u32 *) (d + 4)); 445 d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
448 break; 446 break;
449 447
450 case 2: /* EISA bus */ 448 case 2: /* EISA bus */
451 printk(KERN_DEBUG 449 printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
452 "EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
453 p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4)); 450 p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
454 break; 451 break;
455 452
456 case 3: /* MCA bus */ 453 case 3: /* MCA bus */
457 printk(KERN_DEBUG 454 printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
458 "MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
459 d[3], d[1] << 8 | d[0], *(u32 *) (d + 4)); 455 d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
460 break; 456 break;
461 457
462 case 4: /* PCI bus */ 458 case 4: /* PCI bus */
463 printk(KERN_DEBUG 459 printk("PCI %d: Bus %d Device %d Function %d", p[2],
464 "PCI %d: Bus %d Device %d Function %d", p[2],
465 d[2], d[1], d[0]); 460 d[2], d[1], d[0]);
466 break; 461 break;
467 462
468 case 0x80: /* Other */ 463 case 0x80: /* Other */
469 default: 464 default:
470 printk(KERN_DEBUG "Unsupported bus type."); 465 printk("Unsupported bus type.");
471 break; 466 break;
472 } 467 }
473 printk(KERN_DEBUG "\n"); 468 printk("\n");
474 rows += length; 469 rows += length;
475 } 470 }
476} 471}
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 550f29744812..fc3c8854f430 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4 4
5menu "Multimedia Capabilities Port drivers" 5menu "Multimedia Capabilities Port drivers"
6 depends on ARCH_SA1100
6 7
7config MCP 8config MCP
8 tristate 9 tristate
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 5d397b7a5497..3f5d77f633fa 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -49,6 +49,17 @@ config MMC_PXA
49 49
50 If unsure, say N. 50 If unsure, say N.
51 51
52config MMC_SDHCI
53 tristate "Secure Digital Host Controller Interface support (EXPERIMENTAL)"
54 depends on PCI && MMC && EXPERIMENTAL
55 help
56 This select the generic Secure Digital Host Controller Interface.
57 It is used by manufacturers such as Texas Instruments(R), Ricoh(R)
58 and Toshiba(R). Most controllers found in laptops are of this type.
59 If you have a controller with this interface, say Y or M here.
60
61 If unsure, say N.
62
52config MMC_WBSD 63config MMC_WBSD
53 tristate "Winbond W83L51xD SD/MMC Card Interface support" 64 tristate "Winbond W83L51xD SD/MMC Card Interface support"
54 depends on MMC && ISA_DMA_API 65 depends on MMC && ISA_DMA_API
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index e351e71146e9..769d545284a4 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_MMC_BLOCK) += mmc_block.o
17# 17#
18obj-$(CONFIG_MMC_ARMMMCI) += mmci.o 18obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
19obj-$(CONFIG_MMC_PXA) += pxamci.o 19obj-$(CONFIG_MMC_PXA) += pxamci.o
20obj-$(CONFIG_MMC_SDHCI) += sdhci.o
20obj-$(CONFIG_MMC_WBSD) += wbsd.o 21obj-$(CONFIG_MMC_WBSD) += wbsd.o
21obj-$(CONFIG_MMC_AU1X) += au1xmmc.o 22obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
22 23
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 8d84b045bc83..85e89c77bdea 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -87,7 +87,7 @@ struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
87static int dma = 1; 87static int dma = 1;
88 88
89#ifdef MODULE 89#ifdef MODULE
90MODULE_PARM(dma, "i"); 90module_param(dma, bool, 0);
91MODULE_PARM_DESC(dma, "Use DMA engine for data transfers (0 = disabled)"); 91MODULE_PARM_DESC(dma, "Use DMA engine for data transfers (0 = disabled)");
92#endif 92#endif
93 93
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
new file mode 100644
index 000000000000..8b811d94371c
--- /dev/null
+++ b/drivers/mmc/sdhci.c
@@ -0,0 +1,1265 @@
1/*
2 * linux/drivers/mmc/sdhci.c - Secure Digital Host Controller Interface driver
3 *
4 * Copyright (C) 2005-2006 Pierre Ossman, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11 /*
12 * Note that PIO transfer is rather crappy atm. The buffer full/empty
13 * interrupts aren't reliable so we currently transfer the entire buffer
14 * directly. Patches to solve the problem are welcome.
15 */
16
17#include <linux/delay.h>
18#include <linux/highmem.h>
19#include <linux/pci.h>
20#include <linux/dma-mapping.h>
21
22#include <linux/mmc/host.h>
23#include <linux/mmc/protocol.h>
24
25#include <asm/scatterlist.h>
26
27#include "sdhci.h"
28
29#define DRIVER_NAME "sdhci"
30#define DRIVER_VERSION "0.11"
31
32#define BUGMAIL "<sdhci-devel@list.drzeus.cx>"
33
34#ifdef CONFIG_MMC_DEBUG
35#define DBG(f, x...) \
36 printk(KERN_DEBUG DRIVER_NAME " [%s()]: " f, __func__,## x)
37#else
38#define DBG(f, x...) do { } while (0)
39#endif
40
41static const struct pci_device_id pci_ids[] __devinitdata = {
42 /* handle any SD host controller */
43 {PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)},
44 { /* end: all zeroes */ },
45};
46
47MODULE_DEVICE_TABLE(pci, pci_ids);
48
49static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
50static void sdhci_finish_data(struct sdhci_host *);
51
52static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
53static void sdhci_finish_command(struct sdhci_host *);
54
55static void sdhci_dumpregs(struct sdhci_host *host)
56{
57 printk(KERN_DEBUG DRIVER_NAME ": ============== REGISTER DUMP ==============\n");
58
59 printk(KERN_DEBUG DRIVER_NAME ": Sys addr: 0x%08x | Version: 0x%08x\n",
60 readl(host->ioaddr + SDHCI_DMA_ADDRESS),
61 readw(host->ioaddr + SDHCI_HOST_VERSION));
62 printk(KERN_DEBUG DRIVER_NAME ": Blk size: 0x%08x | Blk cnt: 0x%08x\n",
63 readw(host->ioaddr + SDHCI_BLOCK_SIZE),
64 readw(host->ioaddr + SDHCI_BLOCK_COUNT));
65 printk(KERN_DEBUG DRIVER_NAME ": Argument: 0x%08x | Trn mode: 0x%08x\n",
66 readl(host->ioaddr + SDHCI_ARGUMENT),
67 readw(host->ioaddr + SDHCI_TRANSFER_MODE));
68 printk(KERN_DEBUG DRIVER_NAME ": Present: 0x%08x | Host ctl: 0x%08x\n",
69 readl(host->ioaddr + SDHCI_PRESENT_STATE),
70 readb(host->ioaddr + SDHCI_HOST_CONTROL));
71 printk(KERN_DEBUG DRIVER_NAME ": Power: 0x%08x | Blk gap: 0x%08x\n",
72 readb(host->ioaddr + SDHCI_POWER_CONTROL),
73 readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL));
74 printk(KERN_DEBUG DRIVER_NAME ": Wake-up: 0x%08x | Clock: 0x%08x\n",
75 readb(host->ioaddr + SDHCI_WALK_UP_CONTROL),
76 readw(host->ioaddr + SDHCI_CLOCK_CONTROL));
77 printk(KERN_DEBUG DRIVER_NAME ": Timeout: 0x%08x | Int stat: 0x%08x\n",
78 readb(host->ioaddr + SDHCI_TIMEOUT_CONTROL),
79 readl(host->ioaddr + SDHCI_INT_STATUS));
80 printk(KERN_DEBUG DRIVER_NAME ": Int enab: 0x%08x | Sig enab: 0x%08x\n",
81 readl(host->ioaddr + SDHCI_INT_ENABLE),
82 readl(host->ioaddr + SDHCI_SIGNAL_ENABLE));
83 printk(KERN_DEBUG DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
84 readw(host->ioaddr + SDHCI_ACMD12_ERR),
85 readw(host->ioaddr + SDHCI_SLOT_INT_STATUS));
86 printk(KERN_DEBUG DRIVER_NAME ": Caps: 0x%08x | Max curr: 0x%08x\n",
87 readl(host->ioaddr + SDHCI_CAPABILITIES),
88 readl(host->ioaddr + SDHCI_MAX_CURRENT));
89
90 printk(KERN_DEBUG DRIVER_NAME ": ===========================================\n");
91}
92
93/*****************************************************************************\
94 * *
95 * Low level functions *
96 * *
97\*****************************************************************************/
98
99static void sdhci_reset(struct sdhci_host *host, u8 mask)
100{
101 writeb(mask, host->ioaddr + SDHCI_SOFTWARE_RESET);
102
103 if (mask & SDHCI_RESET_ALL) {
104 host->clock = 0;
105
106 mdelay(50);
107 }
108}
109
110static void sdhci_init(struct sdhci_host *host)
111{
112 u32 intmask;
113
114 sdhci_reset(host, SDHCI_RESET_ALL);
115
116 intmask = ~(SDHCI_INT_CARD_INT | SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL);
117
118 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
119 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
120
121 /* This is unknown magic. */
122 writeb(0xE, host->ioaddr + SDHCI_TIMEOUT_CONTROL);
123}
124
125static void sdhci_activate_led(struct sdhci_host *host)
126{
127 u8 ctrl;
128
129 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
130 ctrl |= SDHCI_CTRL_LED;
131 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
132}
133
134static void sdhci_deactivate_led(struct sdhci_host *host)
135{
136 u8 ctrl;
137
138 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
139 ctrl &= ~SDHCI_CTRL_LED;
140 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
141}
142
143/*****************************************************************************\
144 * *
145 * Core functions *
146 * *
147\*****************************************************************************/
148
149static inline char* sdhci_kmap_sg(struct sdhci_host* host)
150{
151 host->mapped_sg = kmap_atomic(host->cur_sg->page, KM_BIO_SRC_IRQ);
152 return host->mapped_sg + host->cur_sg->offset;
153}
154
155static inline void sdhci_kunmap_sg(struct sdhci_host* host)
156{
157 kunmap_atomic(host->mapped_sg, KM_BIO_SRC_IRQ);
158}
159
160static inline int sdhci_next_sg(struct sdhci_host* host)
161{
162 /*
163 * Skip to next SG entry.
164 */
165 host->cur_sg++;
166 host->num_sg--;
167
168 /*
169 * Any entries left?
170 */
171 if (host->num_sg > 0) {
172 host->offset = 0;
173 host->remain = host->cur_sg->length;
174 }
175
176 return host->num_sg;
177}
178
179static void sdhci_transfer_pio(struct sdhci_host *host)
180{
181 char *buffer;
182 u32 mask;
183 int bytes, size;
184 unsigned long max_jiffies;
185
186 BUG_ON(!host->data);
187
188 if (host->num_sg == 0)
189 return;
190
191 bytes = 0;
192 if (host->data->flags & MMC_DATA_READ)
193 mask = SDHCI_DATA_AVAILABLE;
194 else
195 mask = SDHCI_SPACE_AVAILABLE;
196
197 buffer = sdhci_kmap_sg(host) + host->offset;
198
199 /* Transfer shouldn't take more than 5 s */
200 max_jiffies = jiffies + HZ * 5;
201
202 while (host->size > 0) {
203 if (time_after(jiffies, max_jiffies)) {
204 printk(KERN_ERR "%s: PIO transfer stalled. "
205 "Please report this to "
206 BUGMAIL ".\n", mmc_hostname(host->mmc));
207 sdhci_dumpregs(host);
208
209 sdhci_kunmap_sg(host);
210
211 host->data->error = MMC_ERR_FAILED;
212 sdhci_finish_data(host);
213 return;
214 }
215
216 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask))
217 continue;
218
219 size = min(host->size, host->remain);
220
221 if (size >= 4) {
222 if (host->data->flags & MMC_DATA_READ)
223 *(u32*)buffer = readl(host->ioaddr + SDHCI_BUFFER);
224 else
225 writel(*(u32*)buffer, host->ioaddr + SDHCI_BUFFER);
226 size = 4;
227 } else if (size >= 2) {
228 if (host->data->flags & MMC_DATA_READ)
229 *(u16*)buffer = readw(host->ioaddr + SDHCI_BUFFER);
230 else
231 writew(*(u16*)buffer, host->ioaddr + SDHCI_BUFFER);
232 size = 2;
233 } else {
234 if (host->data->flags & MMC_DATA_READ)
235 *(u8*)buffer = readb(host->ioaddr + SDHCI_BUFFER);
236 else
237 writeb(*(u8*)buffer, host->ioaddr + SDHCI_BUFFER);
238 size = 1;
239 }
240
241 buffer += size;
242 host->offset += size;
243 host->remain -= size;
244
245 bytes += size;
246 host->size -= size;
247
248 if (host->remain == 0) {
249 sdhci_kunmap_sg(host);
250 if (sdhci_next_sg(host) == 0) {
251 DBG("PIO transfer: %d bytes\n", bytes);
252 return;
253 }
254 buffer = sdhci_kmap_sg(host);
255 }
256 }
257
258 sdhci_kunmap_sg(host);
259
260 DBG("PIO transfer: %d bytes\n", bytes);
261}
262
263static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
264{
265 u16 mode;
266
267 WARN_ON(host->data);
268
269 if (data == NULL) {
270 writew(0, host->ioaddr + SDHCI_TRANSFER_MODE);
271 return;
272 }
273
274 DBG("blksz %04x blks %04x flags %08x\n",
275 1 << data->blksz_bits, data->blocks, data->flags);
276 DBG("tsac %d ms nsac %d clk\n",
277 data->timeout_ns / 1000000, data->timeout_clks);
278
279 mode = SDHCI_TRNS_BLK_CNT_EN;
280 if (data->blocks > 1)
281 mode |= SDHCI_TRNS_MULTI;
282 if (data->flags & MMC_DATA_READ)
283 mode |= SDHCI_TRNS_READ;
284 if (host->flags & SDHCI_USE_DMA)
285 mode |= SDHCI_TRNS_DMA;
286
287 writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE);
288
289 writew(1 << data->blksz_bits, host->ioaddr + SDHCI_BLOCK_SIZE);
290 writew(data->blocks, host->ioaddr + SDHCI_BLOCK_COUNT);
291
292 if (host->flags & SDHCI_USE_DMA) {
293 int count;
294
295 count = pci_map_sg(host->chip->pdev, data->sg, data->sg_len,
296 (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE);
297 BUG_ON(count != 1);
298
299 writel(sg_dma_address(data->sg), host->ioaddr + SDHCI_DMA_ADDRESS);
300 } else {
301 host->size = (1 << data->blksz_bits) * data->blocks;
302
303 host->cur_sg = data->sg;
304 host->num_sg = data->sg_len;
305
306 host->offset = 0;
307 host->remain = host->cur_sg->length;
308 }
309}
310
311static void sdhci_finish_data(struct sdhci_host *host)
312{
313 struct mmc_data *data;
314 u32 intmask;
315 u16 blocks;
316
317 BUG_ON(!host->data);
318
319 data = host->data;
320 host->data = NULL;
321
322 if (host->flags & SDHCI_USE_DMA) {
323 pci_unmap_sg(host->chip->pdev, data->sg, data->sg_len,
324 (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE);
325 } else {
326 intmask = readl(host->ioaddr + SDHCI_SIGNAL_ENABLE);
327 intmask &= ~(SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL);
328 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
329
330 intmask = readl(host->ioaddr + SDHCI_INT_ENABLE);
331 intmask &= ~(SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL);
332 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
333 }
334
335 /*
336 * Controller doesn't count down when in single block mode.
337 */
338 if ((data->blocks == 1) && (data->error == MMC_ERR_NONE))
339 blocks = 0;
340 else
341 blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT);
342 data->bytes_xfered = (1 << data->blksz_bits) * (data->blocks - blocks);
343
344 if ((data->error == MMC_ERR_NONE) && blocks) {
345 printk(KERN_ERR "%s: Controller signalled completion even "
346 "though there were blocks left. Please report this "
347 "to " BUGMAIL ".\n", mmc_hostname(host->mmc));
348 data->error = MMC_ERR_FAILED;
349 }
350
351 if (host->size != 0) {
352 printk(KERN_ERR "%s: %d bytes were left untransferred. "
353 "Please report this to " BUGMAIL ".\n",
354 mmc_hostname(host->mmc), host->size);
355 data->error = MMC_ERR_FAILED;
356 }
357
358 DBG("Ending data transfer (%d bytes)\n", data->bytes_xfered);
359
360 if (data->stop) {
361 /*
362 * The controller needs a reset of internal state machines
363 * upon error conditions.
364 */
365 if (data->error != MMC_ERR_NONE) {
366 sdhci_reset(host, SDHCI_RESET_CMD);
367 sdhci_reset(host, SDHCI_RESET_DATA);
368 }
369
370 sdhci_send_command(host, data->stop);
371 } else
372 tasklet_schedule(&host->finish_tasklet);
373}
374
375static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
376{
377 int flags;
378 u32 present;
379 unsigned long max_jiffies;
380
381 WARN_ON(host->cmd);
382
383 DBG("Sending cmd (%x)\n", cmd->opcode);
384
385 /* Wait max 10 ms */
386 max_jiffies = jiffies + (HZ + 99)/100;
387 do {
388 if (time_after(jiffies, max_jiffies)) {
389 printk(KERN_ERR "%s: Controller never released "
390 "inhibit bits. Please report this to "
391 BUGMAIL ".\n", mmc_hostname(host->mmc));
392 sdhci_dumpregs(host);
393 cmd->error = MMC_ERR_FAILED;
394 tasklet_schedule(&host->finish_tasklet);
395 return;
396 }
397 present = readl(host->ioaddr + SDHCI_PRESENT_STATE);
398 } while (present & (SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT));
399
400 mod_timer(&host->timer, jiffies + 10 * HZ);
401
402 host->cmd = cmd;
403
404 sdhci_prepare_data(host, cmd->data);
405
406 writel(cmd->arg, host->ioaddr + SDHCI_ARGUMENT);
407
408 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
409 printk(KERN_ERR "%s: Unsupported response type! "
410 "Please report this to " BUGMAIL ".\n",
411 mmc_hostname(host->mmc));
412 cmd->error = MMC_ERR_INVALID;
413 tasklet_schedule(&host->finish_tasklet);
414 return;
415 }
416
417 if (!(cmd->flags & MMC_RSP_PRESENT))
418 flags = SDHCI_CMD_RESP_NONE;
419 else if (cmd->flags & MMC_RSP_136)
420 flags = SDHCI_CMD_RESP_LONG;
421 else if (cmd->flags & MMC_RSP_BUSY)
422 flags = SDHCI_CMD_RESP_SHORT_BUSY;
423 else
424 flags = SDHCI_CMD_RESP_SHORT;
425
426 if (cmd->flags & MMC_RSP_CRC)
427 flags |= SDHCI_CMD_CRC;
428 if (cmd->flags & MMC_RSP_OPCODE)
429 flags |= SDHCI_CMD_INDEX;
430 if (cmd->data)
431 flags |= SDHCI_CMD_DATA;
432
433 writel(SDHCI_MAKE_CMD(cmd->opcode, flags),
434 host->ioaddr + SDHCI_COMMAND);
435}
436
437static void sdhci_finish_command(struct sdhci_host *host)
438{
439 int i;
440
441 BUG_ON(host->cmd == NULL);
442
443 if (host->cmd->flags & MMC_RSP_PRESENT) {
444 if (host->cmd->flags & MMC_RSP_136) {
445 /* CRC is stripped so we need to do some shifting. */
446 for (i = 0;i < 4;i++) {
447 host->cmd->resp[i] = readl(host->ioaddr +
448 SDHCI_RESPONSE + (3-i)*4) << 8;
449 if (i != 3)
450 host->cmd->resp[i] |=
451 readb(host->ioaddr +
452 SDHCI_RESPONSE + (3-i)*4-1);
453 }
454 } else {
455 host->cmd->resp[0] = readl(host->ioaddr + SDHCI_RESPONSE);
456 }
457 }
458
459 host->cmd->error = MMC_ERR_NONE;
460
461 DBG("Ending cmd (%x)\n", host->cmd->opcode);
462
463 if (host->cmd->data) {
464 u32 intmask;
465
466 host->data = host->cmd->data;
467
468 if (!(host->flags & SDHCI_USE_DMA)) {
469 /*
470 * Don't enable the interrupts until now to make sure we
471 * get stable handling of the FIFO.
472 */
473 intmask = readl(host->ioaddr + SDHCI_INT_ENABLE);
474 intmask |= SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL;
475 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
476
477 intmask = readl(host->ioaddr + SDHCI_SIGNAL_ENABLE);
478 intmask |= SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL;
479 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
480
481 /*
482 * The buffer interrupts are to unreliable so we
483 * start the transfer immediatly.
484 */
485 sdhci_transfer_pio(host);
486 }
487 } else
488 tasklet_schedule(&host->finish_tasklet);
489
490 host->cmd = NULL;
491}
492
493static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
494{
495 int div;
496 u16 clk;
497 unsigned long max_jiffies;
498
499 if (clock == host->clock)
500 return;
501
502 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
503
504 if (clock == 0)
505 goto out;
506
507 for (div = 1;div < 256;div *= 2) {
508 if ((host->max_clk / div) <= clock)
509 break;
510 }
511 div >>= 1;
512
513 clk = div << SDHCI_DIVIDER_SHIFT;
514 clk |= SDHCI_CLOCK_INT_EN;
515 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
516
517 /* Wait max 10 ms */
518 max_jiffies = jiffies + (HZ + 99)/100;
519 do {
520 if (time_after(jiffies, max_jiffies)) {
521 printk(KERN_ERR "%s: Internal clock never stabilised. "
522 "Please report this to " BUGMAIL ".\n",
523 mmc_hostname(host->mmc));
524 sdhci_dumpregs(host);
525 return;
526 }
527 clk = readw(host->ioaddr + SDHCI_CLOCK_CONTROL);
528 } while (!(clk & SDHCI_CLOCK_INT_STABLE));
529
530 clk |= SDHCI_CLOCK_CARD_EN;
531 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
532
533out:
534 host->clock = clock;
535}
536
537/*****************************************************************************\
538 * *
539 * MMC callbacks *
540 * *
541\*****************************************************************************/
542
543static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
544{
545 struct sdhci_host *host;
546 unsigned long flags;
547
548 host = mmc_priv(mmc);
549
550 spin_lock_irqsave(&host->lock, flags);
551
552 WARN_ON(host->mrq != NULL);
553
554 sdhci_activate_led(host);
555
556 host->mrq = mrq;
557
558 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
559 host->mrq->cmd->error = MMC_ERR_TIMEOUT;
560 tasklet_schedule(&host->finish_tasklet);
561 } else
562 sdhci_send_command(host, mrq->cmd);
563
564 spin_unlock_irqrestore(&host->lock, flags);
565}
566
567static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
568{
569 struct sdhci_host *host;
570 unsigned long flags;
571 u8 ctrl;
572
573 host = mmc_priv(mmc);
574
575 spin_lock_irqsave(&host->lock, flags);
576
577 DBG("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n",
578 ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select,
579 ios->vdd, ios->bus_width);
580
581 /*
582 * Reset the chip on each power off.
583 * Should clear out any weird states.
584 */
585 if (ios->power_mode == MMC_POWER_OFF) {
586 writel(0, host->ioaddr + SDHCI_SIGNAL_ENABLE);
587 spin_unlock_irqrestore(&host->lock, flags);
588 sdhci_init(host);
589 spin_lock_irqsave(&host->lock, flags);
590 }
591
592 sdhci_set_clock(host, ios->clock);
593
594 if (ios->power_mode == MMC_POWER_OFF)
595 writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
596 else
597 writeb(0xFF, host->ioaddr + SDHCI_POWER_CONTROL);
598
599 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
600 if (ios->bus_width == MMC_BUS_WIDTH_4)
601 ctrl |= SDHCI_CTRL_4BITBUS;
602 else
603 ctrl &= ~SDHCI_CTRL_4BITBUS;
604 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
605
606 spin_unlock_irqrestore(&host->lock, flags);
607}
608
609static int sdhci_get_ro(struct mmc_host *mmc)
610{
611 struct sdhci_host *host;
612 unsigned long flags;
613 int present;
614
615 host = mmc_priv(mmc);
616
617 spin_lock_irqsave(&host->lock, flags);
618
619 present = readl(host->ioaddr + SDHCI_PRESENT_STATE);
620
621 spin_unlock_irqrestore(&host->lock, flags);
622
623 return !(present & SDHCI_WRITE_PROTECT);
624}
625
626static struct mmc_host_ops sdhci_ops = {
627 .request = sdhci_request,
628 .set_ios = sdhci_set_ios,
629 .get_ro = sdhci_get_ro,
630};
631
632/*****************************************************************************\
633 * *
634 * Tasklets *
635 * *
636\*****************************************************************************/
637
638static void sdhci_tasklet_card(unsigned long param)
639{
640 struct sdhci_host *host;
641 unsigned long flags;
642
643 host = (struct sdhci_host*)param;
644
645 spin_lock_irqsave(&host->lock, flags);
646
647 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
648 if (host->mrq) {
649 printk(KERN_ERR "%s: Card removed during transfer!\n",
650 mmc_hostname(host->mmc));
651 printk(KERN_ERR "%s: Resetting controller.\n",
652 mmc_hostname(host->mmc));
653
654 sdhci_reset(host, SDHCI_RESET_CMD);
655 sdhci_reset(host, SDHCI_RESET_DATA);
656
657 host->mrq->cmd->error = MMC_ERR_FAILED;
658 tasklet_schedule(&host->finish_tasklet);
659 }
660 }
661
662 spin_unlock_irqrestore(&host->lock, flags);
663
664 mmc_detect_change(host->mmc, msecs_to_jiffies(500));
665}
666
667static void sdhci_tasklet_finish(unsigned long param)
668{
669 struct sdhci_host *host;
670 unsigned long flags;
671 struct mmc_request *mrq;
672
673 host = (struct sdhci_host*)param;
674
675 spin_lock_irqsave(&host->lock, flags);
676
677 del_timer(&host->timer);
678
679 mrq = host->mrq;
680
681 DBG("Ending request, cmd (%x)\n", mrq->cmd->opcode);
682
683 /*
684 * The controller needs a reset of internal state machines
685 * upon error conditions.
686 */
687 if ((mrq->cmd->error != MMC_ERR_NONE) ||
688 (mrq->data && ((mrq->data->error != MMC_ERR_NONE) ||
689 (mrq->data->stop && (mrq->data->stop->error != MMC_ERR_NONE))))) {
690 sdhci_reset(host, SDHCI_RESET_CMD);
691 sdhci_reset(host, SDHCI_RESET_DATA);
692 }
693
694 host->mrq = NULL;
695 host->cmd = NULL;
696 host->data = NULL;
697
698 sdhci_deactivate_led(host);
699
700 spin_unlock_irqrestore(&host->lock, flags);
701
702 mmc_request_done(host->mmc, mrq);
703}
704
705static void sdhci_timeout_timer(unsigned long data)
706{
707 struct sdhci_host *host;
708 unsigned long flags;
709
710 host = (struct sdhci_host*)data;
711
712 spin_lock_irqsave(&host->lock, flags);
713
714 if (host->mrq) {
715 printk(KERN_ERR "%s: Timeout waiting for hardware interrupt. "
716 "Please report this to " BUGMAIL ".\n",
717 mmc_hostname(host->mmc));
718 sdhci_dumpregs(host);
719
720 if (host->data) {
721 host->data->error = MMC_ERR_TIMEOUT;
722 sdhci_finish_data(host);
723 } else {
724 if (host->cmd)
725 host->cmd->error = MMC_ERR_TIMEOUT;
726 else
727 host->mrq->cmd->error = MMC_ERR_TIMEOUT;
728
729 tasklet_schedule(&host->finish_tasklet);
730 }
731 }
732
733 spin_unlock_irqrestore(&host->lock, flags);
734}
735
736/*****************************************************************************\
737 * *
738 * Interrupt handling *
739 * *
740\*****************************************************************************/
741
742static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
743{
744 BUG_ON(intmask == 0);
745
746 if (!host->cmd) {
747 printk(KERN_ERR "%s: Got command interrupt even though no "
748 "command operation was in progress.\n",
749 mmc_hostname(host->mmc));
750 printk(KERN_ERR "%s: Please report this to " BUGMAIL ".\n",
751 mmc_hostname(host->mmc));
752 sdhci_dumpregs(host);
753 return;
754 }
755
756 if (intmask & SDHCI_INT_RESPONSE)
757 sdhci_finish_command(host);
758 else {
759 if (intmask & SDHCI_INT_TIMEOUT)
760 host->cmd->error = MMC_ERR_TIMEOUT;
761 else if (intmask & SDHCI_INT_CRC)
762 host->cmd->error = MMC_ERR_BADCRC;
763 else if (intmask & (SDHCI_INT_END_BIT | SDHCI_INT_INDEX))
764 host->cmd->error = MMC_ERR_FAILED;
765 else
766 host->cmd->error = MMC_ERR_INVALID;
767
768 tasklet_schedule(&host->finish_tasklet);
769 }
770}
771
772static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
773{
774 BUG_ON(intmask == 0);
775
776 if (!host->data) {
777 /*
778 * A data end interrupt is sent together with the response
779 * for the stop command.
780 */
781 if (intmask & SDHCI_INT_DATA_END)
782 return;
783
784 printk(KERN_ERR "%s: Got data interrupt even though no "
785 "data operation was in progress.\n",
786 mmc_hostname(host->mmc));
787 printk(KERN_ERR "%s: Please report this to " BUGMAIL ".\n",
788 mmc_hostname(host->mmc));
789 sdhci_dumpregs(host);
790
791 return;
792 }
793
794 if (intmask & SDHCI_INT_DATA_TIMEOUT)
795 host->data->error = MMC_ERR_TIMEOUT;
796 else if (intmask & SDHCI_INT_DATA_CRC)
797 host->data->error = MMC_ERR_BADCRC;
798 else if (intmask & SDHCI_INT_DATA_END_BIT)
799 host->data->error = MMC_ERR_FAILED;
800
801 if (host->data->error != MMC_ERR_NONE)
802 sdhci_finish_data(host);
803 else {
804 if (intmask & (SDHCI_INT_BUF_FULL | SDHCI_INT_BUF_EMPTY))
805 sdhci_transfer_pio(host);
806
807 if (intmask & SDHCI_INT_DATA_END)
808 sdhci_finish_data(host);
809 }
810}
811
812static irqreturn_t sdhci_irq(int irq, void *dev_id, struct pt_regs *regs)
813{
814 irqreturn_t result;
815 struct sdhci_host* host = dev_id;
816 u32 intmask;
817
818 spin_lock(&host->lock);
819
820 intmask = readl(host->ioaddr + SDHCI_INT_STATUS);
821
822 if (!intmask) {
823 result = IRQ_NONE;
824 goto out;
825 }
826
827 DBG("*** %s got interrupt: 0x%08x\n", host->slot_descr, intmask);
828
829 if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE))
830 tasklet_schedule(&host->card_tasklet);
831
832 if (intmask & SDHCI_INT_CMD_MASK) {
833 sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
834
835 writel(intmask & SDHCI_INT_CMD_MASK,
836 host->ioaddr + SDHCI_INT_STATUS);
837 }
838
839 if (intmask & SDHCI_INT_DATA_MASK) {
840 sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
841
842 writel(intmask & SDHCI_INT_DATA_MASK,
843 host->ioaddr + SDHCI_INT_STATUS);
844 }
845
846 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
847
848 if (intmask & SDHCI_INT_CARD_INT) {
849 printk(KERN_ERR "%s: Unexpected card interrupt. Please "
850 "report this to " BUGMAIL ".\n",
851 mmc_hostname(host->mmc));
852 sdhci_dumpregs(host);
853 }
854
855 if (intmask & SDHCI_INT_BUS_POWER) {
856 printk(KERN_ERR "%s: Unexpected bus power interrupt. Please "
857 "report this to " BUGMAIL ".\n",
858 mmc_hostname(host->mmc));
859 sdhci_dumpregs(host);
860 }
861
862 if (intmask & SDHCI_INT_ACMD12ERR) {
863 printk(KERN_ERR "%s: Unexpected auto CMD12 error. Please "
864 "report this to " BUGMAIL ".\n",
865 mmc_hostname(host->mmc));
866 sdhci_dumpregs(host);
867
868 writew(~0, host->ioaddr + SDHCI_ACMD12_ERR);
869 }
870
871 if (intmask)
872 writel(intmask, host->ioaddr + SDHCI_INT_STATUS);
873
874 result = IRQ_HANDLED;
875
876out:
877 spin_unlock(&host->lock);
878
879 return result;
880}
881
882/*****************************************************************************\
883 * *
884 * Suspend/resume *
885 * *
886\*****************************************************************************/
887
888#ifdef CONFIG_PM
889
890static int sdhci_suspend (struct pci_dev *pdev, pm_message_t state)
891{
892 struct sdhci_chip *chip;
893 int i, ret;
894
895 chip = pci_get_drvdata(pdev);
896 if (!chip)
897 return 0;
898
899 DBG("Suspending...\n");
900
901 for (i = 0;i < chip->num_slots;i++) {
902 if (!chip->hosts[i])
903 continue;
904 ret = mmc_suspend_host(chip->hosts[i]->mmc, state);
905 if (ret) {
906 for (i--;i >= 0;i--)
907 mmc_resume_host(chip->hosts[i]->mmc);
908 return ret;
909 }
910 }
911
912 pci_save_state(pdev);
913 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
914 pci_disable_device(pdev);
915 pci_set_power_state(pdev, pci_choose_state(pdev, state));
916
917 return 0;
918}
919
920static int sdhci_resume (struct pci_dev *pdev)
921{
922 struct sdhci_chip *chip;
923 int i, ret;
924
925 chip = pci_get_drvdata(pdev);
926 if (!chip)
927 return 0;
928
929 DBG("Resuming...\n");
930
931 pci_set_power_state(pdev, PCI_D0);
932 pci_restore_state(pdev);
933 pci_enable_device(pdev);
934
935 for (i = 0;i < chip->num_slots;i++) {
936 if (!chip->hosts[i])
937 continue;
938 if (chip->hosts[i]->flags & SDHCI_USE_DMA)
939 pci_set_master(pdev);
940 sdhci_init(chip->hosts[i]);
941 ret = mmc_resume_host(chip->hosts[i]->mmc);
942 if (ret)
943 return ret;
944 }
945
946 return 0;
947}
948
949#else /* CONFIG_PM */
950
951#define sdhci_suspend NULL
952#define sdhci_resume NULL
953
954#endif /* CONFIG_PM */
955
956/*****************************************************************************\
957 * *
958 * Device probing/removal *
959 * *
960\*****************************************************************************/
961
962static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
963{
964 int ret;
965 struct sdhci_chip *chip;
966 struct mmc_host *mmc;
967 struct sdhci_host *host;
968
969 u8 first_bar;
970 unsigned int caps;
971
972 chip = pci_get_drvdata(pdev);
973 BUG_ON(!chip);
974
975 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar);
976 if (ret)
977 return ret;
978
979 first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
980
981 if (first_bar > 5) {
982 printk(KERN_ERR DRIVER_NAME ": Invalid first BAR. Aborting.\n");
983 return -ENODEV;
984 }
985
986 if (!(pci_resource_flags(pdev, first_bar + slot) & IORESOURCE_MEM)) {
987 printk(KERN_ERR DRIVER_NAME ": BAR is not iomem. Aborting.\n");
988 return -ENODEV;
989 }
990
991 if (pci_resource_len(pdev, first_bar + slot) != 0x100) {
992 printk(KERN_ERR DRIVER_NAME ": Invalid iomem size. Aborting.\n");
993 return -ENODEV;
994 }
995
996 mmc = mmc_alloc_host(sizeof(struct sdhci_host), &pdev->dev);
997 if (!mmc)
998 return -ENOMEM;
999
1000 host = mmc_priv(mmc);
1001 host->mmc = mmc;
1002
1003 host->bar = first_bar + slot;
1004
1005 host->addr = pci_resource_start(pdev, host->bar);
1006 host->irq = pdev->irq;
1007
1008 DBG("slot %d at 0x%08lx, irq %d\n", slot, host->addr, host->irq);
1009
1010 snprintf(host->slot_descr, 20, "sdhci:slot%d", slot);
1011
1012 ret = pci_request_region(pdev, host->bar, host->slot_descr);
1013 if (ret)
1014 goto free;
1015
1016 host->ioaddr = ioremap_nocache(host->addr,
1017 pci_resource_len(pdev, host->bar));
1018 if (!host->ioaddr) {
1019 ret = -ENOMEM;
1020 goto release;
1021 }
1022
1023 caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
1024
1025 if ((caps & SDHCI_CAN_DO_DMA) && ((pdev->class & 0x0000FF) == 0x01))
1026 host->flags |= SDHCI_USE_DMA;
1027
1028 if (host->flags & SDHCI_USE_DMA) {
1029 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1030 printk(KERN_WARNING "%s: No suitable DMA available. "
1031 "Falling back to PIO.\n", host->slot_descr);
1032 host->flags &= ~SDHCI_USE_DMA;
1033 }
1034 }
1035
1036 if (host->flags & SDHCI_USE_DMA)
1037 pci_set_master(pdev);
1038 else /* XXX: Hack to get MMC layer to avoid highmem */
1039 pdev->dma_mask = 0;
1040
1041 host->max_clk = (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
1042 host->max_clk *= 1000000;
1043
1044 /*
1045 * Set host parameters.
1046 */
1047 mmc->ops = &sdhci_ops;
1048 mmc->f_min = host->max_clk / 256;
1049 mmc->f_max = host->max_clk;
1050 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;
1051 mmc->caps = MMC_CAP_4_BIT_DATA;
1052
1053 spin_lock_init(&host->lock);
1054
1055 /*
1056 * Maximum number of segments. Hardware cannot do scatter lists.
1057 */
1058 if (host->flags & SDHCI_USE_DMA)
1059 mmc->max_hw_segs = 1;
1060 else
1061 mmc->max_hw_segs = 16;
1062 mmc->max_phys_segs = 16;
1063
1064 /*
1065 * Maximum number of sectors in one transfer. Limited by sector
1066 * count register.
1067 */
1068 mmc->max_sectors = 0x3FFF;
1069
1070 /*
1071 * Maximum segment size. Could be one segment with the maximum number
1072 * of sectors.
1073 */
1074 mmc->max_seg_size = mmc->max_sectors * 512;
1075
1076 /*
1077 * Init tasklets.
1078 */
1079 tasklet_init(&host->card_tasklet,
1080 sdhci_tasklet_card, (unsigned long)host);
1081 tasklet_init(&host->finish_tasklet,
1082 sdhci_tasklet_finish, (unsigned long)host);
1083
1084 setup_timer(&host->timer, sdhci_timeout_timer, (int)host);
1085
1086 ret = request_irq(host->irq, sdhci_irq, SA_SHIRQ,
1087 host->slot_descr, host);
1088 if (ret)
1089 goto unmap;
1090
1091 sdhci_init(host);
1092
1093#ifdef CONFIG_MMC_DEBUG
1094 sdhci_dumpregs(host);
1095#endif
1096
1097 host->chip = chip;
1098 chip->hosts[slot] = host;
1099
1100 mmc_add_host(mmc);
1101
1102 printk(KERN_INFO "%s: SDHCI at 0x%08lx irq %d %s\n", mmc_hostname(mmc),
1103 host->addr, host->irq,
1104 (host->flags & SDHCI_USE_DMA)?"DMA":"PIO");
1105
1106 return 0;
1107
1108unmap:
1109 tasklet_kill(&host->card_tasklet);
1110 tasklet_kill(&host->finish_tasklet);
1111
1112 iounmap(host->ioaddr);
1113release:
1114 pci_release_region(pdev, host->bar);
1115free:
1116 mmc_free_host(mmc);
1117
1118 return ret;
1119}
1120
1121static void sdhci_remove_slot(struct pci_dev *pdev, int slot)
1122{
1123 struct sdhci_chip *chip;
1124 struct mmc_host *mmc;
1125 struct sdhci_host *host;
1126
1127 chip = pci_get_drvdata(pdev);
1128 host = chip->hosts[slot];
1129 mmc = host->mmc;
1130
1131 chip->hosts[slot] = NULL;
1132
1133 mmc_remove_host(mmc);
1134
1135 sdhci_reset(host, SDHCI_RESET_ALL);
1136
1137 free_irq(host->irq, host);
1138
1139 del_timer_sync(&host->timer);
1140
1141 tasklet_kill(&host->card_tasklet);
1142 tasklet_kill(&host->finish_tasklet);
1143
1144 iounmap(host->ioaddr);
1145
1146 pci_release_region(pdev, host->bar);
1147
1148 mmc_free_host(mmc);
1149}
1150
1151static int __devinit sdhci_probe(struct pci_dev *pdev,
1152 const struct pci_device_id *ent)
1153{
1154 int ret, i;
1155 u8 slots;
1156 struct sdhci_chip *chip;
1157
1158 BUG_ON(pdev == NULL);
1159 BUG_ON(ent == NULL);
1160
1161 DBG("found at %s\n", pci_name(pdev));
1162
1163 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots);
1164 if (ret)
1165 return ret;
1166
1167 slots = PCI_SLOT_INFO_SLOTS(slots) + 1;
1168 DBG("found %d slot(s)\n", slots);
1169 if (slots == 0)
1170 return -ENODEV;
1171
1172 ret = pci_enable_device(pdev);
1173 if (ret)
1174 return ret;
1175
1176 chip = kzalloc(sizeof(struct sdhci_chip) +
1177 sizeof(struct sdhci_host*) * slots, GFP_KERNEL);
1178 if (!chip) {
1179 ret = -ENOMEM;
1180 goto err;
1181 }
1182
1183 chip->pdev = pdev;
1184
1185 chip->num_slots = slots;
1186 pci_set_drvdata(pdev, chip);
1187
1188 for (i = 0;i < slots;i++) {
1189 ret = sdhci_probe_slot(pdev, i);
1190 if (ret) {
1191 for (i--;i >= 0;i--)
1192 sdhci_remove_slot(pdev, i);
1193 goto free;
1194 }
1195 }
1196
1197 return 0;
1198
1199free:
1200 pci_set_drvdata(pdev, NULL);
1201 kfree(chip);
1202
1203err:
1204 pci_disable_device(pdev);
1205 return ret;
1206}
1207
1208static void __devexit sdhci_remove(struct pci_dev *pdev)
1209{
1210 int i;
1211 struct sdhci_chip *chip;
1212
1213 chip = pci_get_drvdata(pdev);
1214
1215 if (chip) {
1216 for (i = 0;i < chip->num_slots;i++)
1217 sdhci_remove_slot(pdev, i);
1218
1219 pci_set_drvdata(pdev, NULL);
1220
1221 kfree(chip);
1222 }
1223
1224 pci_disable_device(pdev);
1225}
1226
1227static struct pci_driver sdhci_driver = {
1228 .name = DRIVER_NAME,
1229 .id_table = pci_ids,
1230 .probe = sdhci_probe,
1231 .remove = __devexit_p(sdhci_remove),
1232 .suspend = sdhci_suspend,
1233 .resume = sdhci_resume,
1234};
1235
1236/*****************************************************************************\
1237 * *
1238 * Driver init/exit *
1239 * *
1240\*****************************************************************************/
1241
1242static int __init sdhci_drv_init(void)
1243{
1244 printk(KERN_INFO DRIVER_NAME
1245 ": Secure Digital Host Controller Interface driver, "
1246 DRIVER_VERSION "\n");
1247 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1248
1249 return pci_register_driver(&sdhci_driver);
1250}
1251
1252static void __exit sdhci_drv_exit(void)
1253{
1254 DBG("Exiting\n");
1255
1256 pci_unregister_driver(&sdhci_driver);
1257}
1258
1259module_init(sdhci_drv_init);
1260module_exit(sdhci_drv_exit);
1261
1262MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>");
1263MODULE_DESCRIPTION("Secure Digital Host Controller Interface driver");
1264MODULE_VERSION(DRIVER_VERSION);
1265MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/sdhci.h b/drivers/mmc/sdhci.h
new file mode 100644
index 000000000000..3b270ef486b4
--- /dev/null
+++ b/drivers/mmc/sdhci.h
@@ -0,0 +1,185 @@
1/*
2 * linux/drivers/mmc/sdhci.h - Secure Digital Host Controller Interface driver
3 *
4 * Copyright (C) 2005 Pierre Ossman, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11/*
12 * PCI registers
13 */
14
15#define PCI_SLOT_INFO 0x40 /* 8 bits */
16#define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7)
17#define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07
18
19/*
20 * Controller registers
21 */
22
23#define SDHCI_DMA_ADDRESS 0x00
24
25#define SDHCI_BLOCK_SIZE 0x04
26
27#define SDHCI_BLOCK_COUNT 0x06
28
29#define SDHCI_ARGUMENT 0x08
30
31#define SDHCI_TRANSFER_MODE 0x0C
32#define SDHCI_TRNS_DMA 0x01
33#define SDHCI_TRNS_BLK_CNT_EN 0x02
34#define SDHCI_TRNS_ACMD12 0x04
35#define SDHCI_TRNS_READ 0x10
36#define SDHCI_TRNS_MULTI 0x20
37
38#define SDHCI_COMMAND 0x0E
39#define SDHCI_CMD_RESP_MASK 0x03
40#define SDHCI_CMD_CRC 0x08
41#define SDHCI_CMD_INDEX 0x10
42#define SDHCI_CMD_DATA 0x20
43
44#define SDHCI_CMD_RESP_NONE 0x00
45#define SDHCI_CMD_RESP_LONG 0x01
46#define SDHCI_CMD_RESP_SHORT 0x02
47#define SDHCI_CMD_RESP_SHORT_BUSY 0x03
48
49#define SDHCI_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
50
51#define SDHCI_RESPONSE 0x10
52
53#define SDHCI_BUFFER 0x20
54
55#define SDHCI_PRESENT_STATE 0x24
56#define SDHCI_CMD_INHIBIT 0x00000001
57#define SDHCI_DATA_INHIBIT 0x00000002
58#define SDHCI_DOING_WRITE 0x00000100
59#define SDHCI_DOING_READ 0x00000200
60#define SDHCI_SPACE_AVAILABLE 0x00000400
61#define SDHCI_DATA_AVAILABLE 0x00000800
62#define SDHCI_CARD_PRESENT 0x00010000
63#define SDHCI_WRITE_PROTECT 0x00080000
64
65#define SDHCI_HOST_CONTROL 0x28
66#define SDHCI_CTRL_LED 0x01
67#define SDHCI_CTRL_4BITBUS 0x02
68
69#define SDHCI_POWER_CONTROL 0x29
70
71#define SDHCI_BLOCK_GAP_CONTROL 0x2A
72
73#define SDHCI_WALK_UP_CONTROL 0x2B
74
75#define SDHCI_CLOCK_CONTROL 0x2C
76#define SDHCI_DIVIDER_SHIFT 8
77#define SDHCI_CLOCK_CARD_EN 0x0004
78#define SDHCI_CLOCK_INT_STABLE 0x0002
79#define SDHCI_CLOCK_INT_EN 0x0001
80
81#define SDHCI_TIMEOUT_CONTROL 0x2E
82
83#define SDHCI_SOFTWARE_RESET 0x2F
84#define SDHCI_RESET_ALL 0x01
85#define SDHCI_RESET_CMD 0x02
86#define SDHCI_RESET_DATA 0x04
87
88#define SDHCI_INT_STATUS 0x30
89#define SDHCI_INT_ENABLE 0x34
90#define SDHCI_SIGNAL_ENABLE 0x38
91#define SDHCI_INT_RESPONSE 0x00000001
92#define SDHCI_INT_DATA_END 0x00000002
93#define SDHCI_INT_DMA_END 0x00000008
94#define SDHCI_INT_BUF_EMPTY 0x00000010
95#define SDHCI_INT_BUF_FULL 0x00000020
96#define SDHCI_INT_CARD_INSERT 0x00000040
97#define SDHCI_INT_CARD_REMOVE 0x00000080
98#define SDHCI_INT_CARD_INT 0x00000100
99#define SDHCI_INT_TIMEOUT 0x00010000
100#define SDHCI_INT_CRC 0x00020000
101#define SDHCI_INT_END_BIT 0x00040000
102#define SDHCI_INT_INDEX 0x00080000
103#define SDHCI_INT_DATA_TIMEOUT 0x00100000
104#define SDHCI_INT_DATA_CRC 0x00200000
105#define SDHCI_INT_DATA_END_BIT 0x00400000
106#define SDHCI_INT_BUS_POWER 0x00800000
107#define SDHCI_INT_ACMD12ERR 0x01000000
108
109#define SDHCI_INT_NORMAL_MASK 0x00007FFF
110#define SDHCI_INT_ERROR_MASK 0xFFFF8000
111
112#define SDHCI_INT_CMD_MASK (SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \
113 SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX)
114#define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \
115 SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL | \
116 SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \
117 SDHCI_INT_DATA_END_BIT)
118
119#define SDHCI_ACMD12_ERR 0x3C
120
121/* 3E-3F reserved */
122
123#define SDHCI_CAPABILITIES 0x40
124#define SDHCI_CAN_DO_DMA 0x00400000
125#define SDHCI_CLOCK_BASE_MASK 0x00003F00
126#define SDHCI_CLOCK_BASE_SHIFT 8
127
128/* 44-47 reserved for more caps */
129
130#define SDHCI_MAX_CURRENT 0x48
131
132/* 4C-4F reserved for more max current */
133
134/* 50-FB reserved */
135
136#define SDHCI_SLOT_INT_STATUS 0xFC
137
138#define SDHCI_HOST_VERSION 0xFE
139
140struct sdhci_chip;
141
142struct sdhci_host {
143 struct sdhci_chip *chip;
144 struct mmc_host *mmc; /* MMC structure */
145
146 spinlock_t lock; /* Mutex */
147
148 int flags; /* Host attributes */
149#define SDHCI_USE_DMA (1<<0)
150
151 unsigned int max_clk; /* Max possible freq (MHz) */
152
153 unsigned int clock; /* Current clock (MHz) */
154
155 struct mmc_request *mrq; /* Current request */
156 struct mmc_command *cmd; /* Current command */
157 struct mmc_data *data; /* Current data request */
158
159 struct scatterlist *cur_sg; /* We're working on this */
160 char *mapped_sg; /* This is where it's mapped */
161 int num_sg; /* Entries left */
162 int offset; /* Offset into current sg */
163 int remain; /* Bytes left in current */
164
165 int size; /* Remaining bytes in transfer */
166
167 char slot_descr[20]; /* Name for reservations */
168
169 int irq; /* Device IRQ */
170 int bar; /* PCI BAR index */
171 unsigned long addr; /* Bus address */
172 void __iomem * ioaddr; /* Mapped address */
173
174 struct tasklet_struct card_tasklet; /* Tasklet structures */
175 struct tasklet_struct finish_tasklet;
176
177 struct timer_list timer; /* Timer for timeouts */
178};
179
180struct sdhci_chip {
181 struct pci_dev *pdev;
182
183 int num_slots; /* Slots on controller */
184 struct sdhci_host *hosts[0]; /* Pointers to hosts */
185};
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index f0f8916da7ad..f988c817e196 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -28,7 +28,7 @@
28 28
29#ifdef CONFIG_MTD_DEBUG 29#ifdef CONFIG_MTD_DEBUG
30static int debug = CONFIG_MTD_DEBUG_VERBOSE; 30static int debug = CONFIG_MTD_DEBUG_VERBOSE;
31MODULE_PARM(debug, "i"); 31module_param(debug, int, 0);
32MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy"); 32MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy");
33#undef DEBUG 33#undef DEBUG
34#define DEBUG(n, format, arg...) \ 34#define DEBUG(n, format, arg...) \
@@ -89,17 +89,17 @@ static int mem_type;
89MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
90MODULE_AUTHOR("Simon Evans <spse@secret.org.uk>"); 90MODULE_AUTHOR("Simon Evans <spse@secret.org.uk>");
91MODULE_DESCRIPTION(DRIVER_DESC); 91MODULE_DESCRIPTION(DRIVER_DESC);
92MODULE_PARM(bankwidth, "i"); 92module_param(bankwidth, int, 0);
93MODULE_PARM_DESC(bankwidth, "Set bankwidth (1=8 bit, 2=16 bit, default=2)"); 93MODULE_PARM_DESC(bankwidth, "Set bankwidth (1=8 bit, 2=16 bit, default=2)");
94MODULE_PARM(mem_speed, "i"); 94module_param(mem_speed, int, 0);
95MODULE_PARM_DESC(mem_speed, "Set memory access speed in ns"); 95MODULE_PARM_DESC(mem_speed, "Set memory access speed in ns");
96MODULE_PARM(force_size, "i"); 96module_param(force_size, int, 0);
97MODULE_PARM_DESC(force_size, "Force size of card in MiB (1-64)"); 97MODULE_PARM_DESC(force_size, "Force size of card in MiB (1-64)");
98MODULE_PARM(setvpp, "i"); 98module_param(setvpp, int, 0);
99MODULE_PARM_DESC(setvpp, "Set Vpp (0=Never, 1=On writes, 2=Always on, default=0)"); 99MODULE_PARM_DESC(setvpp, "Set Vpp (0=Never, 1=On writes, 2=Always on, default=0)");
100MODULE_PARM(vpp, "i"); 100module_param(vpp, int, 0);
101MODULE_PARM_DESC(vpp, "Vpp value in 1/10ths eg 33=3.3V 120=12V (Dangerous)"); 101MODULE_PARM_DESC(vpp, "Vpp value in 1/10ths eg 33=3.3V 120=12V (Dangerous)");
102MODULE_PARM(mem_type, "i"); 102module_param(mem_type, int, 0);
103MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)"); 103MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)");
104 104
105 105
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 5d11a06ecb2c..d339308539fa 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1096,14 +1096,18 @@ static int __init vortex_eisa_init (void)
1096 int orig_cards_found = vortex_cards_found; 1096 int orig_cards_found = vortex_cards_found;
1097 1097
1098#ifdef CONFIG_EISA 1098#ifdef CONFIG_EISA
1099 if (eisa_driver_register (&vortex_eisa_driver) >= 0) { 1099 int err;
1100 /* Because of the way EISA bus is probed, we cannot assume 1100
1101 * any device have been found when we exit from 1101 err = eisa_driver_register (&vortex_eisa_driver);
1102 * eisa_driver_register (the bus root driver may not be 1102 if (!err) {
1103 * initialized yet). So we blindly assume something was 1103 /*
1104 * found, and let the sysfs magic happend... */ 1104 * Because of the way EISA bus is probed, we cannot assume
1105 1105 * any device have been found when we exit from
1106 eisa_found = 1; 1106 * eisa_driver_register (the bus root driver may not be
1107 * initialized yet). So we blindly assume something was
1108 * found, and let the sysfs magic happend...
1109 */
1110 eisa_found = 1;
1107 } 1111 }
1108#endif 1112#endif
1109 1113
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index f5ee064ab6b2..feae7832fc84 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)
1131 No extra delay is needed with 33Mhz PCI, but 66Mhz may change this. 1131 No extra delay is needed with 33Mhz PCI, but 66Mhz may change this.
1132 */ 1132 */
1133 1133
1134#define eeprom_delay() RTL_R32(Cfg9346) 1134#define eeprom_delay() (void)RTL_R32(Cfg9346)
1135 1135
1136/* The EEPROM commands include the alway-set leading bit. */ 1136/* The EEPROM commands include the alway-set leading bit. */
1137#define EE_WRITE_CMD (5) 1137#define EE_WRITE_CMD (5)
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index 8e538a6d7d97..79bb56b8dcef 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)
829 829
830static int __init a2065_init_module(void) 830static int __init a2065_init_module(void)
831{ 831{
832 return zorro_module_init(&a2065_driver); 832 return zorro_register_driver(&a2065_driver);
833} 833}
834 834
835static void __exit a2065_cleanup_module(void) 835static void __exit a2065_cleanup_module(void)
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index 9fe93acfc8ef..d1b6b1f794e2 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)
864 864
865static int __init ariadne_init_module(void) 865static int __init ariadne_init_module(void)
866{ 866{
867 return zorro_module_init(&ariadne_driver); 867 return zorro_register_driver(&ariadne_driver);
868} 868}
869 869
870static void __exit ariadne_cleanup_module(void) 870static void __exit ariadne_cleanup_module(void)
diff --git a/drivers/net/arm/Kconfig b/drivers/net/arm/Kconfig
index 625184b65e38..77fe20dbea35 100644
--- a/drivers/net/arm/Kconfig
+++ b/drivers/net/arm/Kconfig
@@ -31,3 +31,11 @@ config ARM_ETHERH
31 help 31 help
32 If you have an Acorn system with one of these network cards, you 32 If you have an Acorn system with one of these network cards, you
33 should say Y to this option if you wish to use it with Linux. 33 should say Y to this option if you wish to use it with Linux.
34
35config ARM_AT91_ETHER
36 tristate "AT91RM9200 Ethernet support"
37 depends on NET_ETHERNET && ARM && ARCH_AT91RM9200
38 select MII
39 help
40 If you wish to compile a kernel for the AT91RM9200 and enable
41 ethernet support, then you should always answer Y to this.
diff --git a/drivers/net/arm/Makefile b/drivers/net/arm/Makefile
index bc263edf06a7..42c95b79c261 100644
--- a/drivers/net/arm/Makefile
+++ b/drivers/net/arm/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARM_AM79C961A) += am79c961a.o
7obj-$(CONFIG_ARM_ETHERH) += etherh.o 7obj-$(CONFIG_ARM_ETHERH) += etherh.o
8obj-$(CONFIG_ARM_ETHER3) += ether3.o 8obj-$(CONFIG_ARM_ETHER3) += ether3.o
9obj-$(CONFIG_ARM_ETHER1) += ether1.o 9obj-$(CONFIG_ARM_ETHER1) += ether1.o
10obj-$(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 000000000000..5503dc8a66e4
--- /dev/null
+++ b/drivers/net/arm/at91_ether.c
@@ -0,0 +1,1110 @@
1/*
2 * Ethernet driver for the Atmel AT91RM9200 (Thunder)
3 *
4 * Copyright (C) 2003 SAN People (Pty) Ltd
5 *
6 * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
7 * Initial version by Rick Bronson 01/11/2003
8 *
9 * Intel LXT971A PHY support by Christopher Bahns & David Knickerbocker
10 * (Polaroid Corporation)
11 *
12 * Realtek RTL8201(B)L PHY support by Roman Avramenko <roman@imsystems.ru>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/config.h>
23#include <linux/mii.h>
24#include <linux/netdevice.h>
25#include <linux/etherdevice.h>
26#include <linux/skbuff.h>
27#include <linux/dma-mapping.h>
28#include <linux/ethtool.h>
29#include <linux/platform_device.h>
30#include <linux/clk.h>
31
32#include <asm/io.h>
33#include <asm/uaccess.h>
34#include <asm/mach-types.h>
35
36#include <asm/arch/at91rm9200_emac.h>
37#include <asm/arch/gpio.h>
38#include <asm/arch/board.h>
39
40#include "at91_ether.h"
41
42#define DRV_NAME "at91_ether"
43#define DRV_VERSION "1.0"
44
45static struct net_device *at91_dev;
46static struct clk *ether_clk;
47
48/* ..................................................................... */
49
50/*
51 * Read from a EMAC register.
52 */
53static inline unsigned long at91_emac_read(unsigned int reg)
54{
55 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
56
57 return __raw_readl(emac_base + reg);
58}
59
60/*
61 * Write to a EMAC register.
62 */
63static inline void at91_emac_write(unsigned int reg, unsigned long value)
64{
65 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
66
67 __raw_writel(value, emac_base + reg);
68}
69
70/* ........................... PHY INTERFACE ........................... */
71
72/*
73 * Enable the MDIO bit in MAC control register
74 * When not called from an interrupt-handler, access to the PHY must be
75 * protected by a spinlock.
76 */
77static void enable_mdi(void)
78{
79 unsigned long ctl;
80
81 ctl = at91_emac_read(AT91_EMAC_CTL);
82 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_MPE); /* enable management port */
83}
84
85/*
86 * Disable the MDIO bit in the MAC control register
87 */
88static void disable_mdi(void)
89{
90 unsigned long ctl;
91
92 ctl = at91_emac_read(AT91_EMAC_CTL);
93 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_MPE); /* disable management port */
94}
95
96/*
97 * Wait until the PHY operation is complete.
98 */
99static inline void at91_phy_wait(void) {
100 unsigned long timeout = jiffies + 2;
101
102 while (!(at91_emac_read(AT91_EMAC_SR) & AT91_EMAC_SR_IDLE)) {
103 if (time_after(jiffies, timeout)) {
104 printk("at91_ether: MIO timeout\n");
105 break;
106 }
107 cpu_relax();
108 }
109}
110
111/*
112 * Write value to the a PHY register
113 * Note: MDI interface is assumed to already have been enabled.
114 */
115static void write_phy(unsigned char phy_addr, unsigned char address, unsigned int value)
116{
117 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_W
118 | ((phy_addr & 0x1f) << 23) | (address << 18) | (value & AT91_EMAC_DATA));
119
120 /* Wait until IDLE bit in Network Status register is cleared */
121 at91_phy_wait();
122}
123
124/*
125 * Read value stored in a PHY register.
126 * Note: MDI interface is assumed to already have been enabled.
127 */
128static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int *value)
129{
130 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_R
131 | ((phy_addr & 0x1f) << 23) | (address << 18));
132
133 /* Wait until IDLE bit in Network Status register is cleared */
134 at91_phy_wait();
135
136 *value = at91_emac_read(AT91_EMAC_MAN) & AT91_EMAC_DATA;
137}
138
139/* ........................... PHY MANAGEMENT .......................... */
140
141/*
142 * Access the PHY to determine the current link speed and mode, and update the
143 * MAC accordingly.
144 * If no link or auto-negotiation is busy, then no changes are made.
145 */
146static void update_linkspeed(struct net_device *dev)
147{
148 struct at91_private *lp = (struct at91_private *) dev->priv;
149 unsigned int bmsr, bmcr, lpa, mac_cfg;
150 unsigned int speed, duplex;
151
152 if (!mii_link_ok(&lp->mii)) { /* no link */
153 netif_carrier_off(dev);
154 printk(KERN_INFO "%s: Link down.\n", dev->name);
155 return;
156 }
157
158 /* Link up, or auto-negotiation still in progress */
159 read_phy(lp->phy_address, MII_BMSR, &bmsr);
160 read_phy(lp->phy_address, MII_BMCR, &bmcr);
161 if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
162 if (!(bmsr & BMSR_ANEGCOMPLETE))
163 return; /* Do nothing - another interrupt generated when negotiation complete */
164
165 read_phy(lp->phy_address, MII_LPA, &lpa);
166 if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
167 else speed = SPEED_10;
168 if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL;
169 else duplex = DUPLEX_HALF;
170 } else {
171 speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
172 duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
173 }
174
175 /* Update the MAC */
176 mac_cfg = at91_emac_read(AT91_EMAC_CFG) & ~(AT91_EMAC_SPD | AT91_EMAC_FD);
177 if (speed == SPEED_100) {
178 if (duplex == DUPLEX_FULL) /* 100 Full Duplex */
179 mac_cfg |= AT91_EMAC_SPD | AT91_EMAC_FD;
180 else /* 100 Half Duplex */
181 mac_cfg |= AT91_EMAC_SPD;
182 } else {
183 if (duplex == DUPLEX_FULL) /* 10 Full Duplex */
184 mac_cfg |= AT91_EMAC_FD;
185 else {} /* 10 Half Duplex */
186 }
187 at91_emac_write(AT91_EMAC_CFG, mac_cfg);
188
189 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
190 netif_carrier_on(dev);
191}
192
193/*
194 * Handle interrupts from the PHY
195 */
196static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
197{
198 struct net_device *dev = (struct net_device *) dev_id;
199 struct at91_private *lp = (struct at91_private *) dev->priv;
200 unsigned int phy;
201
202 /*
203 * This hander is triggered on both edges, but the PHY chips expect
204 * level-triggering. We therefore have to check if the PHY actually has
205 * an IRQ pending.
206 */
207 enable_mdi();
208 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
209 read_phy(lp->phy_address, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */
210 if (!(phy & (1 << 0)))
211 goto done;
212 }
213 else if (lp->phy_type == MII_LXT971A_ID) {
214 read_phy(lp->phy_address, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */
215 if (!(phy & (1 << 2)))
216 goto done;
217 }
218 else if (lp->phy_type == MII_BCM5221_ID) {
219 read_phy(lp->phy_address, MII_BCMINTR_REG, &phy); /* ack interrupt in Broadcom PHY */
220 if (!(phy & (1 << 0)))
221 goto done;
222 }
223 else if (lp->phy_type == MII_KS8721_ID) {
224 read_phy(lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */
225 if (!(phy & ((1 << 2) | 1)))
226 goto done;
227 }
228
229 update_linkspeed(dev);
230
231done:
232 disable_mdi();
233
234 return IRQ_HANDLED;
235}
236
237/*
238 * Initialize and enable the PHY interrupt for link-state changes
239 */
240static void enable_phyirq(struct net_device *dev)
241{
242 struct at91_private *lp = (struct at91_private *) dev->priv;
243 unsigned int dsintr, irq_number;
244 int status;
245
246 if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */
247 return;
248 if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */
249 return;
250 if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */
251 return;
252
253 irq_number = lp->board_data.phy_irq_pin;
254 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
255 if (status) {
256 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
257 return;
258 }
259
260 spin_lock_irq(&lp->lock);
261 enable_mdi();
262
263 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
264 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
265 dsintr = dsintr & ~0xf00; /* clear bits 8..11 */
266 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
267 }
268 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
269 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
270 dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */
271 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
272 }
273 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
274 dsintr = (1 << 15) | ( 1 << 14);
275 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
276 }
277 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
278 dsintr = (1 << 10) | ( 1 << 8);
279 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
280 }
281
282 disable_mdi();
283 spin_unlock_irq(&lp->lock);
284}
285
286/*
287 * Disable the PHY interrupt
288 */
289static void disable_phyirq(struct net_device *dev)
290{
291 struct at91_private *lp = (struct at91_private *) dev->priv;
292 unsigned int dsintr;
293 unsigned int irq_number;
294
295 if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */
296 return;
297 if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */
298 return;
299 if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */
300 return;
301
302 spin_lock_irq(&lp->lock);
303 enable_mdi();
304
305 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
306 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
307 dsintr = dsintr | 0xf00; /* set bits 8..11 */
308 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
309 }
310 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
311 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
312 dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */
313 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
314 }
315 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
316 read_phy(lp->phy_address, MII_BCMINTR_REG, &dsintr);
317 dsintr = ~(1 << 14);
318 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
319 }
320 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
321 read_phy(lp->phy_address, MII_TPISTATUS, &dsintr);
322 dsintr = ~((1 << 10) | (1 << 8));
323 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
324 }
325
326 disable_mdi();
327 spin_unlock_irq(&lp->lock);
328
329 irq_number = lp->board_data.phy_irq_pin;
330 free_irq(irq_number, dev); /* Free interrupt handler */
331}
332
333/*
334 * Perform a software reset of the PHY.
335 */
336#if 0
337static void reset_phy(struct net_device *dev)
338{
339 struct at91_private *lp = (struct at91_private *) dev->priv;
340 unsigned int bmcr;
341
342 spin_lock_irq(&lp->lock);
343 enable_mdi();
344
345 /* Perform PHY reset */
346 write_phy(lp->phy_address, MII_BMCR, BMCR_RESET);
347
348 /* Wait until PHY reset is complete */
349 do {
350 read_phy(lp->phy_address, MII_BMCR, &bmcr);
351 } while (!(bmcr && BMCR_RESET));
352
353 disable_mdi();
354 spin_unlock_irq(&lp->lock);
355}
356#endif
357
358/* ......................... ADDRESS MANAGEMENT ........................ */
359
360/*
361 * NOTE: Your bootloader must always set the MAC address correctly before
362 * booting into Linux.
363 *
364 * - It must always set the MAC address after reset, even if it doesn't
365 * happen to access the Ethernet while it's booting. Some versions of
366 * U-Boot on the AT91RM9200-DK do not do this.
367 *
368 * - Likewise it must store the addresses in the correct byte order.
369 * MicroMonitor (uMon) on the CSB337 does this incorrectly (and
370 * continues to do so, for bug-compatibility).
371 */
372
373static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
374{
375 char addr[6];
376
377 if (machine_is_csb337()) {
378 addr[5] = (lo & 0xff); /* The CSB337 bootloader stores the MAC the wrong-way around */
379 addr[4] = (lo & 0xff00) >> 8;
380 addr[3] = (lo & 0xff0000) >> 16;
381 addr[2] = (lo & 0xff000000) >> 24;
382 addr[1] = (hi & 0xff);
383 addr[0] = (hi & 0xff00) >> 8;
384 }
385 else {
386 addr[0] = (lo & 0xff);
387 addr[1] = (lo & 0xff00) >> 8;
388 addr[2] = (lo & 0xff0000) >> 16;
389 addr[3] = (lo & 0xff000000) >> 24;
390 addr[4] = (hi & 0xff);
391 addr[5] = (hi & 0xff00) >> 8;
392 }
393
394 if (is_valid_ether_addr(addr)) {
395 memcpy(dev->dev_addr, &addr, 6);
396 return 1;
397 }
398 return 0;
399}
400
401/*
402 * Set the ethernet MAC address in dev->dev_addr
403 */
404static void __init get_mac_address(struct net_device *dev)
405{
406 /* Check Specific-Address 1 */
407 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA1H), at91_emac_read(AT91_EMAC_SA1L)))
408 return;
409 /* Check Specific-Address 2 */
410 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA2H), at91_emac_read(AT91_EMAC_SA2L)))
411 return;
412 /* Check Specific-Address 3 */
413 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA3H), at91_emac_read(AT91_EMAC_SA3L)))
414 return;
415 /* Check Specific-Address 4 */
416 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA4H), at91_emac_read(AT91_EMAC_SA4L)))
417 return;
418
419 printk(KERN_ERR "at91_ether: Your bootloader did not configure a MAC address.\n");
420}
421
422/*
423 * Program the hardware MAC address from dev->dev_addr.
424 */
425static void update_mac_address(struct net_device *dev)
426{
427 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]));
428 at91_emac_write(AT91_EMAC_SA1H, (dev->dev_addr[5] << 8) | (dev->dev_addr[4]));
429
430 at91_emac_write(AT91_EMAC_SA2L, 0);
431 at91_emac_write(AT91_EMAC_SA2H, 0);
432}
433
434/*
435 * Store the new hardware address in dev->dev_addr, and update the MAC.
436 */
437static int set_mac_address(struct net_device *dev, void* addr)
438{
439 struct sockaddr *address = addr;
440
441 if (!is_valid_ether_addr(address->sa_data))
442 return -EADDRNOTAVAIL;
443
444 memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
445 update_mac_address(dev);
446
447 printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
448 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
449 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
450
451 return 0;
452}
453
454static int inline hash_bit_value(int bitnr, __u8 *addr)
455{
456 if (addr[bitnr / 8] & (1 << (bitnr % 8)))
457 return 1;
458 return 0;
459}
460
461/*
462 * The hash address register is 64 bits long and takes up two locations in the memory map.
463 * The least significant bits are stored in EMAC_HSL and the most significant
464 * bits in EMAC_HSH.
465 *
466 * The unicast hash enable and the multicast hash enable bits in the network configuration
467 * register enable the reception of hash matched frames. The destination address is
468 * reduced to a 6 bit index into the 64 bit hash register using the following hash function.
469 * The hash function is an exclusive or of every sixth bit of the destination address.
470 * hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47]
471 * hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46]
472 * hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45]
473 * hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44]
474 * hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43]
475 * hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42]
476 * da[0] represents the least significant bit of the first byte received, that is, the multicast/
477 * unicast indicator, and da[47] represents the most significant bit of the last byte
478 * received.
479 * If the hash index points to a bit that is set in the hash register then the frame will be
480 * matched according to whether the frame is multicast or unicast.
481 * A multicast match will be signalled if the multicast hash enable bit is set, da[0] is 1 and
482 * the hash index points to a bit set in the hash register.
483 * A unicast match will be signalled if the unicast hash enable bit is set, da[0] is 0 and the
484 * hash index points to a bit set in the hash register.
485 * To receive all multicast frames, the hash register should be set with all ones and the
486 * multicast hash enable bit should be set in the network configuration register.
487 */
488
489/*
490 * Return the hash index value for the specified address.
491 */
492static int hash_get_index(__u8 *addr)
493{
494 int i, j, bitval;
495 int hash_index = 0;
496
497 for (j = 0; j < 6; j++) {
498 for (i = 0, bitval = 0; i < 8; i++)
499 bitval ^= hash_bit_value(i*6 + j, addr);
500
501 hash_index |= (bitval << j);
502 }
503
504 return hash_index;
505}
506
507/*
508 * Add multicast addresses to the internal multicast-hash table.
509 */
510static void at91ether_sethashtable(struct net_device *dev)
511{
512 struct dev_mc_list *curr;
513 unsigned long mc_filter[2];
514 unsigned int i, bitnr;
515
516 mc_filter[0] = mc_filter[1] = 0;
517
518 curr = dev->mc_list;
519 for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
520 if (!curr) break; /* unexpected end of list */
521
522 bitnr = hash_get_index(curr->dmi_addr);
523 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
524 }
525
526 at91_emac_write(AT91_EMAC_HSH, mc_filter[0]);
527 at91_emac_write(AT91_EMAC_HSL, mc_filter[1]);
528}
529
530/*
531 * Enable/Disable promiscuous and multicast modes.
532 */
533static void at91ether_set_rx_mode(struct net_device *dev)
534{
535 unsigned long cfg;
536
537 cfg = at91_emac_read(AT91_EMAC_CFG);
538
539 if (dev->flags & IFF_PROMISC) /* Enable promiscuous mode */
540 cfg |= AT91_EMAC_CAF;
541 else if (dev->flags & (~IFF_PROMISC)) /* Disable promiscuous mode */
542 cfg &= ~AT91_EMAC_CAF;
543
544 if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */
545 at91_emac_write(AT91_EMAC_HSH, -1);
546 at91_emac_write(AT91_EMAC_HSL, -1);
547 cfg |= AT91_EMAC_MTI;
548 } else if (dev->mc_count > 0) { /* Enable specific multicasts */
549 at91ether_sethashtable(dev);
550 cfg |= AT91_EMAC_MTI;
551 } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
552 at91_emac_write(AT91_EMAC_HSH, 0);
553 at91_emac_write(AT91_EMAC_HSL, 0);
554 cfg &= ~AT91_EMAC_MTI;
555 }
556
557 at91_emac_write(AT91_EMAC_CFG, cfg);
558}
559
560
561/* ......................... ETHTOOL SUPPORT ........................... */
562
563
564static int mdio_read(struct net_device *dev, int phy_id, int location)
565{
566 unsigned int value;
567
568 read_phy(phy_id, location, &value);
569 return value;
570}
571
572static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
573{
574 write_phy(phy_id, location, value);
575}
576
577static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
578{
579 struct at91_private *lp = (struct at91_private *) dev->priv;
580 int ret;
581
582 spin_lock_irq(&lp->lock);
583 enable_mdi();
584
585 ret = mii_ethtool_gset(&lp->mii, cmd);
586
587 disable_mdi();
588 spin_unlock_irq(&lp->lock);
589
590 if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */
591 cmd->supported = SUPPORTED_FIBRE;
592 cmd->port = PORT_FIBRE;
593 }
594
595 return ret;
596}
597
598static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
599{
600 struct at91_private *lp = (struct at91_private *) dev->priv;
601 int ret;
602
603 spin_lock_irq(&lp->lock);
604 enable_mdi();
605
606 ret = mii_ethtool_sset(&lp->mii, cmd);
607
608 disable_mdi();
609 spin_unlock_irq(&lp->lock);
610
611 return ret;
612}
613
614static int at91ether_nwayreset(struct net_device *dev)
615{
616 struct at91_private *lp = (struct at91_private *) dev->priv;
617 int ret;
618
619 spin_lock_irq(&lp->lock);
620 enable_mdi();
621
622 ret = mii_nway_restart(&lp->mii);
623
624 disable_mdi();
625 spin_unlock_irq(&lp->lock);
626
627 return ret;
628}
629
630static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
631{
632 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
633 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
634 strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info));
635}
636
637static struct ethtool_ops at91ether_ethtool_ops = {
638 .get_settings = at91ether_get_settings,
639 .set_settings = at91ether_set_settings,
640 .get_drvinfo = at91ether_get_drvinfo,
641 .nway_reset = at91ether_nwayreset,
642 .get_link = ethtool_op_get_link,
643};
644
645
646/* ................................ MAC ................................ */
647
648/*
649 * Initialize and start the Receiver and Transmit subsystems
650 */
651static void at91ether_start(struct net_device *dev)
652{
653 struct at91_private *lp = (struct at91_private *) dev->priv;
654 struct recv_desc_bufs *dlist, *dlist_phys;
655 int i;
656 unsigned long ctl;
657
658 dlist = lp->dlist;
659 dlist_phys = lp->dlist_phys;
660
661 for (i = 0; i < MAX_RX_DESCR; i++) {
662 dlist->descriptors[i].addr = (unsigned int) &dlist_phys->recv_buf[i][0];
663 dlist->descriptors[i].size = 0;
664 }
665
666 /* Set the Wrap bit on the last descriptor */
667 dlist->descriptors[i-1].addr |= EMAC_DESC_WRAP;
668
669 /* Reset buffer index */
670 lp->rxBuffIndex = 0;
671
672 /* Program address of descriptor list in Rx Buffer Queue register */
673 at91_emac_write(AT91_EMAC_RBQP, (unsigned long) dlist_phys);
674
675 /* Enable Receive and Transmit */
676 ctl = at91_emac_read(AT91_EMAC_CTL);
677 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE | AT91_EMAC_TE);
678}
679
680/*
681 * Open the ethernet interface
682 */
683static int at91ether_open(struct net_device *dev)
684{
685 struct at91_private *lp = (struct at91_private *) dev->priv;
686 unsigned long ctl;
687
688 if (!is_valid_ether_addr(dev->dev_addr))
689 return -EADDRNOTAVAIL;
690
691 clk_enable(ether_clk); /* Re-enable Peripheral clock */
692
693 /* Clear internal statistics */
694 ctl = at91_emac_read(AT91_EMAC_CTL);
695 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_CSR);
696
697 /* Update the MAC address (incase user has changed it) */
698 update_mac_address(dev);
699
700 /* Enable PHY interrupt */
701 enable_phyirq(dev);
702
703 /* Enable MAC interrupts */
704 at91_emac_write(AT91_EMAC_IER, AT91_EMAC_RCOM | AT91_EMAC_RBNA
705 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
706 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
707
708 /* Determine current link speed */
709 spin_lock_irq(&lp->lock);
710 enable_mdi();
711 update_linkspeed(dev);
712 disable_mdi();
713 spin_unlock_irq(&lp->lock);
714
715 at91ether_start(dev);
716 netif_start_queue(dev);
717 return 0;
718}
719
720/*
721 * Close the interface
722 */
723static int at91ether_close(struct net_device *dev)
724{
725 unsigned long ctl;
726
727 /* Disable Receiver and Transmitter */
728 ctl = at91_emac_read(AT91_EMAC_CTL);
729 at91_emac_write(AT91_EMAC_CTL, ctl & ~(AT91_EMAC_TE | AT91_EMAC_RE));
730
731 /* Disable PHY interrupt */
732 disable_phyirq(dev);
733
734 /* Disable MAC interrupts */
735 at91_emac_write(AT91_EMAC_IDR, AT91_EMAC_RCOM | AT91_EMAC_RBNA
736 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
737 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
738
739 netif_stop_queue(dev);
740
741 clk_disable(ether_clk); /* Disable Peripheral clock */
742
743 return 0;
744}
745
746/*
747 * Transmit packet.
748 */
749static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
750{
751 struct at91_private *lp = (struct at91_private *) dev->priv;
752
753 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
754 netif_stop_queue(dev);
755
756 /* Store packet information (to free when Tx completed) */
757 lp->skb = skb;
758 lp->skb_length = skb->len;
759 lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
760 lp->stats.tx_bytes += skb->len;
761
762 /* Set address of the data in the Transmit Address register */
763 at91_emac_write(AT91_EMAC_TAR, lp->skb_physaddr);
764 /* Set length of the packet in the Transmit Control register */
765 at91_emac_write(AT91_EMAC_TCR, skb->len);
766
767 dev->trans_start = jiffies;
768 } else {
769 printk(KERN_ERR "at91_ether.c: at91ether_tx() called, but device is busy!\n");
770 return 1; /* if we return anything but zero, dev.c:1055 calls kfree_skb(skb)
771 on this skb, he also reports -ENETDOWN and printk's, so either
772 we free and return(0) or don't free and return 1 */
773 }
774
775 return 0;
776}
777
778/*
779 * Update the current statistics from the internal statistics registers.
780 */
781static struct net_device_stats *at91ether_stats(struct net_device *dev)
782{
783 struct at91_private *lp = (struct at91_private *) dev->priv;
784 int ale, lenerr, seqe, lcol, ecol;
785
786 if (netif_running(dev)) {
787 lp->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */
788 ale = at91_emac_read(AT91_EMAC_ALE);
789 lp->stats.rx_frame_errors += ale; /* Alignment errors */
790 lenerr = at91_emac_read(AT91_EMAC_ELR) + at91_emac_read(AT91_EMAC_USF);
791 lp->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
792 seqe = at91_emac_read(AT91_EMAC_SEQE);
793 lp->stats.rx_crc_errors += seqe; /* CRC error */
794 lp->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */
795 lp->stats.rx_errors += (ale + lenerr + seqe
796 + at91_emac_read(AT91_EMAC_CDE) + at91_emac_read(AT91_EMAC_RJB));
797
798 lp->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */
799 lp->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */
800 lp->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */
801 lp->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */
802
803 lcol = at91_emac_read(AT91_EMAC_LCOL);
804 ecol = at91_emac_read(AT91_EMAC_ECOL);
805 lp->stats.tx_window_errors += lcol; /* Late collisions */
806 lp->stats.tx_aborted_errors += ecol; /* 16 collisions */
807
808 lp->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + lcol + ecol);
809 }
810 return &lp->stats;
811}
812
813/*
814 * Extract received frame from buffer descriptors and sent to upper layers.
815 * (Called from interrupt context)
816 */
817static void at91ether_rx(struct net_device *dev)
818{
819 struct at91_private *lp = (struct at91_private *) dev->priv;
820 struct recv_desc_bufs *dlist;
821 unsigned char *p_recv;
822 struct sk_buff *skb;
823 unsigned int pktlen;
824
825 dlist = lp->dlist;
826 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
827 p_recv = dlist->recv_buf[lp->rxBuffIndex];
828 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
829 skb = alloc_skb(pktlen + 2, GFP_ATOMIC);
830 if (skb != NULL) {
831 skb_reserve(skb, 2);
832 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
833
834 skb->dev = dev;
835 skb->protocol = eth_type_trans(skb, dev);
836 skb->len = pktlen;
837 dev->last_rx = jiffies;
838 lp->stats.rx_bytes += pktlen;
839 netif_rx(skb);
840 }
841 else {
842 lp->stats.rx_dropped += 1;
843 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
844 }
845
846 if (dlist->descriptors[lp->rxBuffIndex].size & EMAC_MULTICAST)
847 lp->stats.multicast++;
848
849 dlist->descriptors[lp->rxBuffIndex].addr &= ~EMAC_DESC_DONE; /* reset ownership bit */
850 if (lp->rxBuffIndex == MAX_RX_DESCR-1) /* wrap after last buffer */
851 lp->rxBuffIndex = 0;
852 else
853 lp->rxBuffIndex++;
854 }
855}
856
857/*
858 * MAC interrupt handler
859 */
860static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *regs)
861{
862 struct net_device *dev = (struct net_device *) dev_id;
863 struct at91_private *lp = (struct at91_private *) dev->priv;
864 unsigned long intstatus, ctl;
865
866 /* MAC Interrupt Status register indicates what interrupts are pending.
867 It is automatically cleared once read. */
868 intstatus = at91_emac_read(AT91_EMAC_ISR);
869
870 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */
871 at91ether_rx(dev);
872
873 if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */
874 /* The TCOM bit is set even if the transmission failed. */
875 if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY))
876 lp->stats.tx_errors += 1;
877
878 if (lp->skb) {
879 dev_kfree_skb_irq(lp->skb);
880 lp->skb = NULL;
881 dma_unmap_single(NULL, lp->skb_physaddr, lp->skb_length, DMA_TO_DEVICE);
882 }
883 netif_wake_queue(dev);
884 }
885
886 /* Work-around for Errata #11 */
887 if (intstatus & AT91_EMAC_RBNA) {
888 ctl = at91_emac_read(AT91_EMAC_CTL);
889 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_RE);
890 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE);
891 }
892
893 if (intstatus & AT91_EMAC_ROVR)
894 printk("%s: ROVR error\n", dev->name);
895
896 return IRQ_HANDLED;
897}
898
899/*
900 * Initialize the ethernet interface
901 */
902static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev)
903{
904 struct at91_eth_data *board_data = pdev->dev.platform_data;
905 struct net_device *dev;
906 struct at91_private *lp;
907 unsigned int val;
908 int res;
909
910 if (at91_dev) /* already initialized */
911 return 0;
912
913 dev = alloc_etherdev(sizeof(struct at91_private));
914 if (!dev)
915 return -ENOMEM;
916
917 dev->base_addr = AT91_VA_BASE_EMAC;
918 dev->irq = AT91_ID_EMAC;
919 SET_MODULE_OWNER(dev);
920
921 /* Install the interrupt handler */
922 if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) {
923 free_netdev(dev);
924 return -EBUSY;
925 }
926
927 /* Allocate memory for DMA Receive descriptors */
928 lp = (struct at91_private *)dev->priv;
929 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
930 if (lp->dlist == NULL) {
931 free_irq(dev->irq, dev);
932 free_netdev(dev);
933 return -ENOMEM;
934 }
935 lp->board_data = *board_data;
936 platform_set_drvdata(pdev, dev);
937
938 spin_lock_init(&lp->lock);
939
940 ether_setup(dev);
941 dev->open = at91ether_open;
942 dev->stop = at91ether_close;
943 dev->hard_start_xmit = at91ether_tx;
944 dev->get_stats = at91ether_stats;
945 dev->set_multicast_list = at91ether_set_rx_mode;
946 dev->set_mac_address = set_mac_address;
947 dev->ethtool_ops = &at91ether_ethtool_ops;
948
949 SET_NETDEV_DEV(dev, &pdev->dev);
950
951 get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */
952 update_mac_address(dev); /* Program ethernet address into MAC */
953
954 at91_emac_write(AT91_EMAC_CTL, 0);
955
956 if (lp->board_data.is_rmii)
957 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG | AT91_EMAC_RMII);
958 else
959 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG);
960
961 /* Perform PHY-specific initialization */
962 spin_lock_irq(&lp->lock);
963 enable_mdi();
964 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
965 read_phy(phy_address, MII_DSCR_REG, &val);
966 if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */
967 lp->phy_media = PORT_FIBRE;
968 } else if (machine_is_csb337()) {
969 /* mix link activity status into LED2 link state */
970 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
971 }
972 disable_mdi();
973 spin_unlock_irq(&lp->lock);
974
975 lp->mii.dev = dev; /* Support for ethtool */
976 lp->mii.mdio_read = mdio_read;
977 lp->mii.mdio_write = mdio_write;
978
979 lp->phy_type = phy_type; /* Type of PHY connected */
980 lp->phy_address = phy_address; /* MDI address of PHY */
981
982 /* Register the network interface */
983 res = register_netdev(dev);
984 if (res) {
985 free_irq(dev->irq, dev);
986 free_netdev(dev);
987 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
988 return res;
989 }
990 at91_dev = dev;
991
992 /* Determine current link speed */
993 spin_lock_irq(&lp->lock);
994 enable_mdi();
995 update_linkspeed(dev);
996 disable_mdi();
997 spin_unlock_irq(&lp->lock);
998 netif_carrier_off(dev); /* will be enabled in open() */
999
1000 /* Display ethernet banner */
1001 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n",
1002 dev->name, (uint) dev->base_addr, dev->irq,
1003 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-",
1004 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex",
1005 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1006 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1007 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
1008 printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
1009 else if (phy_type == MII_LXT971A_ID)
1010 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
1011 else if (phy_type == MII_RTL8201_ID)
1012 printk(KERN_INFO "%s: Realtek RTL8201(B)L PHY\n", dev->name);
1013 else if (phy_type == MII_BCM5221_ID)
1014 printk(KERN_INFO "%s: Broadcom BCM5221 PHY\n", dev->name);
1015 else if (phy_type == MII_DP83847_ID)
1016 printk(KERN_INFO "%s: National Semiconductor DP83847 PHY\n", dev->name);
1017 else if (phy_type == MII_AC101L_ID)
1018 printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name);
1019 else if (phy_type == MII_KS8721_ID)
1020 printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name);
1021
1022 return 0;
1023}
1024
1025/*
1026 * Detect MAC and PHY and perform initialization
1027 */
1028static int __init at91ether_probe(struct platform_device *pdev)
1029{
1030 unsigned int phyid1, phyid2;
1031 int detected = -1;
1032 unsigned long phy_id;
1033 unsigned short phy_address = 0;
1034
1035 ether_clk = clk_get(&pdev->dev, "ether_clk");
1036 if (!ether_clk) {
1037 printk(KERN_ERR "at91_ether: no clock defined\n");
1038 return -ENODEV;
1039 }
1040 clk_enable(ether_clk); /* Enable Peripheral clock */
1041
1042 while ((detected != 0) && (phy_address < 32)) {
1043 /* Read the PHY ID registers */
1044 enable_mdi();
1045 read_phy(phy_address, MII_PHYSID1, &phyid1);
1046 read_phy(phy_address, MII_PHYSID2, &phyid2);
1047 disable_mdi();
1048
1049 phy_id = (phyid1 << 16) | (phyid2 & 0xfff0);
1050 switch (phy_id) {
1051 case MII_DM9161_ID: /* Davicom 9161: PHY_ID1 = 0x181, PHY_ID2 = B881 */
1052 case MII_DM9161A_ID: /* Davicom 9161A: PHY_ID1 = 0x181, PHY_ID2 = B8A0 */
1053 case MII_LXT971A_ID: /* Intel LXT971A: PHY_ID1 = 0x13, PHY_ID2 = 78E0 */
1054 case MII_RTL8201_ID: /* Realtek RTL8201: PHY_ID1 = 0, PHY_ID2 = 0x8201 */
1055 case MII_BCM5221_ID: /* Broadcom BCM5221: PHY_ID1 = 0x40, PHY_ID2 = 0x61e0 */
1056 case MII_DP83847_ID: /* National Semiconductor DP83847: */
1057 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
1058 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
1059 detected = at91ether_setup(phy_id, phy_address, pdev);
1060 break;
1061 }
1062
1063 phy_address++;
1064 }
1065
1066 clk_disable(ether_clk); /* Disable Peripheral clock */
1067
1068 return detected;
1069}
1070
1071static int __devexit at91ether_remove(struct platform_device *pdev)
1072{
1073 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1074
1075 unregister_netdev(at91_dev);
1076 free_irq(at91_dev->irq, at91_dev);
1077 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1078 clk_put(ether_clk);
1079
1080 free_netdev(at91_dev);
1081 at91_dev = NULL;
1082 return 0;
1083}
1084
1085static struct platform_driver at91ether_driver = {
1086 .probe = at91ether_probe,
1087 .remove = __devexit_p(at91ether_remove),
1088 /* FIXME: support suspend and resume */
1089 .driver = {
1090 .name = DRV_NAME,
1091 .owner = THIS_MODULE,
1092 },
1093};
1094
1095static int __init at91ether_init(void)
1096{
1097 return platform_driver_register(&at91ether_driver);
1098}
1099
1100static void __exit at91ether_exit(void)
1101{
1102 platform_driver_unregister(&at91ether_driver);
1103}
1104
1105module_init(at91ether_init)
1106module_exit(at91ether_exit)
1107
1108MODULE_LICENSE("GPL");
1109MODULE_DESCRIPTION("AT91RM9200 EMAC Ethernet driver");
1110MODULE_AUTHOR("Andrew Victor");
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h
new file mode 100644
index 000000000000..9885735c9c8a
--- /dev/null
+++ b/drivers/net/arm/at91_ether.h
@@ -0,0 +1,101 @@
1/*
2 * Ethernet driver for the Atmel AT91RM9200 (Thunder)
3 *
4 * Copyright (C) SAN People (Pty) Ltd
5 *
6 * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
7 * Initial version by Rick Bronson.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#ifndef AT91_ETHERNET
16#define AT91_ETHERNET
17
18
19/* Davicom 9161 PHY */
20#define MII_DM9161_ID 0x0181b880
21#define MII_DM9161A_ID 0x0181b8a0
22
23/* Davicom specific registers */
24#define MII_DSCR_REG 16
25#define MII_DSCSR_REG 17
26#define MII_DSINTR_REG 21
27
28/* Intel LXT971A PHY */
29#define MII_LXT971A_ID 0x001378E0
30
31/* Intel specific registers */
32#define MII_ISINTE_REG 18
33#define MII_ISINTS_REG 19
34#define MII_LEDCTRL_REG 20
35
36/* Realtek RTL8201 PHY */
37#define MII_RTL8201_ID 0x00008200
38
39/* Broadcom BCM5221 PHY */
40#define MII_BCM5221_ID 0x004061e0
41
42/* Broadcom specific registers */
43#define MII_BCMINTR_REG 26
44
45/* National Semiconductor DP83847 */
46#define MII_DP83847_ID 0x20005c30
47
48/* Altima AC101L PHY */
49#define MII_AC101L_ID 0x00225520
50
51/* Micrel KS8721 PHY */
52#define MII_KS8721_ID 0x00221610
53
54/* ........................................................................ */
55
56#define MAX_RBUFF_SZ 0x600 /* 1518 rounded up */
57#define MAX_RX_DESCR 9 /* max number of receive buffers */
58
59#define EMAC_DESC_DONE 0x00000001 /* bit for if DMA is done */
60#define EMAC_DESC_WRAP 0x00000002 /* bit for wrap */
61
62#define EMAC_BROADCAST 0x80000000 /* broadcast address */
63#define EMAC_MULTICAST 0x40000000 /* multicast address */
64#define EMAC_UNICAST 0x20000000 /* unicast address */
65
66struct rbf_t
67{
68 unsigned int addr;
69 unsigned long size;
70};
71
72struct recv_desc_bufs
73{
74 struct rbf_t descriptors[MAX_RX_DESCR]; /* must be on sizeof (rbf_t) boundary */
75 char recv_buf[MAX_RX_DESCR][MAX_RBUFF_SZ]; /* must be on long boundary */
76};
77
78struct at91_private
79{
80 struct net_device_stats stats;
81 struct mii_if_info mii; /* ethtool support */
82 struct at91_eth_data board_data; /* board-specific configuration */
83
84 /* PHY */
85 unsigned long phy_type; /* type of PHY (PHY_ID) */
86 spinlock_t lock; /* lock for MDI interface */
87 short phy_media; /* media interface type */
88 unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */
89
90 /* Transmit */
91 struct sk_buff *skb; /* holds skb until xmit interrupt completes */
92 dma_addr_t skb_physaddr; /* phys addr from pci_map_single */
93 int skb_length; /* saved skb length for pci_unmap_single */
94
95 /* Receive */
96 int rxBuffIndex; /* index into receive descriptor list */
97 struct recv_desc_bufs *dlist; /* descriptor list address */
98 struct recv_desc_bufs *dlist_phys; /* descriptor list physical address */
99};
100
101#endif
diff --git a/drivers/net/atari_bionet.c b/drivers/net/atari_bionet.c
index 0095384ff454..5e5f80b99b9e 100644
--- a/drivers/net/atari_bionet.c
+++ b/drivers/net/atari_bionet.c
@@ -123,7 +123,7 @@ static char version[] =
123 * Global variable 'bionet_debug'. Can be set at load time by 'insmod' 123 * Global variable 'bionet_debug'. Can be set at load time by 'insmod'
124 */ 124 */
125unsigned int bionet_debug = NET_DEBUG; 125unsigned int bionet_debug = NET_DEBUG;
126MODULE_PARM(bionet_debug, "i"); 126module_param(bionet_debug, int, 0);
127MODULE_PARM_DESC(bionet_debug, "bionet debug level (0-2)"); 127MODULE_PARM_DESC(bionet_debug, "bionet debug level (0-2)");
128MODULE_LICENSE("GPL"); 128MODULE_LICENSE("GPL");
129 129
diff --git a/drivers/net/atari_pamsnet.c b/drivers/net/atari_pamsnet.c
index 8b997809f9de..d6039e62d832 100644
--- a/drivers/net/atari_pamsnet.c
+++ b/drivers/net/atari_pamsnet.c
@@ -119,7 +119,7 @@ static char *version =
119 * Global variable 'pamsnet_debug'. Can be set at load time by 'insmod' 119 * Global variable 'pamsnet_debug'. Can be set at load time by 'insmod'
120 */ 120 */
121unsigned int pamsnet_debug = NET_DEBUG; 121unsigned int pamsnet_debug = NET_DEBUG;
122MODULE_PARM(pamsnet_debug, "i"); 122module_param(pamsnet_debug, int, 0);
123MODULE_PARM_DESC(pamsnet_debug, "pamsnet debug enable (0-1)"); 123MODULE_PARM_DESC(pamsnet_debug, "pamsnet debug enable (0-1)");
124MODULE_LICENSE("GPL"); 124MODULE_LICENSE("GPL");
125 125
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index e01b6a78ec63..442b2cbeb58a 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -78,7 +78,7 @@ static int lance_debug = LANCE_DEBUG;
78#else 78#else
79static int lance_debug = 1; 79static int lance_debug = 1;
80#endif 80#endif
81MODULE_PARM(lance_debug, "i"); 81module_param(lance_debug, int, 0);
82MODULE_PARM_DESC(lance_debug, "atarilance debug level (0-3)"); 82MODULE_PARM_DESC(lance_debug, "atarilance debug level (0-3)");
83MODULE_LICENSE("GPL"); 83MODULE_LICENSE("GPL");
84 84
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 8f1573e658a5..ac48f7543500 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -192,12 +192,15 @@
192static char version[] __devinitdata = 192static char version[] __devinitdata =
193 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 193 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
194 194
195static int cassini_debug = -1; /* -1 == use CAS_DEF_MSG_ENABLE as value */
196static int link_mode;
197
195MODULE_AUTHOR("Adrian Sun (asun@darksunrising.com)"); 198MODULE_AUTHOR("Adrian Sun (asun@darksunrising.com)");
196MODULE_DESCRIPTION("Sun Cassini(+) ethernet driver"); 199MODULE_DESCRIPTION("Sun Cassini(+) ethernet driver");
197MODULE_LICENSE("GPL"); 200MODULE_LICENSE("GPL");
198MODULE_PARM(cassini_debug, "i"); 201module_param(cassini_debug, int, 0);
199MODULE_PARM_DESC(cassini_debug, "Cassini bitmapped debugging message enable value"); 202MODULE_PARM_DESC(cassini_debug, "Cassini bitmapped debugging message enable value");
200MODULE_PARM(link_mode, "i"); 203module_param(link_mode, int, 0);
201MODULE_PARM_DESC(link_mode, "default link mode"); 204MODULE_PARM_DESC(link_mode, "default link mode");
202 205
203/* 206/*
@@ -209,7 +212,7 @@ MODULE_PARM_DESC(link_mode, "default link mode");
209 * Value in seconds, for user input. 212 * Value in seconds, for user input.
210 */ 213 */
211static int linkdown_timeout = DEFAULT_LINKDOWN_TIMEOUT; 214static int linkdown_timeout = DEFAULT_LINKDOWN_TIMEOUT;
212MODULE_PARM(linkdown_timeout, "i"); 215module_param(linkdown_timeout, int, 0);
213MODULE_PARM_DESC(linkdown_timeout, 216MODULE_PARM_DESC(linkdown_timeout,
214"min reset interval in sec. for PCS linkdown issue; disabled if not positive"); 217"min reset interval in sec. for PCS linkdown issue; disabled if not positive");
215 218
@@ -221,8 +224,6 @@ MODULE_PARM_DESC(linkdown_timeout,
221static int link_transition_timeout; 224static int link_transition_timeout;
222 225
223 226
224static int cassini_debug = -1; /* -1 == use CAS_DEF_MSG_ENABLE as value */
225static int link_mode;
226 227
227static u16 link_modes[] __devinitdata = { 228static u16 link_modes[] __devinitdata = {
228 BMCR_ANENABLE, /* 0 : autoneg */ 229 BMCR_ANENABLE, /* 0 : autoneg */
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 349ebe783ed6..7fe2638ae06d 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -124,7 +124,7 @@ MODULE_LICENSE("GPL");
124 124
125static int dflt_msg_enable = DFLT_MSG_ENABLE; 125static int dflt_msg_enable = DFLT_MSG_ENABLE;
126 126
127MODULE_PARM(dflt_msg_enable, "i"); 127module_param(dflt_msg_enable, int, 0);
128MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 message enable bitmap"); 128MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 message enable bitmap");
129 129
130 130
diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c
index 32d13166c6e8..e175d4876682 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-
1551static int __init dgrs_init_module (void) 1551static int __init dgrs_init_module (void)
1552{ 1552{
1553 int i; 1553 int i;
1554 int cardcount = 0; 1554 int err;
1555 1555
1556 /* 1556 /*
1557 * Command line variable overrides 1557 * Command line variable overrides
@@ -1593,13 +1593,13 @@ static int __init dgrs_init_module (void)
1593 * Find and configure all the cards 1593 * Find and configure all the cards
1594 */ 1594 */
1595#ifdef CONFIG_EISA 1595#ifdef CONFIG_EISA
1596 cardcount = eisa_driver_register(&dgrs_eisa_driver); 1596 err = eisa_driver_register(&dgrs_eisa_driver);
1597 if (cardcount < 0) 1597 if (err)
1598 return cardcount; 1598 return err;
1599#endif 1599#endif
1600 cardcount = pci_register_driver(&dgrs_pci_driver); 1600 err = pci_register_driver(&dgrs_pci_driver);
1601 if (cardcount) 1601 if (err)
1602 return cardcount; 1602 return err;
1603 return 0; 1603 return 0;
1604} 1604}
1605 1605
diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c
index b4f3a9f8a535..7e4338097139 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>");
55MODULE_DESCRIPTION("Motorola 8xx FEC ethernet driver"); 55MODULE_DESCRIPTION("Motorola 8xx FEC ethernet driver");
56MODULE_LICENSE("GPL"); 56MODULE_LICENSE("GPL");
57 57
58MODULE_PARM(fec_8xx_debug, "i"); 58int fec_8xx_debug = -1; /* -1 == use FEC_8XX_DEF_MSG_ENABLE as value */
59module_param(fec_8xx_debug, int, 0);
59MODULE_PARM_DESC(fec_8xx_debug, 60MODULE_PARM_DESC(fec_8xx_debug,
60 "FEC 8xx bitmapped debugging message enable value"); 61 "FEC 8xx bitmapped debugging message enable value");
61 62
62int fec_8xx_debug = -1; /* -1 == use FEC_8XX_DEF_MSG_ENABLE as value */
63 63
64/*************************************************/ 64/*************************************************/
65 65
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index f5d49a110654..196298f33db8 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");
58MODULE_LICENSE("GPL"); 58MODULE_LICENSE("GPL");
59MODULE_VERSION(DRV_MODULE_VERSION); 59MODULE_VERSION(DRV_MODULE_VERSION);
60 60
61MODULE_PARM(fs_enet_debug, "i"); 61int fs_enet_debug = -1; /* -1 == use FS_ENET_DEF_MSG_ENABLE as value */
62module_param(fs_enet_debug, int, 0);
62MODULE_PARM_DESC(fs_enet_debug, 63MODULE_PARM_DESC(fs_enet_debug,
63 "Freescale bitmapped debugging message enable value"); 64 "Freescale bitmapped debugging message enable value");
64 65
65int fs_enet_debug = -1; /* -1 == use FS_ENET_DEF_MSG_ENABLE as value */
66 66
67static void fs_set_multicast_list(struct net_device *dev) 67static void fs_set_multicast_list(struct net_device *dev)
68{ 68{
diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
index 5958a6314723..2d2435404614 100644
--- a/drivers/net/gt96100eth.c
+++ b/drivers/net/gt96100eth.c
@@ -114,8 +114,8 @@ static int max_interrupt_work = 32;
114 114
115static char mac0[18] = "00.02.03.04.05.06"; 115static char mac0[18] = "00.02.03.04.05.06";
116static char mac1[18] = "00.01.02.03.04.05"; 116static char mac1[18] = "00.01.02.03.04.05";
117MODULE_PARM(mac0, "c18"); 117module_param_string(mac0, mac0, 18, 0);
118MODULE_PARM(mac1, "c18"); 118module_param_string(mac1, mac0, 18, 0);
119MODULE_PARM_DESC(mac0, "MAC address for GT96100 ethernet port 0"); 119MODULE_PARM_DESC(mac0, "MAC address for GT96100 ethernet port 0");
120MODULE_PARM_DESC(mac1, "MAC address for GT96100 ethernet port 1"); 120MODULE_PARM_DESC(mac1, "MAC address for GT96100 ethernet port 1");
121 121
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index c8dc40214a08..79a8fbcf5f93 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -280,7 +280,7 @@ static unsigned long rand;
280 280
281MODULE_AUTHOR("Klaus Kudielka"); 281MODULE_AUTHOR("Klaus Kudielka");
282MODULE_DESCRIPTION("Driver for high-speed SCC boards"); 282MODULE_DESCRIPTION("Driver for high-speed SCC boards");
283MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NUM_DEVS) "i"); 283module_param_array(io, int, NULL, 0);
284MODULE_LICENSE("GPL"); 284MODULE_LICENSE("GPL");
285 285
286static void __exit dmascc_exit(void) 286static void __exit dmascc_exit(void)
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index dc5e9d59deed..d81a8e1eeb8d 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -1012,7 +1012,7 @@ static void __exit mkiss_exit_driver(void)
1012 1012
1013MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>"); 1013MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>");
1014MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs"); 1014MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs");
1015MODULE_PARM(crc_force, "i"); 1015module_param(crc_force, int, 0);
1016MODULE_PARM_DESC(crc_force, "crc [0 = auto | 1 = none | 2 = flexnet | 3 = smack]"); 1016MODULE_PARM_DESC(crc_force, "crc [0 = auto | 1 = none | 2 = flexnet | 3 = smack]");
1017MODULE_LICENSE("GPL"); 1017MODULE_LICENSE("GPL");
1018MODULE_ALIAS_LDISC(N_AX25); 1018MODULE_ALIAS_LDISC(N_AX25);
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 74e167e7dea7..0d7a6250e346 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)
250 ei_status.block_output = &hpp_mem_block_output; 250 ei_status.block_output = &hpp_mem_block_output;
251 ei_status.get_8390_hdr = &hpp_mem_get_8390_hdr; 251 ei_status.get_8390_hdr = &hpp_mem_get_8390_hdr;
252 dev->mem_start = mem_start; 252 dev->mem_start = mem_start;
253 ei_status.mem = ioremap(mem_start,
254 (HP_STOP_PG - HP_START_PG)*256);
255 if (!ei_status.mem) {
256 retval = -ENOMEM;
257 goto out;
258 }
253 ei_status.rmem_start = dev->mem_start + TX_PAGES/2*256; 259 ei_status.rmem_start = dev->mem_start + TX_PAGES/2*256;
254 dev->mem_end = ei_status.rmem_end 260 dev->mem_end = ei_status.rmem_end
255 = dev->mem_start + (HP_STOP_PG - HP_START_PG)*256; 261 = 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)
262 268
263 retval = register_netdev(dev); 269 retval = register_netdev(dev);
264 if (retval) 270 if (retval)
265 goto out; 271 goto out1;
266 return 0; 272 return 0;
273out1:
274 iounmap(ei_status.mem);
267out: 275out:
268 release_region(ioaddr, HP_IO_EXTENT); 276 release_region(ioaddr, HP_IO_EXTENT);
269 return retval; 277 return retval;
@@ -372,7 +380,7 @@ hpp_mem_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring
372 380
373 outw((ring_page<<8), ioaddr + HPP_IN_ADDR); 381 outw((ring_page<<8), ioaddr + HPP_IN_ADDR);
374 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION); 382 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
375 isa_memcpy_fromio(hdr, dev->mem_start, sizeof(struct e8390_pkt_hdr)); 383 memcpy_fromio(hdr, ei_status.mem, sizeof(struct e8390_pkt_hdr));
376 outw(option_reg, ioaddr + HPP_OPTION); 384 outw(option_reg, ioaddr + HPP_OPTION);
377 hdr->count = (le16_to_cpu(hdr->count) + 3) & ~3; /* Round up allocation. */ 385 hdr->count = (le16_to_cpu(hdr->count) + 3) & ~3; /* Round up allocation. */
378} 386}
@@ -391,7 +399,7 @@ hpp_mem_block_input(struct net_device *dev, int count, struct sk_buff *skb, int
391 Also note that we *can't* use eth_io_copy_and_sum() because 399 Also note that we *can't* use eth_io_copy_and_sum() because
392 it will not always copy "count" bytes (e.g. padded IP). */ 400 it will not always copy "count" bytes (e.g. padded IP). */
393 401
394 isa_memcpy_fromio(skb->data, dev->mem_start, count); 402 memcpy_fromio(skb->data, ei_status.mem, count);
395 outw(option_reg, ioaddr + HPP_OPTION); 403 outw(option_reg, ioaddr + HPP_OPTION);
396} 404}
397 405
@@ -416,7 +424,7 @@ hpp_mem_block_output(struct net_device *dev, int count,
416 424
417 outw(start_page << 8, ioaddr + HPP_OUT_ADDR); 425 outw(start_page << 8, ioaddr + HPP_OUT_ADDR);
418 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION); 426 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
419 isa_memcpy_toio(dev->mem_start, buf, (count + 3) & ~3); 427 memcpy_toio(ei_status.mem, buf, (count + 3) & ~3);
420 outw(option_reg, ioaddr + HPP_OPTION); 428 outw(option_reg, ioaddr + HPP_OPTION);
421 429
422 return; 430 return;
@@ -470,6 +478,7 @@ init_module(void)
470static void cleanup_card(struct net_device *dev) 478static void cleanup_card(struct net_device *dev)
471{ 479{
472 /* NB: hpp_close() handles free_irq */ 480 /* NB: hpp_close() handles free_irq */
481 iounmap(ei_status.mem);
473 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); 482 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
474} 483}
475 484
diff --git a/drivers/net/hplance.c b/drivers/net/hplance.c
index d8410634bcaf..685693464605 100644
--- a/drivers/net/hplance.c
+++ b/drivers/net/hplance.c
@@ -217,7 +217,7 @@ static int hplance_close(struct net_device *dev)
217 217
218int __init hplance_init_module(void) 218int __init hplance_init_module(void)
219{ 219{
220 return dio_module_init(&hplance_driver); 220 return dio_register_driver(&hplance_driver);
221} 221}
222 222
223void __exit hplance_cleanup_module(void) 223void __exit hplance_cleanup_module(void)
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 6e0ca7340a8f..d9fb8e74e631 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)
242 242
243static int __init hydra_init_module(void) 243static int __init hydra_init_module(void)
244{ 244{
245 return zorro_module_init(&hydra_driver); 245 return zorro_register_driver(&hydra_driver);
246} 246}
247 247
248static void __exit hydra_cleanup_module(void) 248static void __exit hydra_cleanup_module(void)
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c
index 6070195b87bd..98fa5319e5cc 100644
--- a/drivers/net/irda/irport.c
+++ b/drivers/net/irda/irport.c
@@ -1118,9 +1118,9 @@ static void __exit irport_cleanup(void)
1118 } 1118 }
1119} 1119}
1120 1120
1121MODULE_PARM(io, "1-4i"); 1121module_param_array(io, int, NULL, 0);
1122MODULE_PARM_DESC(io, "Base I/O addresses"); 1122MODULE_PARM_DESC(io, "Base I/O addresses");
1123MODULE_PARM(irq, "1-4i"); 1123module_param_array(irq, int, NULL, 0);
1124MODULE_PARM_DESC(irq, "IRQ lines"); 1124MODULE_PARM_DESC(irq, "IRQ lines");
1125 1125
1126MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); 1126MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index d1d714faa6ce..bb5ad479210b 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
464 static int did_version; /* Already printed version info. */ 464 static int did_version; /* Already printed version info. */
465 unsigned long flags; 465 unsigned long flags;
466 int err = -ENOMEM; 466 int err = -ENOMEM;
467 void __iomem *bios;
467 468
468 /* First we look for special cases. 469 /* First we look for special cases.
469 Check for HP's on-board ethernet by looking for 'HP' in the BIOS. 470 Check for HP's on-board ethernet by looking for 'HP' in the BIOS.
470 There are two HP versions, check the BIOS for the configuration port. 471 There are two HP versions, check the BIOS for the configuration port.
471 This method provided by L. Julliard, Laurent_Julliard@grenoble.hp.com. 472 This method provided by L. Julliard, Laurent_Julliard@grenoble.hp.com.
472 */ 473 */
473 if (isa_readw(0x000f0102) == 0x5048) { 474 bios = ioremap(0xf00f0, 0x14);
475 if (!bios)
476 return -ENOMEM;
477 if (readw(bios + 0x12) == 0x5048) {
474 static const short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360}; 478 static const short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360};
475 int hp_port = (isa_readl(0x000f00f1) & 1) ? 0x499 : 0x99; 479 int hp_port = (readl(bios + 1) & 1) ? 0x499 : 0x99;
476 /* We can have boards other than the built-in! Verify this is on-board. */ 480 /* We can have boards other than the built-in! Verify this is on-board. */
477 if ((inb(hp_port) & 0xc0) == 0x80 481 if ((inb(hp_port) & 0xc0) == 0x80
478 && ioaddr_table[inb(hp_port) & 3] == ioaddr) 482 && ioaddr_table[inb(hp_port) & 3] == ioaddr)
479 hp_builtin = hp_port; 483 hp_builtin = hp_port;
480 } 484 }
485 iounmap(bios);
481 /* We also recognize the HP Vectra on-board here, but check below. */ 486 /* We also recognize the HP Vectra on-board here, but check below. */
482 hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00 487 hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00
483 && inb(ioaddr+2) == 0x09); 488 && inb(ioaddr+2) == 0x09);
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index f7b7238d8352..957888de3d7e 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);
177MODULE_AUTHOR("Richard Hirst"); 177MODULE_AUTHOR("Richard Hirst");
178MODULE_DESCRIPTION("i82596 driver"); 178MODULE_DESCRIPTION("i82596 driver");
179MODULE_LICENSE("GPL"); 179MODULE_LICENSE("GPL");
180MODULE_PARM(i596_debug, "i"); 180module_param(i596_debug, int, 0);
181MODULE_PARM_DESC(i596_debug, "lasi_82596 debug mask"); 181MODULE_PARM_DESC(i596_debug, "lasi_82596 debug mask");
182 182
183/* Copy frames shorter than rx_copybreak, otherwise pass on up in 183/* Copy frames shorter than rx_copybreak, otherwise pass on up in
@@ -1520,9 +1520,9 @@ static void set_multicast_list(struct net_device *dev)
1520 } 1520 }
1521} 1521}
1522 1522
1523MODULE_PARM(debug, "i");
1524MODULE_PARM_DESC(debug, "lasi_82596 debug mask");
1525static int debug = -1; 1523static int debug = -1;
1524module_param(debug, int, 0);
1525MODULE_PARM_DESC(debug, "lasi_82596 debug mask");
1526 1526
1527static int num_drivers; 1527static int num_drivers;
1528static struct net_device *netdevs[MAX_DRIVERS]; 1528static struct net_device *netdevs[MAX_DRIVERS];
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index f65b0db111b8..cd3c9a5a98b2 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)
629static struct net_device *dev_cs89x0; 629static struct net_device *dev_cs89x0;
630static int debug; 630static int debug;
631 631
632MODULE_PARM(debug, "i"); 632module_param(debug, int, 0);
633MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)"); 633MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
634MODULE_LICENSE("GPL"); 634MODULE_LICENSE("GPL");
635 635
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 2a5add257b8f..77792b286027 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -1042,7 +1042,7 @@ static void __exit mace_cleanup(void)
1042 1042
1043MODULE_AUTHOR("Paul Mackerras"); 1043MODULE_AUTHOR("Paul Mackerras");
1044MODULE_DESCRIPTION("PowerMac MACE driver."); 1044MODULE_DESCRIPTION("PowerMac MACE driver.");
1045MODULE_PARM(port_aaui, "i"); 1045module_param(port_aaui, int, 0);
1046MODULE_PARM_DESC(port_aaui, "MACE uses AAUI port (0-1)"); 1046MODULE_PARM_DESC(port_aaui, "MACE uses AAUI port (0-1)");
1047MODULE_LICENSE("GPL"); 1047MODULE_LICENSE("GPL");
1048 1048
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index e23655f5049f..d644bf3a933c 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -62,7 +62,7 @@ MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
62 62
63#ifdef HAVE_TX_TIMEOUT 63#ifdef HAVE_TX_TIMEOUT
64static int timeout = TX_TIMEOUT; 64static int timeout = TX_TIMEOUT;
65MODULE_PARM(timeout, "i"); 65module_param(timeout, int, 0);
66#endif 66#endif
67 67
68/* 68/*
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index aaebd28a1920..7ea3d596ac3b 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -601,9 +601,9 @@ static int io[MAX_NE_CARDS];
601static int irq[MAX_NE_CARDS]; 601static int irq[MAX_NE_CARDS];
602static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */ 602static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */
603 603
604MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); 604module_param_array(io, int, NULL, 0);
605MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); 605module_param_array(irq, int, NULL, 0);
606MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); 606module_param_array(bad, int, NULL, 0);
607MODULE_PARM_DESC(io, "I/O base address(es)"); 607MODULE_PARM_DESC(io, "I/O base address(es)");
608MODULE_PARM_DESC(irq, "IRQ number(s)"); 608MODULE_PARM_DESC(irq, "IRQ number(s)");
609MODULE_DESCRIPTION("H8/300 NE2000 Ethernet driver"); 609MODULE_DESCRIPTION("H8/300 NE2000 Ethernet driver");
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index e3ebb5803b02..d11821dd86ed 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -117,7 +117,7 @@ enum ne2k_pci_chipsets {
117}; 117};
118 118
119 119
120static const struct { 120static struct {
121 char *name; 121 char *name;
122 int flags; 122 int flags;
123} pci_clone_list[] __devinitdata = { 123} pci_clone_list[] __devinitdata = {
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index 2ab01a5d1d22..a68bf474f6ed 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -766,8 +766,8 @@ static void ni5010_show_registers(struct net_device *dev)
766#ifdef MODULE 766#ifdef MODULE
767static struct net_device *dev_ni5010; 767static struct net_device *dev_ni5010;
768 768
769MODULE_PARM(io, "i"); 769module_param(io, int, 0);
770MODULE_PARM(irq, "i"); 770module_param(irq, int, 0);
771MODULE_PARM_DESC(io, "ni5010 I/O base address"); 771MODULE_PARM_DESC(io, "ni5010 I/O base address");
772MODULE_PARM_DESC(irq, "ni5010 IRQ number"); 772MODULE_PARM_DESC(irq, "ni5010 IRQ number");
773 773
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index a5f2b1ee0752..38a26df4095f 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 */
1727 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); 1727 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
1728 pTxd->pMBuf = pMessage; 1728 pTxd->pMBuf = pMessage;
1729 1729
1730 pTxd->TBControl = Control | BMU_OWN | sk_frag->size;; 1730 pTxd->TBControl = Control | BMU_OWN | sk_frag->size;
1731 1731
1732 /* 1732 /*
1733 ** Do we have the last fragment? 1733 ** Do we have the last fragment?
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 2838f661b393..62532b4e45c5 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1804,7 +1804,7 @@ struct sky2_rx_le {
1804 __le16 length; 1804 __le16 length;
1805 u8 ctrl; 1805 u8 ctrl;
1806 u8 opcode; 1806 u8 opcode;
1807} __attribute((packed));; 1807} __attribute((packed));
1808 1808
1809struct sky2_status_le { 1809struct sky2_status_le {
1810 __le32 status; /* also checksum */ 1810 __le32 status; /* also checksum */
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 01bdb2334058..d4c0002b43db 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -71,7 +71,7 @@ static int lance_debug = LANCE_DEBUG;
71#else 71#else
72static int lance_debug = 1; 72static int lance_debug = 1;
73#endif 73#endif
74MODULE_PARM(lance_debug, "i"); 74module_param(lance_debug, int, 0);
75MODULE_PARM_DESC(lance_debug, "SUN3 Lance debug level (0-3)"); 75MODULE_PARM_DESC(lance_debug, "SUN3 Lance debug level (0-3)");
76MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
77 77
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 6a1033ec06cf..fd17aa8491b6 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -27,6 +27,7 @@ config NET_RADIO
27 27
28config NET_WIRELESS_RTNETLINK 28config NET_WIRELESS_RTNETLINK
29 bool "Wireless Extension API over RtNetlink" 29 bool "Wireless Extension API over RtNetlink"
30 depends on NET_RADIO
30 ---help--- 31 ---help---
31 Support the Wireless Extension API over the RtNetlink socket 32 Support the Wireless Extension API over the RtNetlink socket
32 in addition to the traditional ioctl interface (selected above). 33 in addition to the traditional ioctl interface (selected above).
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index eea2f04c8c6d..ebb238785839 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)
332 case OID_TYPE_ATTACH:{ 332 case OID_TYPE_ATTACH:{
333 struct obj_attachment *attach = data; 333 struct obj_attachment *attach = data;
334 attach->id = le16_to_cpu(attach->id); 334 attach->id = le16_to_cpu(attach->id);
335 attach->size = le16_to_cpu(attach->size);; 335 attach->size = le16_to_cpu(attach->size);
336 break; 336 break;
337 } 337 }
338 case OID_TYPE_SSID: 338 case OID_TYPE_SSID:
@@ -401,7 +401,7 @@ mgt_cpu_to_le(int type, void *data)
401 case OID_TYPE_ATTACH:{ 401 case OID_TYPE_ATTACH:{
402 struct obj_attachment *attach = data; 402 struct obj_attachment *attach = data;
403 attach->id = cpu_to_le16(attach->id); 403 attach->id = cpu_to_le16(attach->id);
404 attach->size = cpu_to_le16(attach->size);; 404 attach->size = cpu_to_le16(attach->size);
405 break; 405 break;
406 } 406 }
407 case OID_TYPE_SSID: 407 case OID_TYPE_SSID:
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index fee4be1ce810..5fa6fbe35bb9 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -147,7 +147,7 @@ struct pdi {
147 __le16 _len; /* length of ID and data, in words */ 147 __le16 _len; /* length of ID and data, in words */
148 __le16 _id; /* record ID */ 148 __le16 _id; /* record ID */
149 char data[0]; /* plug data */ 149 char data[0]; /* plug data */
150} __attribute__ ((packed));; 150} __attribute__ ((packed));
151 151
152 152
153/* Functions for access to little-endian data */ 153/* Functions for access to little-endian data */
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index 761021603597..8037e5806d0a 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)
426 426
427static int __init zorro8390_init_module(void) 427static int __init zorro8390_init_module(void)
428{ 428{
429 return zorro_module_init(&zorro8390_driver); 429 return zorro_register_driver(&zorro8390_driver);
430} 430}
431 431
432static void __exit zorro8390_cleanup_module(void) 432static void __exit zorro8390_cleanup_module(void)
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 5d47c5965c51..0821747e44cf 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,
1724 sba_dev->chip_resv.start = PCI_F_EXTEND | 0xfef00000UL; 1724 sba_dev->chip_resv.start = PCI_F_EXTEND | 0xfef00000UL;
1725 sba_dev->chip_resv.end = PCI_F_EXTEND | (0xff000000UL - 1) ; 1725 sba_dev->chip_resv.end = PCI_F_EXTEND | (0xff000000UL - 1) ;
1726 err = request_resource(&iomem_resource, &(sba_dev->chip_resv)); 1726 err = request_resource(&iomem_resource, &(sba_dev->chip_resv));
1727 if (err < 0) { 1727 BUG_ON(err < 0);
1728 BUG();
1729 }
1730 1728
1731 } else if (IS_PLUTO(sba_dev->iodc)) { 1729 } else if (IS_PLUTO(sba_dev->iodc)) {
1732 int err; 1730 int err;
@@ -2185,8 +2183,7 @@ void sba_directed_lmmio(struct parisc_device *pci_hba, struct resource *r)
2185 int i; 2183 int i;
2186 int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */ 2184 int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */
2187 2185
2188 if ((t!=HPHW_IOA) && (t!=HPHW_BCPORT)) 2186 BUG_ON((t!=HPHW_IOA) && (t!=HPHW_BCPORT));
2189 BUG();
2190 2187
2191 r->start = r->end = 0; 2188 r->start = r->end = 0;
2192 2189
@@ -2228,8 +2225,7 @@ void sba_distributed_lmmio(struct parisc_device *pci_hba, struct resource *r )
2228 int base, size; 2225 int base, size;
2229 int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */ 2226 int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */
2230 2227
2231 if ((t!=HPHW_IOA) && (t!=HPHW_BCPORT)) 2228 BUG_ON((t!=HPHW_IOA) && (t!=HPHW_BCPORT));
2232 BUG();
2233 2229
2234 r->start = r->end = 0; 2230 r->start = r->end = 0;
2235 2231
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index ba971fecd0d8..ad6d3b28a3a6 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -157,8 +157,8 @@ superio_init(struct pci_dev *pcidev)
157 if (sio->suckyio_irq_enabled) 157 if (sio->suckyio_irq_enabled)
158 return; 158 return;
159 159
160 if (!pdev) BUG(); 160 BUG_ON(!pdev);
161 if (!sio->usb_pdev) BUG(); 161 BUG_ON(!sio->usb_pdev);
162 162
163 /* use the IRQ iosapic found for USB INT D... */ 163 /* use the IRQ iosapic found for USB INT D... */
164 pdev->irq = sio->usb_pdev->irq; 164 pdev->irq = sio->usb_pdev->irq;
@@ -474,8 +474,7 @@ superio_probe(struct pci_dev *dev, const struct pci_device_id *id)
474 dev->subsystem_vendor, dev->subsystem_device, 474 dev->subsystem_vendor, dev->subsystem_device,
475 dev->class); 475 dev->class);
476 476
477 if (!sio->suckyio_irq_enabled) 477 BUG_ON(!sio->suckyio_irq_enabled); /* Enabled by PCI_FIXUP_FINAL */
478 BUG(); /* Enabled by PCI_FIXUP_FINAL */
479 478
480 if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */ 479 if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */
481 superio_parport_init(); 480 superio_parport_init();
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 57fd60314d59..b1b4b683cbdd 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,
646 size = 0; 646 size = 0;
647 skip = 0; 647 skip = 0;
648 option = pnp_register_independent_option(dev); 648 option = pnp_register_independent_option(dev);
649 if (!option) 649 if (!option) {
650 kfree(dev);
650 return 1; 651 return 1;
652 }
651 pnp_add_card_device(card,dev); 653 pnp_add_card_device(card,dev);
652 } else { 654 } else {
653 skip = 1; 655 skip = 1;
diff --git a/drivers/s390/Kconfig b/drivers/s390/Kconfig
index 721787cc5a1c..4d36208ff8de 100644
--- a/drivers/s390/Kconfig
+++ b/drivers/s390/Kconfig
@@ -183,7 +183,13 @@ config S390_TAPE_34XX
183 tape subsystems and 100% compatibles. 183 tape subsystems and 100% compatibles.
184 It is safe to say "Y" here. 184 It is safe to say "Y" here.
185 185
186 186config S390_TAPE_3590
187 tristate "Support for 3590 tape hardware"
188 depends on S390_TAPE
189 help
190 Select this option if you want to access IBM 3590 magnetic
191 tape subsystems and 100% compatibles.
192 It is safe to say "Y" here.
187 193
188config VMLOGRDR 194config VMLOGRDR
189 tristate "Support for the z/VM recording system services (VM only)" 195 tristate "Support for the z/VM recording system services (VM only)"
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig
index 6f50cc9323d9..929d6fff6152 100644
--- a/drivers/s390/block/Kconfig
+++ b/drivers/s390/block/Kconfig
@@ -49,20 +49,18 @@ config DASD_FBA
49 49
50config DASD_DIAG 50config DASD_DIAG
51 tristate "Support for DIAG access to Disks" 51 tristate "Support for DIAG access to Disks"
52 depends on DASD && ( 64BIT = 'n' || EXPERIMENTAL) 52 depends on DASD
53 help 53 help
54 Select this option if you want to use Diagnose250 command to access 54 Select this option if you want to use Diagnose250 command to access
55 Disks under VM. If you are not running under VM or unsure what it is, 55 Disks under VM. If you are not running under VM or unsure what it is,
56 say "N". 56 say "N".
57 57
58config DASD_CMB 58config DASD_EER
59 tristate "Compatibility interface for DASD channel measurement blocks" 59 bool "Extended error reporting (EER)"
60 depends on DASD 60 depends on DASD
61 help 61 help
62 This driver provides an additional interface to the channel measurement 62 This driver provides a character device interface to the
63 facility, which is normally accessed though sysfs, with a set of 63 DASD extended error reporting. This is only needed if you want to
64 ioctl functions specific to the dasd driver. 64 use applications written for the EER facility.
65 This is only needed if you want to use applications written for
66 linux-2.4 dasd channel measurement facility interface.
67 65
68endif 66endif
diff --git a/drivers/s390/block/Makefile b/drivers/s390/block/Makefile
index 58c6780134f7..be9f22d52fd8 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
7dasd_diag_mod-objs := dasd_diag.o 7dasd_diag_mod-objs := dasd_diag.o
8dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \ 8dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \
9 dasd_genhd.o dasd_erp.o 9 dasd_genhd.o dasd_erp.o
10ifdef CONFIG_DASD_EER
11dasd_mod-objs += dasd_eer.o
12endif
10 13
11obj-$(CONFIG_DASD) += dasd_mod.o 14obj-$(CONFIG_DASD) += dasd_mod.o
12obj-$(CONFIG_DASD_DIAG) += dasd_diag_mod.o 15obj-$(CONFIG_DASD_DIAG) += dasd_diag_mod.o
13obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o 16obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o
14obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o 17obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o
15obj-$(CONFIG_DASD_CMB) += dasd_cmb.o
16obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o 18obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o
17obj-$(CONFIG_DCSSBLK) += dcssblk.o 19obj-$(CONFIG_DCSSBLK) += dcssblk.o
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 33157c84d1d3..0a9f12c4e911 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>");
43MODULE_DESCRIPTION("Linux on S/390 DASD device driver," 43MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
44 " Copyright 2000 IBM Corporation"); 44 " Copyright 2000 IBM Corporation");
45MODULE_SUPPORTED_DEVICE("dasd"); 45MODULE_SUPPORTED_DEVICE("dasd");
46MODULE_PARM(dasd, "1-" __MODULE_STRING(256) "s");
47MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
48 47
49/* 48/*
@@ -71,10 +70,9 @@ dasd_alloc_device(void)
71{ 70{
72 struct dasd_device *device; 71 struct dasd_device *device;
73 72
74 device = kmalloc(sizeof (struct dasd_device), GFP_ATOMIC); 73 device = kzalloc(sizeof (struct dasd_device), GFP_ATOMIC);
75 if (device == NULL) 74 if (device == NULL)
76 return ERR_PTR(-ENOMEM); 75 return ERR_PTR(-ENOMEM);
77 memset(device, 0, sizeof (struct dasd_device));
78 /* open_count = 0 means device online but not in use */ 76 /* open_count = 0 means device online but not in use */
79 atomic_set(&device->open_count, -1); 77 atomic_set(&device->open_count, -1);
80 78
@@ -151,6 +149,8 @@ dasd_state_new_to_known(struct dasd_device *device)
151static inline void 149static inline void
152dasd_state_known_to_new(struct dasd_device * device) 150dasd_state_known_to_new(struct dasd_device * device)
153{ 151{
152 /* Disable extended error reporting for this device. */
153 dasd_eer_disable(device);
154 /* Forget the discipline information. */ 154 /* Forget the discipline information. */
155 if (device->discipline) 155 if (device->discipline)
156 module_put(device->discipline->owner); 156 module_put(device->discipline->owner);
@@ -541,33 +541,29 @@ dasd_kmalloc_request(char *magic, int cplength, int datasize,
541 struct dasd_ccw_req *cqr; 541 struct dasd_ccw_req *cqr;
542 542
543 /* Sanity checks */ 543 /* Sanity checks */
544 if ( magic == NULL || datasize > PAGE_SIZE || 544 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
545 (cplength*sizeof(struct ccw1)) > PAGE_SIZE) 545 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
546 BUG();
547 546
548 cqr = kmalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC); 547 cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
549 if (cqr == NULL) 548 if (cqr == NULL)
550 return ERR_PTR(-ENOMEM); 549 return ERR_PTR(-ENOMEM);
551 memset(cqr, 0, sizeof(struct dasd_ccw_req));
552 cqr->cpaddr = NULL; 550 cqr->cpaddr = NULL;
553 if (cplength > 0) { 551 if (cplength > 0) {
554 cqr->cpaddr = kmalloc(cplength*sizeof(struct ccw1), 552 cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
555 GFP_ATOMIC | GFP_DMA); 553 GFP_ATOMIC | GFP_DMA);
556 if (cqr->cpaddr == NULL) { 554 if (cqr->cpaddr == NULL) {
557 kfree(cqr); 555 kfree(cqr);
558 return ERR_PTR(-ENOMEM); 556 return ERR_PTR(-ENOMEM);
559 } 557 }
560 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
561 } 558 }
562 cqr->data = NULL; 559 cqr->data = NULL;
563 if (datasize > 0) { 560 if (datasize > 0) {
564 cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA); 561 cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
565 if (cqr->data == NULL) { 562 if (cqr->data == NULL) {
566 kfree(cqr->cpaddr); 563 kfree(cqr->cpaddr);
567 kfree(cqr); 564 kfree(cqr);
568 return ERR_PTR(-ENOMEM); 565 return ERR_PTR(-ENOMEM);
569 } 566 }
570 memset(cqr->data, 0, datasize);
571 } 567 }
572 strncpy((char *) &cqr->magic, magic, 4); 568 strncpy((char *) &cqr->magic, magic, 4);
573 ASCEBC((char *) &cqr->magic, 4); 569 ASCEBC((char *) &cqr->magic, 4);
@@ -586,9 +582,8 @@ dasd_smalloc_request(char *magic, int cplength, int datasize,
586 int size; 582 int size;
587 583
588 /* Sanity checks */ 584 /* Sanity checks */
589 if ( magic == NULL || datasize > PAGE_SIZE || 585 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
590 (cplength*sizeof(struct ccw1)) > PAGE_SIZE) 586 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
591 BUG();
592 587
593 size = (sizeof(struct dasd_ccw_req) + 7L) & -8L; 588 size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
594 if (cplength > 0) 589 if (cplength > 0)
@@ -892,6 +887,9 @@ dasd_handle_state_change_pending(struct dasd_device *device)
892 struct dasd_ccw_req *cqr; 887 struct dasd_ccw_req *cqr;
893 struct list_head *l, *n; 888 struct list_head *l, *n;
894 889
890 /* First of all start sense subsystem status request. */
891 dasd_eer_snss(device);
892
895 device->stopped &= ~DASD_STOPPED_PENDING; 893 device->stopped &= ~DASD_STOPPED_PENDING;
896 894
897 /* restart all 'running' IO on queue */ 895 /* restart all 'running' IO on queue */
@@ -1111,6 +1109,19 @@ restart:
1111 } 1109 }
1112 goto restart; 1110 goto restart;
1113 } 1111 }
1112
1113 /* First of all call extended error reporting. */
1114 if (dasd_eer_enabled(device) &&
1115 cqr->status == DASD_CQR_FAILED) {
1116 dasd_eer_write(device, cqr, DASD_EER_FATALERROR);
1117
1118 /* restart request */
1119 cqr->status = DASD_CQR_QUEUED;
1120 cqr->retries = 255;
1121 device->stopped |= DASD_STOPPED_QUIESCE;
1122 goto restart;
1123 }
1124
1114 /* Process finished ERP request. */ 1125 /* Process finished ERP request. */
1115 if (cqr->refers) { 1126 if (cqr->refers) {
1116 __dasd_process_erp(device, cqr); 1127 __dasd_process_erp(device, cqr);
@@ -1248,7 +1259,8 @@ __dasd_start_head(struct dasd_device * device)
1248 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); 1259 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1249 /* check FAILFAST */ 1260 /* check FAILFAST */
1250 if (device->stopped & ~DASD_STOPPED_PENDING && 1261 if (device->stopped & ~DASD_STOPPED_PENDING &&
1251 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) { 1262 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
1263 (!dasd_eer_enabled(device))) {
1252 cqr->status = DASD_CQR_FAILED; 1264 cqr->status = DASD_CQR_FAILED;
1253 dasd_schedule_bh(device); 1265 dasd_schedule_bh(device);
1254 } 1266 }
@@ -1807,7 +1819,7 @@ dasd_exit(void)
1807#ifdef CONFIG_PROC_FS 1819#ifdef CONFIG_PROC_FS
1808 dasd_proc_exit(); 1820 dasd_proc_exit();
1809#endif 1821#endif
1810 dasd_ioctl_exit(); 1822 dasd_eer_exit();
1811 if (dasd_page_cache != NULL) { 1823 if (dasd_page_cache != NULL) {
1812 kmem_cache_destroy(dasd_page_cache); 1824 kmem_cache_destroy(dasd_page_cache);
1813 dasd_page_cache = NULL; 1825 dasd_page_cache = NULL;
@@ -2004,6 +2016,9 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
2004 switch (event) { 2016 switch (event) {
2005 case CIO_GONE: 2017 case CIO_GONE:
2006 case CIO_NO_PATH: 2018 case CIO_NO_PATH:
2019 /* First of all call extended error reporting. */
2020 dasd_eer_write(device, NULL, DASD_EER_NOPATH);
2021
2007 if (device->state < DASD_STATE_BASIC) 2022 if (device->state < DASD_STATE_BASIC)
2008 break; 2023 break;
2009 /* Device is active. We want to keep it. */ 2024 /* Device is active. We want to keep it. */
@@ -2061,6 +2076,7 @@ dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
2061 put_driver(drv); 2076 put_driver(drv);
2062} 2077}
2063 2078
2079
2064static int __init 2080static int __init
2065dasd_init(void) 2081dasd_init(void)
2066{ 2082{
@@ -2093,7 +2109,7 @@ dasd_init(void)
2093 rc = dasd_parse(); 2109 rc = dasd_parse();
2094 if (rc) 2110 if (rc)
2095 goto failed; 2111 goto failed;
2096 rc = dasd_ioctl_init(); 2112 rc = dasd_eer_init();
2097 if (rc) 2113 if (rc)
2098 goto failed; 2114 goto failed;
2099#ifdef CONFIG_PROC_FS 2115#ifdef CONFIG_PROC_FS
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index 4ee0f934e325..2ed51562319e 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)
1108 case 0x0B: 1108 case 0x0B:
1109 DEV_MESSAGE(KERN_WARNING, device, "%s", 1109 DEV_MESSAGE(KERN_WARNING, device, "%s",
1110 "FORMAT F - Volume is suspended duplex"); 1110 "FORMAT F - Volume is suspended duplex");
1111 /* call extended error reporting (EER) */
1112 dasd_eer_write(device, erp->refers,
1113 DASD_EER_PPRCSUSPEND);
1111 break; 1114 break;
1112 case 0x0C: 1115 case 0x0C:
1113 DEV_MESSAGE(KERN_WARNING, device, "%s", 1116 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 e88f73ee72ce..000000000000
--- a/drivers/s390/block/dasd_cmb.c
+++ /dev/null
@@ -1,128 +0,0 @@
1/*
2 * Linux on zSeries Channel Measurement Facility support
3 * (dasd device driver interface)
4 *
5 * Copyright 2000,2003 IBM Corporation
6 *
7 * Author: Arnd Bergmann <arndb@de.ibm.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23#include <linux/init.h>
24#include <linux/module.h>
25#include <asm/ccwdev.h>
26#include <asm/cmb.h>
27
28#include "dasd_int.h"
29
30static int
31dasd_ioctl_cmf_enable(struct block_device *bdev, int no, long args)
32{
33 struct dasd_device *device;
34
35 device = bdev->bd_disk->private_data;
36 if (!device)
37 return -EINVAL;
38
39 return enable_cmf(device->cdev);
40}
41
42static int
43dasd_ioctl_cmf_disable(struct block_device *bdev, int no, long args)
44{
45 struct dasd_device *device;
46
47 device = bdev->bd_disk->private_data;
48 if (!device)
49 return -EINVAL;
50
51 return disable_cmf(device->cdev);
52}
53
54static int
55dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
56{
57 struct dasd_device *device;
58 struct cmbdata __user *udata;
59 struct cmbdata data;
60 size_t size;
61 int ret;
62
63 device = bdev->bd_disk->private_data;
64 if (!device)
65 return -EINVAL;
66 udata = (void __user *) args;
67 size = _IOC_SIZE(no);
68
69 if (!access_ok(VERIFY_WRITE, udata, size))
70 return -EFAULT;
71 ret = cmf_readall(device->cdev, &data);
72 if (ret)
73 return ret;
74 if (copy_to_user(udata, &data, min(size, sizeof(*udata))))
75 return -EFAULT;
76 return 0;
77}
78
79/* module initialization below here. dasd already provides a mechanism
80 * to dynamically register ioctl functions, so we simply use this. */
81static inline int
82ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
83{
84 return dasd_ioctl_no_register(THIS_MODULE, no, handler);
85}
86
87static inline void
88ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
89{
90 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
91}
92
93static void
94dasd_cmf_exit(void)
95{
96 ioctl_unreg(BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
97 ioctl_unreg(BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
98 ioctl_unreg(BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
99}
100
101static int __init
102dasd_cmf_init(void)
103{
104 int ret;
105 ret = ioctl_reg (BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
106 if (ret)
107 goto err;
108 ret = ioctl_reg (BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
109 if (ret)
110 goto err;
111 ret = ioctl_reg (BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
112 if (ret)
113 goto err;
114
115 return 0;
116err:
117 dasd_cmf_exit();
118
119 return ret;
120}
121
122module_init(dasd_cmf_init);
123module_exit(dasd_cmf_exit);
124
125MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
126MODULE_LICENSE("GPL");
127MODULE_DESCRIPTION("channel measurement facility interface for dasd\n"
128 "Copyright 2003 IBM Corporation\n");
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 1629b27c48ab..2f720108a7e0 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -16,6 +16,7 @@
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/ctype.h> 17#include <linux/ctype.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h>
19 20
20#include <asm/debug.h> 21#include <asm/debug.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
@@ -69,6 +70,8 @@ int dasd_autodetect = 0; /* is true, when autodetection is active */
69 * strings when running as a module. 70 * strings when running as a module.
70 */ 71 */
71static char *dasd[256]; 72static char *dasd[256];
73module_param_array(dasd, charp, NULL, 0);
74
72/* 75/*
73 * Single spinlock to protect devmap structures and lists. 76 * Single spinlock to protect devmap structures and lists.
74 */ 77 */
@@ -715,10 +718,51 @@ dasd_discipline_show(struct device *dev, struct device_attribute *attr, char *bu
715 718
716static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL); 719static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
717 720
721/*
722 * extended error-reporting
723 */
724static ssize_t
725dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
726{
727 struct dasd_devmap *devmap;
728 int eer_flag;
729
730 devmap = dasd_find_busid(dev->bus_id);
731 if (!IS_ERR(devmap) && devmap->device)
732 eer_flag = dasd_eer_enabled(devmap->device);
733 else
734 eer_flag = 0;
735 return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
736}
737
738static ssize_t
739dasd_eer_store(struct device *dev, struct device_attribute *attr,
740 const char *buf, size_t count)
741{
742 struct dasd_devmap *devmap;
743 int rc;
744
745 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
746 if (IS_ERR(devmap))
747 return PTR_ERR(devmap);
748 if (!devmap->device)
749 return count;
750 if (buf[0] == '1') {
751 rc = dasd_eer_enable(devmap->device);
752 if (rc)
753 return rc;
754 } else
755 dasd_eer_disable(devmap->device);
756 return count;
757}
758
759static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
760
718static struct attribute * dasd_attrs[] = { 761static struct attribute * dasd_attrs[] = {
719 &dev_attr_readonly.attr, 762 &dev_attr_readonly.attr,
720 &dev_attr_discipline.attr, 763 &dev_attr_discipline.attr,
721 &dev_attr_use_diag.attr, 764 &dev_attr_use_diag.attr,
765 &dev_attr_eer_enabled.attr,
722 NULL, 766 NULL,
723}; 767};
724 768
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 822e2a265578..ee09ef33d08d 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,
1227 * (see dasd_eckd_reserve) device. 1227 * (see dasd_eckd_reserve) device.
1228 */ 1228 */
1229static int 1229static int
1230dasd_eckd_release(struct block_device *bdev, int no, long args) 1230dasd_eckd_release(struct dasd_device *device)
1231{ 1231{
1232 struct dasd_device *device;
1233 struct dasd_ccw_req *cqr; 1232 struct dasd_ccw_req *cqr;
1234 int rc; 1233 int rc;
1235 1234
1236 if (!capable(CAP_SYS_ADMIN)) 1235 if (!capable(CAP_SYS_ADMIN))
1237 return -EACCES; 1236 return -EACCES;
1238 1237
1239 device = bdev->bd_disk->private_data;
1240 if (device == NULL)
1241 return -ENODEV;
1242
1243 cqr = dasd_smalloc_request(dasd_eckd_discipline.name, 1238 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1244 1, 32, device); 1239 1, 32, device);
1245 if (IS_ERR(cqr)) { 1240 if (IS_ERR(cqr)) {
@@ -1272,19 +1267,14 @@ dasd_eckd_release(struct block_device *bdev, int no, long args)
1272 * the interrupt is outstanding for a certain time. 1267 * the interrupt is outstanding for a certain time.
1273 */ 1268 */
1274static int 1269static int
1275dasd_eckd_reserve(struct block_device *bdev, int no, long args) 1270dasd_eckd_reserve(struct dasd_device *device)
1276{ 1271{
1277 struct dasd_device *device;
1278 struct dasd_ccw_req *cqr; 1272 struct dasd_ccw_req *cqr;
1279 int rc; 1273 int rc;
1280 1274
1281 if (!capable(CAP_SYS_ADMIN)) 1275 if (!capable(CAP_SYS_ADMIN))
1282 return -EACCES; 1276 return -EACCES;
1283 1277
1284 device = bdev->bd_disk->private_data;
1285 if (device == NULL)
1286 return -ENODEV;
1287
1288 cqr = dasd_smalloc_request(dasd_eckd_discipline.name, 1278 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1289 1, 32, device); 1279 1, 32, device);
1290 if (IS_ERR(cqr)) { 1280 if (IS_ERR(cqr)) {
@@ -1316,19 +1306,14 @@ dasd_eckd_reserve(struct block_device *bdev, int no, long args)
1316 * (unconditional reserve) 1306 * (unconditional reserve)
1317 */ 1307 */
1318static int 1308static int
1319dasd_eckd_steal_lock(struct block_device *bdev, int no, long args) 1309dasd_eckd_steal_lock(struct dasd_device *device)
1320{ 1310{
1321 struct dasd_device *device;
1322 struct dasd_ccw_req *cqr; 1311 struct dasd_ccw_req *cqr;
1323 int rc; 1312 int rc;
1324 1313
1325 if (!capable(CAP_SYS_ADMIN)) 1314 if (!capable(CAP_SYS_ADMIN))
1326 return -EACCES; 1315 return -EACCES;
1327 1316
1328 device = bdev->bd_disk->private_data;
1329 if (device == NULL)
1330 return -ENODEV;
1331
1332 cqr = dasd_smalloc_request(dasd_eckd_discipline.name, 1317 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1333 1, 32, device); 1318 1, 32, device);
1334 if (IS_ERR(cqr)) { 1319 if (IS_ERR(cqr)) {
@@ -1358,19 +1343,14 @@ dasd_eckd_steal_lock(struct block_device *bdev, int no, long args)
1358 * Read performance statistics 1343 * Read performance statistics
1359 */ 1344 */
1360static int 1345static int
1361dasd_eckd_performance(struct block_device *bdev, int no, long args) 1346dasd_eckd_performance(struct dasd_device *device, void __user *argp)
1362{ 1347{
1363 struct dasd_device *device;
1364 struct dasd_psf_prssd_data *prssdp; 1348 struct dasd_psf_prssd_data *prssdp;
1365 struct dasd_rssd_perf_stats_t *stats; 1349 struct dasd_rssd_perf_stats_t *stats;
1366 struct dasd_ccw_req *cqr; 1350 struct dasd_ccw_req *cqr;
1367 struct ccw1 *ccw; 1351 struct ccw1 *ccw;
1368 int rc; 1352 int rc;
1369 1353
1370 device = bdev->bd_disk->private_data;
1371 if (device == NULL)
1372 return -ENODEV;
1373
1374 cqr = dasd_smalloc_request(dasd_eckd_discipline.name, 1354 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1375 1 /* PSF */ + 1 /* RSSD */ , 1355 1 /* PSF */ + 1 /* RSSD */ ,
1376 (sizeof (struct dasd_psf_prssd_data) + 1356 (sizeof (struct dasd_psf_prssd_data) +
@@ -1414,8 +1394,9 @@ dasd_eckd_performance(struct block_device *bdev, int no, long args)
1414 /* Prepare for Read Subsystem Data */ 1394 /* Prepare for Read Subsystem Data */
1415 prssdp = (struct dasd_psf_prssd_data *) cqr->data; 1395 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
1416 stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1); 1396 stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1);
1417 rc = copy_to_user((long __user *) args, (long *) stats, 1397 if (copy_to_user(argp, stats,
1418 sizeof(struct dasd_rssd_perf_stats_t)); 1398 sizeof(struct dasd_rssd_perf_stats_t)))
1399 rc = -EFAULT;
1419 } 1400 }
1420 dasd_sfree_request(cqr, cqr->device); 1401 dasd_sfree_request(cqr, cqr->device);
1421 return rc; 1402 return rc;
@@ -1426,27 +1407,22 @@ dasd_eckd_performance(struct block_device *bdev, int no, long args)
1426 * Returnes the cache attributes used in Define Extend (DE). 1407 * Returnes the cache attributes used in Define Extend (DE).
1427 */ 1408 */
1428static int 1409static int
1429dasd_eckd_get_attrib (struct block_device *bdev, int no, long args) 1410dasd_eckd_get_attrib(struct dasd_device *device, void __user *argp)
1430{ 1411{
1431 struct dasd_device *device; 1412 struct dasd_eckd_private *private =
1432 struct dasd_eckd_private *private; 1413 (struct dasd_eckd_private *)device->private;
1433 struct attrib_data_t attrib; 1414 struct attrib_data_t attrib = private->attrib;
1434 int rc; 1415 int rc;
1435 1416
1436 if (!capable(CAP_SYS_ADMIN)) 1417 if (!capable(CAP_SYS_ADMIN))
1437 return -EACCES; 1418 return -EACCES;
1438 if (!args) 1419 if (!argp)
1439 return -EINVAL; 1420 return -EINVAL;
1440 1421
1441 device = bdev->bd_disk->private_data; 1422 rc = 0;
1442 if (device == NULL) 1423 if (copy_to_user(argp, (long *) &attrib,
1443 return -ENODEV; 1424 sizeof (struct attrib_data_t)))
1444 1425 rc = -EFAULT;
1445 private = (struct dasd_eckd_private *) device->private;
1446 attrib = private->attrib;
1447
1448 rc = copy_to_user((long __user *) args, (long *) &attrib,
1449 sizeof (struct attrib_data_t));
1450 1426
1451 return rc; 1427 return rc;
1452} 1428}
@@ -1456,26 +1432,19 @@ dasd_eckd_get_attrib (struct block_device *bdev, int no, long args)
1456 * Stores the attributes for cache operation to be used in Define Extend (DE). 1432 * Stores the attributes for cache operation to be used in Define Extend (DE).
1457 */ 1433 */
1458static int 1434static int
1459dasd_eckd_set_attrib(struct block_device *bdev, int no, long args) 1435dasd_eckd_set_attrib(struct dasd_device *device, void __user *argp)
1460{ 1436{
1461 struct dasd_device *device; 1437 struct dasd_eckd_private *private =
1462 struct dasd_eckd_private *private; 1438 (struct dasd_eckd_private *)device->private;
1463 struct attrib_data_t attrib; 1439 struct attrib_data_t attrib;
1464 1440
1465 if (!capable(CAP_SYS_ADMIN)) 1441 if (!capable(CAP_SYS_ADMIN))
1466 return -EACCES; 1442 return -EACCES;
1467 if (!args) 1443 if (!argp)
1468 return -EINVAL; 1444 return -EINVAL;
1469 1445
1470 device = bdev->bd_disk->private_data; 1446 if (copy_from_user(&attrib, argp, sizeof(struct attrib_data_t)))
1471 if (device == NULL)
1472 return -ENODEV;
1473
1474 if (copy_from_user(&attrib, (void __user *) args,
1475 sizeof (struct attrib_data_t))) {
1476 return -EFAULT; 1447 return -EFAULT;
1477 }
1478 private = (struct dasd_eckd_private *) device->private;
1479 private->attrib = attrib; 1448 private->attrib = attrib;
1480 1449
1481 DEV_MESSAGE(KERN_INFO, device, 1450 DEV_MESSAGE(KERN_INFO, device,
@@ -1484,6 +1453,27 @@ dasd_eckd_set_attrib(struct block_device *bdev, int no, long args)
1484 return 0; 1453 return 0;
1485} 1454}
1486 1455
1456static int
1457dasd_eckd_ioctl(struct dasd_device *device, unsigned int cmd, void __user *argp)
1458{
1459 switch (cmd) {
1460 case BIODASDGATTR:
1461 return dasd_eckd_get_attrib(device, argp);
1462 case BIODASDSATTR:
1463 return dasd_eckd_set_attrib(device, argp);
1464 case BIODASDPSRD:
1465 return dasd_eckd_performance(device, argp);
1466 case BIODASDRLSE:
1467 return dasd_eckd_release(device);
1468 case BIODASDRSRV:
1469 return dasd_eckd_reserve(device);
1470 case BIODASDSLCK:
1471 return dasd_eckd_steal_lock(device);
1472 default:
1473 return -ENOIOCTLCMD;
1474 }
1475}
1476
1487/* 1477/*
1488 * Print sense data and related channel program. 1478 * Print sense data and related channel program.
1489 * Parts are printed because printk buffer is only 1024 bytes. 1479 * Parts are printed because printk buffer is only 1024 bytes.
@@ -1642,6 +1632,7 @@ static struct dasd_discipline dasd_eckd_discipline = {
1642 .free_cp = dasd_eckd_free_cp, 1632 .free_cp = dasd_eckd_free_cp,
1643 .dump_sense = dasd_eckd_dump_sense, 1633 .dump_sense = dasd_eckd_dump_sense,
1644 .fill_info = dasd_eckd_fill_info, 1634 .fill_info = dasd_eckd_fill_info,
1635 .ioctl = dasd_eckd_ioctl,
1645}; 1636};
1646 1637
1647static int __init 1638static int __init
@@ -1649,59 +1640,18 @@ dasd_eckd_init(void)
1649{ 1640{
1650 int ret; 1641 int ret;
1651 1642
1652 dasd_ioctl_no_register(THIS_MODULE, BIODASDGATTR,
1653 dasd_eckd_get_attrib);
1654 dasd_ioctl_no_register(THIS_MODULE, BIODASDSATTR,
1655 dasd_eckd_set_attrib);
1656 dasd_ioctl_no_register(THIS_MODULE, BIODASDPSRD,
1657 dasd_eckd_performance);
1658 dasd_ioctl_no_register(THIS_MODULE, BIODASDRLSE,
1659 dasd_eckd_release);
1660 dasd_ioctl_no_register(THIS_MODULE, BIODASDRSRV,
1661 dasd_eckd_reserve);
1662 dasd_ioctl_no_register(THIS_MODULE, BIODASDSLCK,
1663 dasd_eckd_steal_lock);
1664
1665 ASCEBC(dasd_eckd_discipline.ebcname, 4); 1643 ASCEBC(dasd_eckd_discipline.ebcname, 4);
1666 1644
1667 ret = ccw_driver_register(&dasd_eckd_driver); 1645 ret = ccw_driver_register(&dasd_eckd_driver);
1668 if (ret) { 1646 if (!ret)
1669 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDGATTR, 1647 dasd_generic_auto_online(&dasd_eckd_driver);
1670 dasd_eckd_get_attrib); 1648 return ret;
1671 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSATTR,
1672 dasd_eckd_set_attrib);
1673 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDPSRD,
1674 dasd_eckd_performance);
1675 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRLSE,
1676 dasd_eckd_release);
1677 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRSRV,
1678 dasd_eckd_reserve);
1679 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSLCK,
1680 dasd_eckd_steal_lock);
1681 return ret;
1682 }
1683
1684 dasd_generic_auto_online(&dasd_eckd_driver);
1685 return 0;
1686} 1649}
1687 1650
1688static void __exit 1651static void __exit
1689dasd_eckd_cleanup(void) 1652dasd_eckd_cleanup(void)
1690{ 1653{
1691 ccw_driver_unregister(&dasd_eckd_driver); 1654 ccw_driver_unregister(&dasd_eckd_driver);
1692
1693 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDGATTR,
1694 dasd_eckd_get_attrib);
1695 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSATTR,
1696 dasd_eckd_set_attrib);
1697 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDPSRD,
1698 dasd_eckd_performance);
1699 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRLSE,
1700 dasd_eckd_release);
1701 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRSRV,
1702 dasd_eckd_reserve);
1703 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSLCK,
1704 dasd_eckd_steal_lock);
1705} 1655}
1706 1656
1707module_init(dasd_eckd_init); 1657module_init(dasd_eckd_init);
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h
index bc3823d35223..ad8524bb7bb3 100644
--- a/drivers/s390/block/dasd_eckd.h
+++ b/drivers/s390/block/dasd_eckd.h
@@ -29,6 +29,7 @@
29#define DASD_ECKD_CCW_PSF 0x27 29#define DASD_ECKD_CCW_PSF 0x27
30#define DASD_ECKD_CCW_RSSD 0x3e 30#define DASD_ECKD_CCW_RSSD 0x3e
31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47 31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47
32#define DASD_ECKD_CCW_SNSS 0x54
32#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63 33#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63
33#define DASD_ECKD_CCW_WRITE_MT 0x85 34#define DASD_ECKD_CCW_WRITE_MT 0x85
34#define DASD_ECKD_CCW_READ_MT 0x86 35#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 000000000000..2d946b6ca074
--- /dev/null
+++ b/drivers/s390/block/dasd_eer.c
@@ -0,0 +1,682 @@
1/*
2 * Character device driver for extended error reporting.
3 *
4 * Copyright (C) 2005 IBM Corporation
5 * extended error reporting for DASD ECKD devices
6 * Author(s): Stefan Weinhuber <wein@de.ibm.com>
7 */
8
9#include <linux/init.h>
10#include <linux/fs.h>
11#include <linux/kernel.h>
12#include <linux/miscdevice.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/device.h>
16#include <linux/poll.h>
17
18#include <asm/uaccess.h>
19#include <asm/semaphore.h>
20#include <asm/atomic.h>
21#include <asm/ebcdic.h>
22
23#include "dasd_int.h"
24#include "dasd_eckd.h"
25
26#ifdef PRINTK_HEADER
27#undef PRINTK_HEADER
28#endif /* PRINTK_HEADER */
29#define PRINTK_HEADER "dasd(eer):"
30
31/*
32 * SECTION: the internal buffer
33 */
34
35/*
36 * The internal buffer is meant to store obaque blobs of data, so it does
37 * not know of higher level concepts like triggers.
38 * It consists of a number of pages that are used as a ringbuffer. Each data
39 * blob is stored in a simple record that consists of an integer, which
40 * contains the size of the following data, and the data bytes themselfes.
41 *
42 * To allow for multiple independent readers we create one internal buffer
43 * each time the device is opened and destroy the buffer when the file is
44 * closed again. The number of pages used for this buffer is determined by
45 * the module parmeter eer_pages.
46 *
47 * One record can be written to a buffer by using the functions
48 * - dasd_eer_start_record (one time per record to write the size to the
49 * buffer and reserve the space for the data)
50 * - dasd_eer_write_buffer (one or more times per record to write the data)
51 * The data can be written in several steps but you will have to compute
52 * the total size up front for the invocation of dasd_eer_start_record.
53 * If the ringbuffer is full, dasd_eer_start_record will remove the required
54 * number of old records.
55 *
56 * A record is typically read in two steps, first read the integer that
57 * specifies the size of the following data, then read the data.
58 * Both can be done by
59 * - dasd_eer_read_buffer
60 *
61 * For all mentioned functions you need to get the bufferlock first and keep
62 * it until a complete record is written or read.
63 *
64 * All information necessary to keep track of an internal buffer is kept in
65 * a struct eerbuffer. The buffer specific to a file pointer is strored in
66 * the private_data field of that file. To be able to write data to all
67 * existing buffers, each buffer is also added to the bufferlist.
68 * If the user does not want to read a complete record in one go, we have to
69 * keep track of the rest of the record. residual stores the number of bytes
70 * that are still to deliver. If the rest of the record is invalidated between
71 * two reads then residual will be set to -1 so that the next read will fail.
72 * All entries in the eerbuffer structure are protected with the bufferlock.
73 * To avoid races between writing to a buffer on the one side and creating
74 * and destroying buffers on the other side, the bufferlock must also be used
75 * to protect the bufferlist.
76 */
77
78static int eer_pages = 5;
79module_param(eer_pages, int, S_IRUGO|S_IWUSR);
80
81struct eerbuffer {
82 struct list_head list;
83 char **buffer;
84 int buffersize;
85 int buffer_page_count;
86 int head;
87 int tail;
88 int residual;
89};
90
91static LIST_HEAD(bufferlist);
92static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED;
93static DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue);
94
95/*
96 * How many free bytes are available on the buffer.
97 * Needs to be called with bufferlock held.
98 */
99static int dasd_eer_get_free_bytes(struct eerbuffer *eerb)
100{
101 if (eerb->head < eerb->tail)
102 return eerb->tail - eerb->head - 1;
103 return eerb->buffersize - eerb->head + eerb->tail -1;
104}
105
106/*
107 * How many bytes of buffer space are used.
108 * Needs to be called with bufferlock held.
109 */
110static int dasd_eer_get_filled_bytes(struct eerbuffer *eerb)
111{
112
113 if (eerb->head >= eerb->tail)
114 return eerb->head - eerb->tail;
115 return eerb->buffersize - eerb->tail + eerb->head;
116}
117
118/*
119 * The dasd_eer_write_buffer function just copies count bytes of data
120 * to the buffer. Make sure to call dasd_eer_start_record first, to
121 * make sure that enough free space is available.
122 * Needs to be called with bufferlock held.
123 */
124static void dasd_eer_write_buffer(struct eerbuffer *eerb,
125 char *data, int count)
126{
127
128 unsigned long headindex,localhead;
129 unsigned long rest, len;
130 char *nextdata;
131
132 nextdata = data;
133 rest = count;
134 while (rest > 0) {
135 headindex = eerb->head / PAGE_SIZE;
136 localhead = eerb->head % PAGE_SIZE;
137 len = min(rest, PAGE_SIZE - localhead);
138 memcpy(eerb->buffer[headindex]+localhead, nextdata, len);
139 nextdata += len;
140 rest -= len;
141 eerb->head += len;
142 if (eerb->head == eerb->buffersize)
143 eerb->head = 0; /* wrap around */
144 BUG_ON(eerb->head > eerb->buffersize);
145 }
146}
147
148/*
149 * Needs to be called with bufferlock held.
150 */
151static int dasd_eer_read_buffer(struct eerbuffer *eerb, char *data, int count)
152{
153
154 unsigned long tailindex,localtail;
155 unsigned long rest, len, finalcount;
156 char *nextdata;
157
158 finalcount = min(count, dasd_eer_get_filled_bytes(eerb));
159 nextdata = data;
160 rest = finalcount;
161 while (rest > 0) {
162 tailindex = eerb->tail / PAGE_SIZE;
163 localtail = eerb->tail % PAGE_SIZE;
164 len = min(rest, PAGE_SIZE - localtail);
165 memcpy(nextdata, eerb->buffer[tailindex] + localtail, len);
166 nextdata += len;
167 rest -= len;
168 eerb->tail += len;
169 if (eerb->tail == eerb->buffersize)
170 eerb->tail = 0; /* wrap around */
171 BUG_ON(eerb->tail > eerb->buffersize);
172 }
173 return finalcount;
174}
175
176/*
177 * Whenever you want to write a blob of data to the internal buffer you
178 * have to start by using this function first. It will write the number
179 * of bytes that will be written to the buffer. If necessary it will remove
180 * old records to make room for the new one.
181 * Needs to be called with bufferlock held.
182 */
183static int dasd_eer_start_record(struct eerbuffer *eerb, int count)
184{
185 int tailcount;
186
187 if (count + sizeof(count) > eerb->buffersize)
188 return -ENOMEM;
189 while (dasd_eer_get_free_bytes(eerb) < count + sizeof(count)) {
190 if (eerb->residual > 0) {
191 eerb->tail += eerb->residual;
192 if (eerb->tail >= eerb->buffersize)
193 eerb->tail -= eerb->buffersize;
194 eerb->residual = -1;
195 }
196 dasd_eer_read_buffer(eerb, (char *) &tailcount,
197 sizeof(tailcount));
198 eerb->tail += tailcount;
199 if (eerb->tail >= eerb->buffersize)
200 eerb->tail -= eerb->buffersize;
201 }
202 dasd_eer_write_buffer(eerb, (char*) &count, sizeof(count));
203
204 return 0;
205};
206
207/*
208 * Release pages that are not used anymore.
209 */
210static void dasd_eer_free_buffer_pages(char **buf, int no_pages)
211{
212 int i;
213
214 for (i = 0; i < no_pages; i++)
215 free_page((unsigned long) buf[i]);
216}
217
218/*
219 * Allocate a new set of memory pages.
220 */
221static int dasd_eer_allocate_buffer_pages(char **buf, int no_pages)
222{
223 int i;
224
225 for (i = 0; i < no_pages; i++) {
226 buf[i] = (char *) get_zeroed_page(GFP_KERNEL);
227 if (!buf[i]) {
228 dasd_eer_free_buffer_pages(buf, i);
229 return -ENOMEM;
230 }
231 }
232 return 0;
233}
234
235/*
236 * SECTION: The extended error reporting functionality
237 */
238
239/*
240 * When a DASD device driver wants to report an error, it calls the
241 * function dasd_eer_write and gives the respective trigger ID as
242 * parameter. Currently there are four kinds of triggers:
243 *
244 * DASD_EER_FATALERROR: all kinds of unrecoverable I/O problems
245 * DASD_EER_PPRCSUSPEND: PPRC was suspended
246 * DASD_EER_NOPATH: There is no path to the device left.
247 * DASD_EER_STATECHANGE: The state of the device has changed.
248 *
249 * For the first three triggers all required information can be supplied by
250 * the caller. For these triggers a record is written by the function
251 * dasd_eer_write_standard_trigger.
252 *
253 * The DASD_EER_STATECHANGE trigger is special since a sense subsystem
254 * status ccw need to be executed to gather the necessary sense data first.
255 * The dasd_eer_snss function will queue the SNSS request and the request
256 * callback will then call dasd_eer_write with the DASD_EER_STATCHANGE
257 * trigger.
258 *
259 * To avoid memory allocations at runtime, the necessary memory is allocated
260 * when the extended error reporting is enabled for a device (by
261 * dasd_eer_probe). There is one sense subsystem status request for each
262 * eer enabled DASD device. The presence of the cqr in device->eer_cqr
263 * indicates that eer is enable for the device. The use of the snss request
264 * is protected by the DASD_FLAG_EER_IN_USE bit. When this flag indicates
265 * that the cqr is currently in use, dasd_eer_snss cannot start a second
266 * request but sets the DASD_FLAG_EER_SNSS flag instead. The callback of
267 * the SNSS request will check the bit and call dasd_eer_snss again.
268 */
269
270#define SNSS_DATA_SIZE 44
271
272#define DASD_EER_BUSID_SIZE 10
273struct dasd_eer_header {
274 __u32 total_size;
275 __u32 trigger;
276 __u64 tv_sec;
277 __u64 tv_usec;
278 char busid[DASD_EER_BUSID_SIZE];
279};
280
281/*
282 * The following function can be used for those triggers that have
283 * all necessary data available when the function is called.
284 * If the parameter cqr is not NULL, the chain of requests will be searched
285 * for valid sense data, and all valid sense data sets will be added to
286 * the triggers data.
287 */
288static void dasd_eer_write_standard_trigger(struct dasd_device *device,
289 struct dasd_ccw_req *cqr,
290 int trigger)
291{
292 struct dasd_ccw_req *temp_cqr;
293 int data_size;
294 struct timeval tv;
295 struct dasd_eer_header header;
296 unsigned long flags;
297 struct eerbuffer *eerb;
298
299 /* go through cqr chain and count the valid sense data sets */
300 data_size = 0;
301 for (temp_cqr = cqr; temp_cqr; temp_cqr = temp_cqr->refers)
302 if (temp_cqr->irb.esw.esw0.erw.cons)
303 data_size += 32;
304
305 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
306 header.trigger = trigger;
307 do_gettimeofday(&tv);
308 header.tv_sec = tv.tv_sec;
309 header.tv_usec = tv.tv_usec;
310 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
311
312 spin_lock_irqsave(&bufferlock, flags);
313 list_for_each_entry(eerb, &bufferlist, list) {
314 dasd_eer_start_record(eerb, header.total_size);
315 dasd_eer_write_buffer(eerb, (char *) &header, sizeof(header));
316 for (temp_cqr = cqr; temp_cqr; temp_cqr = temp_cqr->refers)
317 if (temp_cqr->irb.esw.esw0.erw.cons)
318 dasd_eer_write_buffer(eerb, cqr->irb.ecw, 32);
319 dasd_eer_write_buffer(eerb, "EOR", 4);
320 }
321 spin_unlock_irqrestore(&bufferlock, flags);
322 wake_up_interruptible(&dasd_eer_read_wait_queue);
323}
324
325/*
326 * This function writes a DASD_EER_STATECHANGE trigger.
327 */
328static void dasd_eer_write_snss_trigger(struct dasd_device *device,
329 struct dasd_ccw_req *cqr,
330 int trigger)
331{
332 int data_size;
333 int snss_rc;
334 struct timeval tv;
335 struct dasd_eer_header header;
336 unsigned long flags;
337 struct eerbuffer *eerb;
338
339 snss_rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
340 if (snss_rc)
341 data_size = 0;
342 else
343 data_size = SNSS_DATA_SIZE;
344
345 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
346 header.trigger = DASD_EER_STATECHANGE;
347 do_gettimeofday(&tv);
348 header.tv_sec = tv.tv_sec;
349 header.tv_usec = tv.tv_usec;
350 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
351
352 spin_lock_irqsave(&bufferlock, flags);
353 list_for_each_entry(eerb, &bufferlist, list) {
354 dasd_eer_start_record(eerb, header.total_size);
355 dasd_eer_write_buffer(eerb, (char *) &header , sizeof(header));
356 if (!snss_rc)
357 dasd_eer_write_buffer(eerb, cqr->data, SNSS_DATA_SIZE);
358 dasd_eer_write_buffer(eerb, "EOR", 4);
359 }
360 spin_unlock_irqrestore(&bufferlock, flags);
361 wake_up_interruptible(&dasd_eer_read_wait_queue);
362}
363
364/*
365 * This function is called for all triggers. It calls the appropriate
366 * function that writes the actual trigger records.
367 */
368void dasd_eer_write(struct dasd_device *device, struct dasd_ccw_req *cqr,
369 unsigned int id)
370{
371 if (!device->eer_cqr)
372 return;
373 switch (id) {
374 case DASD_EER_FATALERROR:
375 case DASD_EER_PPRCSUSPEND:
376 dasd_eer_write_standard_trigger(device, cqr, id);
377 break;
378 case DASD_EER_NOPATH:
379 dasd_eer_write_standard_trigger(device, NULL, id);
380 break;
381 case DASD_EER_STATECHANGE:
382 dasd_eer_write_snss_trigger(device, cqr, id);
383 break;
384 default: /* unknown trigger, so we write it without any sense data */
385 dasd_eer_write_standard_trigger(device, NULL, id);
386 break;
387 }
388}
389EXPORT_SYMBOL(dasd_eer_write);
390
391/*
392 * Start a sense subsystem status request.
393 * Needs to be called with the device held.
394 */
395void dasd_eer_snss(struct dasd_device *device)
396{
397 struct dasd_ccw_req *cqr;
398
399 cqr = device->eer_cqr;
400 if (!cqr) /* Device not eer enabled. */
401 return;
402 if (test_and_set_bit(DASD_FLAG_EER_IN_USE, &device->flags)) {
403 /* Sense subsystem status request in use. */
404 set_bit(DASD_FLAG_EER_SNSS, &device->flags);
405 return;
406 }
407 clear_bit(DASD_FLAG_EER_SNSS, &device->flags);
408 cqr->status = DASD_CQR_QUEUED;
409 list_add(&cqr->list, &device->ccw_queue);
410 dasd_schedule_bh(device);
411}
412
413/*
414 * Callback function for use with sense subsystem status request.
415 */
416static void dasd_eer_snss_cb(struct dasd_ccw_req *cqr, void *data)
417{
418 struct dasd_device *device = cqr->device;
419 unsigned long flags;
420
421 dasd_eer_write(device, cqr, DASD_EER_STATECHANGE);
422 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
423 if (device->eer_cqr == cqr) {
424 clear_bit(DASD_FLAG_EER_IN_USE, &device->flags);
425 if (test_bit(DASD_FLAG_EER_SNSS, &device->flags))
426 /* Another SNSS has been requested in the meantime. */
427 dasd_eer_snss(device);
428 cqr = NULL;
429 }
430 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
431 if (cqr)
432 /*
433 * Extended error recovery has been switched off while
434 * the SNSS request was running. It could even have
435 * been switched off and on again in which case there
436 * is a new ccw in device->eer_cqr. Free the "old"
437 * snss request now.
438 */
439 dasd_kfree_request(cqr, device);
440}
441
442/*
443 * Enable error reporting on a given device.
444 */
445int dasd_eer_enable(struct dasd_device *device)
446{
447 struct dasd_ccw_req *cqr;
448 unsigned long flags;
449
450 if (device->eer_cqr)
451 return 0;
452
453 if (!device->discipline || strcmp(device->discipline->name, "ECKD"))
454 return -EPERM; /* FIXME: -EMEDIUMTYPE ? */
455
456 cqr = dasd_kmalloc_request("ECKD", 1 /* SNSS */,
457 SNSS_DATA_SIZE, device);
458 if (!cqr)
459 return -ENOMEM;
460
461 cqr->device = device;
462 cqr->retries = 255;
463 cqr->expires = 10 * HZ;
464
465 cqr->cpaddr->cmd_code = DASD_ECKD_CCW_SNSS;
466 cqr->cpaddr->count = SNSS_DATA_SIZE;
467 cqr->cpaddr->flags = 0;
468 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
469
470 cqr->buildclk = get_clock();
471 cqr->status = DASD_CQR_FILLED;
472 cqr->callback = dasd_eer_snss_cb;
473
474 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
475 if (!device->eer_cqr) {
476 device->eer_cqr = cqr;
477 cqr = NULL;
478 }
479 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
480 if (cqr)
481 dasd_kfree_request(cqr, device);
482 return 0;
483}
484
485/*
486 * Disable error reporting on a given device.
487 */
488void dasd_eer_disable(struct dasd_device *device)
489{
490 struct dasd_ccw_req *cqr;
491 unsigned long flags;
492 int in_use;
493
494 if (!device->eer_cqr)
495 return;
496 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
497 cqr = device->eer_cqr;
498 device->eer_cqr = NULL;
499 clear_bit(DASD_FLAG_EER_SNSS, &device->flags);
500 in_use = test_and_clear_bit(DASD_FLAG_EER_IN_USE, &device->flags);
501 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
502 if (cqr && !in_use)
503 dasd_kfree_request(cqr, device);
504}
505
506/*
507 * SECTION: the device operations
508 */
509
510/*
511 * On the one side we need a lock to access our internal buffer, on the
512 * other side a copy_to_user can sleep. So we need to copy the data we have
513 * to transfer in a readbuffer, which is protected by the readbuffer_mutex.
514 */
515static char readbuffer[PAGE_SIZE];
516static DECLARE_MUTEX(readbuffer_mutex);
517
518static int dasd_eer_open(struct inode *inp, struct file *filp)
519{
520 struct eerbuffer *eerb;
521 unsigned long flags;
522
523 eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL);
524 eerb->buffer_page_count = eer_pages;
525 if (eerb->buffer_page_count < 1 ||
526 eerb->buffer_page_count > INT_MAX / PAGE_SIZE) {
527 kfree(eerb);
528 MESSAGE(KERN_WARNING, "can't open device since module "
529 "parameter eer_pages is smaller then 1 or"
530 " bigger then %d", (int)(INT_MAX / PAGE_SIZE));
531 return -EINVAL;
532 }
533 eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
534 eerb->buffer = kmalloc(eerb->buffer_page_count * sizeof(char *),
535 GFP_KERNEL);
536 if (!eerb->buffer) {
537 kfree(eerb);
538 return -ENOMEM;
539 }
540 if (dasd_eer_allocate_buffer_pages(eerb->buffer,
541 eerb->buffer_page_count)) {
542 kfree(eerb->buffer);
543 kfree(eerb);
544 return -ENOMEM;
545 }
546 filp->private_data = eerb;
547 spin_lock_irqsave(&bufferlock, flags);
548 list_add(&eerb->list, &bufferlist);
549 spin_unlock_irqrestore(&bufferlock, flags);
550
551 return nonseekable_open(inp,filp);
552}
553
554static int dasd_eer_close(struct inode *inp, struct file *filp)
555{
556 struct eerbuffer *eerb;
557 unsigned long flags;
558
559 eerb = (struct eerbuffer *) filp->private_data;
560 spin_lock_irqsave(&bufferlock, flags);
561 list_del(&eerb->list);
562 spin_unlock_irqrestore(&bufferlock, flags);
563 dasd_eer_free_buffer_pages(eerb->buffer, eerb->buffer_page_count);
564 kfree(eerb->buffer);
565 kfree(eerb);
566
567 return 0;
568}
569
570static ssize_t dasd_eer_read(struct file *filp, char __user *buf,
571 size_t count, loff_t *ppos)
572{
573 int tc,rc;
574 int tailcount,effective_count;
575 unsigned long flags;
576 struct eerbuffer *eerb;
577
578 eerb = (struct eerbuffer *) filp->private_data;
579 if (down_interruptible(&readbuffer_mutex))
580 return -ERESTARTSYS;
581
582 spin_lock_irqsave(&bufferlock, flags);
583
584 if (eerb->residual < 0) { /* the remainder of this record */
585 /* has been deleted */
586 eerb->residual = 0;
587 spin_unlock_irqrestore(&bufferlock, flags);
588 up(&readbuffer_mutex);
589 return -EIO;
590 } else if (eerb->residual > 0) {
591 /* OK we still have a second half of a record to deliver */
592 effective_count = min(eerb->residual, (int) count);
593 eerb->residual -= effective_count;
594 } else {
595 tc = 0;
596 while (!tc) {
597 tc = dasd_eer_read_buffer(eerb, (char *) &tailcount,
598 sizeof(tailcount));
599 if (!tc) {
600 /* no data available */
601 spin_unlock_irqrestore(&bufferlock, flags);
602 up(&readbuffer_mutex);
603 if (filp->f_flags & O_NONBLOCK)
604 return -EAGAIN;
605 rc = wait_event_interruptible(
606 dasd_eer_read_wait_queue,
607 eerb->head != eerb->tail);
608 if (rc)
609 return rc;
610 if (down_interruptible(&readbuffer_mutex))
611 return -ERESTARTSYS;
612 spin_lock_irqsave(&bufferlock, flags);
613 }
614 }
615 WARN_ON(tc != sizeof(tailcount));
616 effective_count = min(tailcount,(int)count);
617 eerb->residual = tailcount - effective_count;
618 }
619
620 tc = dasd_eer_read_buffer(eerb, readbuffer, effective_count);
621 WARN_ON(tc != effective_count);
622
623 spin_unlock_irqrestore(&bufferlock, flags);
624
625 if (copy_to_user(buf, readbuffer, effective_count)) {
626 up(&readbuffer_mutex);
627 return -EFAULT;
628 }
629
630 up(&readbuffer_mutex);
631 return effective_count;
632}
633
634static unsigned int dasd_eer_poll(struct file *filp, poll_table *ptable)
635{
636 unsigned int mask;
637 unsigned long flags;
638 struct eerbuffer *eerb;
639
640 eerb = (struct eerbuffer *) filp->private_data;
641 poll_wait(filp, &dasd_eer_read_wait_queue, ptable);
642 spin_lock_irqsave(&bufferlock, flags);
643 if (eerb->head != eerb->tail)
644 mask = POLLIN | POLLRDNORM ;
645 else
646 mask = 0;
647 spin_unlock_irqrestore(&bufferlock, flags);
648 return mask;
649}
650
651static struct file_operations dasd_eer_fops = {
652 .open = &dasd_eer_open,
653 .release = &dasd_eer_close,
654 .read = &dasd_eer_read,
655 .poll = &dasd_eer_poll,
656 .owner = THIS_MODULE,
657};
658
659static struct miscdevice dasd_eer_dev = {
660 .minor = MISC_DYNAMIC_MINOR,
661 .name = "dasd_eer",
662 .fops = &dasd_eer_fops,
663};
664
665int __init dasd_eer_init(void)
666{
667 int rc;
668
669 rc = misc_register(&dasd_eer_dev);
670 if (rc) {
671 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
672 "register misc device");
673 return rc;
674 }
675
676 return 0;
677}
678
679void __exit dasd_eer_exit(void)
680{
681 WARN_ON(misc_deregister(&dasd_eer_dev) != 0);
682}
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 7cb0b9e78a6a..4293ba827523 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -69,15 +69,6 @@
69 */ 69 */
70struct dasd_device; 70struct dasd_device;
71 71
72typedef int (*dasd_ioctl_fn_t) (struct block_device *bdev, int no, long args);
73
74struct dasd_ioctl {
75 struct list_head list;
76 struct module *owner;
77 int no;
78 dasd_ioctl_fn_t handler;
79};
80
81typedef enum { 72typedef enum {
82 dasd_era_fatal = -1, /* no chance to recover */ 73 dasd_era_fatal = -1, /* no chance to recover */
83 dasd_era_none = 0, /* don't recover, everything alright */ 74 dasd_era_none = 0, /* don't recover, everything alright */
@@ -272,10 +263,28 @@ struct dasd_discipline {
272 /* i/o control functions. */ 263 /* i/o control functions. */
273 int (*fill_geometry) (struct dasd_device *, struct hd_geometry *); 264 int (*fill_geometry) (struct dasd_device *, struct hd_geometry *);
274 int (*fill_info) (struct dasd_device *, struct dasd_information2_t *); 265 int (*fill_info) (struct dasd_device *, struct dasd_information2_t *);
266 int (*ioctl) (struct dasd_device *, unsigned int, void __user *);
275}; 267};
276 268
277extern struct dasd_discipline *dasd_diag_discipline_pointer; 269extern struct dasd_discipline *dasd_diag_discipline_pointer;
278 270
271
272/*
273 * Notification numbers for extended error reporting notifications:
274 * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
275 * eer pointer) is freed. The error reporting module needs to do all necessary
276 * cleanup steps.
277 * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
278 */
279#define DASD_EER_DISABLE 0
280#define DASD_EER_TRIGGER 1
281
282/* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
283#define DASD_EER_FATALERROR 1
284#define DASD_EER_NOPATH 2
285#define DASD_EER_STATECHANGE 3
286#define DASD_EER_PPRCSUSPEND 4
287
279struct dasd_device { 288struct dasd_device {
280 /* Block device stuff. */ 289 /* Block device stuff. */
281 struct gendisk *gdp; 290 struct gendisk *gdp;
@@ -289,6 +298,9 @@ struct dasd_device {
289 unsigned long flags; /* per device flags */ 298 unsigned long flags; /* per device flags */
290 unsigned short features; /* copy of devmap-features (read-only!) */ 299 unsigned short features; /* copy of devmap-features (read-only!) */
291 300
301 /* extended error reporting stuff (eer) */
302 struct dasd_ccw_req *eer_cqr;
303
292 /* Device discipline stuff. */ 304 /* Device discipline stuff. */
293 struct dasd_discipline *discipline; 305 struct dasd_discipline *discipline;
294 struct dasd_discipline *base_discipline; 306 struct dasd_discipline *base_discipline;
@@ -334,6 +346,8 @@ struct dasd_device {
334/* per device flags */ 346/* per device flags */
335#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */ 347#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */
336#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */ 348#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */
349#define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */
350#define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */
337 351
338void dasd_put_device_wake(struct dasd_device *); 352void dasd_put_device_wake(struct dasd_device *);
339 353
@@ -523,10 +537,6 @@ int dasd_scan_partitions(struct dasd_device *);
523void dasd_destroy_partitions(struct dasd_device *); 537void dasd_destroy_partitions(struct dasd_device *);
524 538
525/* externals in dasd_ioctl.c */ 539/* externals in dasd_ioctl.c */
526int dasd_ioctl_init(void);
527void dasd_ioctl_exit(void);
528int dasd_ioctl_no_register(struct module *, int, dasd_ioctl_fn_t);
529int dasd_ioctl_no_unregister(struct module *, int, dasd_ioctl_fn_t);
530int dasd_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 540int dasd_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
531long dasd_compat_ioctl(struct file *, unsigned int, unsigned long); 541long dasd_compat_ioctl(struct file *, unsigned int, unsigned long);
532 542
@@ -557,6 +567,30 @@ dasd_era_t dasd_9336_erp_examine(struct dasd_ccw_req *, struct irb *);
557dasd_era_t dasd_9343_erp_examine(struct dasd_ccw_req *, struct irb *); 567dasd_era_t dasd_9343_erp_examine(struct dasd_ccw_req *, struct irb *);
558struct dasd_ccw_req *dasd_9343_erp_action(struct dasd_ccw_req *); 568struct dasd_ccw_req *dasd_9343_erp_action(struct dasd_ccw_req *);
559 569
570/* externals in dasd_eer.c */
571#ifdef CONFIG_DASD_EER
572int dasd_eer_init(void);
573void dasd_eer_exit(void);
574int dasd_eer_enable(struct dasd_device *);
575void dasd_eer_disable(struct dasd_device *);
576void dasd_eer_write(struct dasd_device *, struct dasd_ccw_req *cqr,
577 unsigned int id);
578void dasd_eer_snss(struct dasd_device *);
579
580static inline int dasd_eer_enabled(struct dasd_device *device)
581{
582 return device->eer_cqr != NULL;
583}
584#else
585#define dasd_eer_init() (0)
586#define dasd_eer_exit() do { } while (0)
587#define dasd_eer_enable(d) (0)
588#define dasd_eer_disable(d) do { } while (0)
589#define dasd_eer_write(d,c,i) do { } while (0)
590#define dasd_eer_snss(d) do { } while (0)
591#define dasd_eer_enabled(d) (0)
592#endif /* CONFIG_DASD_ERR */
593
560#endif /* __KERNEL__ */ 594#endif /* __KERNEL__ */
561 595
562#endif /* DASD_H */ 596#endif /* DASD_H */
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index f9930552ab54..b8c80d28df41 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -16,6 +16,7 @@
16#include <linux/blkpg.h> 16#include <linux/blkpg.h>
17 17
18#include <asm/ccwdev.h> 18#include <asm/ccwdev.h>
19#include <asm/cmb.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20 21
21/* This is ugly... */ 22/* This is ugly... */
@@ -23,116 +24,12 @@
23 24
24#include "dasd_int.h" 25#include "dasd_int.h"
25 26
26/*
27 * SECTION: ioctl functions.
28 */
29static struct list_head dasd_ioctl_list = LIST_HEAD_INIT(dasd_ioctl_list);
30
31/*
32 * Find the ioctl with number no.
33 */
34static struct dasd_ioctl *
35dasd_find_ioctl(int no)
36{
37 struct dasd_ioctl *ioctl;
38
39 list_for_each_entry (ioctl, &dasd_ioctl_list, list)
40 if (ioctl->no == no)
41 return ioctl;
42 return NULL;
43}
44
45/*
46 * Register ioctl with number no.
47 */
48int
49dasd_ioctl_no_register(struct module *owner, int no, dasd_ioctl_fn_t handler)
50{
51 struct dasd_ioctl *new;
52 if (dasd_find_ioctl(no))
53 return -EBUSY;
54 new = kmalloc(sizeof (struct dasd_ioctl), GFP_KERNEL);
55 if (new == NULL)
56 return -ENOMEM;
57 new->owner = owner;
58 new->no = no;
59 new->handler = handler;
60 list_add(&new->list, &dasd_ioctl_list);
61 return 0;
62}
63
64/*
65 * Deregister ioctl with number no.
66 */
67int
68dasd_ioctl_no_unregister(struct module *owner, int no, dasd_ioctl_fn_t handler)
69{
70 struct dasd_ioctl *old = dasd_find_ioctl(no);
71 if (old == NULL)
72 return -ENOENT;
73 if (old->no != no || old->handler != handler || owner != old->owner)
74 return -EINVAL;
75 list_del(&old->list);
76 kfree(old);
77 return 0;
78}
79
80int
81dasd_ioctl(struct inode *inp, struct file *filp,
82 unsigned int no, unsigned long data)
83{
84 struct block_device *bdev = inp->i_bdev;
85 struct dasd_device *device = bdev->bd_disk->private_data;
86 struct dasd_ioctl *ioctl;
87 const char *dir;
88 int rc;
89
90 if ((_IOC_DIR(no) != _IOC_NONE) && (data == 0)) {
91 PRINT_DEBUG("empty data ptr");
92 return -EINVAL;
93 }
94 dir = _IOC_DIR (no) == _IOC_NONE ? "0" :
95 _IOC_DIR (no) == _IOC_READ ? "r" :
96 _IOC_DIR (no) == _IOC_WRITE ? "w" :
97 _IOC_DIR (no) == (_IOC_READ | _IOC_WRITE) ? "rw" : "u";
98 DBF_DEV_EVENT(DBF_DEBUG, device,
99 "ioctl 0x%08x %s'0x%x'%d(%d) with data %8lx", no,
100 dir, _IOC_TYPE(no), _IOC_NR(no), _IOC_SIZE(no), data);
101 /* Search for ioctl no in the ioctl list. */
102 list_for_each_entry(ioctl, &dasd_ioctl_list, list) {
103 if (ioctl->no == no) {
104 /* Found a matching ioctl. Call it. */
105 if (!try_module_get(ioctl->owner))
106 continue;
107 rc = ioctl->handler(bdev, no, data);
108 module_put(ioctl->owner);
109 return rc;
110 }
111 }
112 /* No ioctl with number no. */
113 DBF_DEV_EVENT(DBF_INFO, device,
114 "unknown ioctl 0x%08x=%s'0x%x'%d(%d) data %8lx", no,
115 dir, _IOC_TYPE(no), _IOC_NR(no), _IOC_SIZE(no), data);
116 return -EINVAL;
117}
118
119long
120dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
121{
122 int rval;
123
124 lock_kernel();
125 rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
126 unlock_kernel();
127
128 return (rval == -EINVAL) ? -ENOIOCTLCMD : rval;
129}
130 27
131static int 28static int
132dasd_ioctl_api_version(struct block_device *bdev, int no, long args) 29dasd_ioctl_api_version(void __user *argp)
133{ 30{
134 int ver = DASD_API_VERSION; 31 int ver = DASD_API_VERSION;
135 return put_user(ver, (int __user *) args); 32 return put_user(ver, (int __user *)argp);
136} 33}
137 34
138/* 35/*
@@ -140,15 +37,13 @@ dasd_ioctl_api_version(struct block_device *bdev, int no, long args)
140 * used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection 37 * used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection
141 */ 38 */
142static int 39static int
143dasd_ioctl_enable(struct block_device *bdev, int no, long args) 40dasd_ioctl_enable(struct block_device *bdev)
144{ 41{
145 struct dasd_device *device; 42 struct dasd_device *device = bdev->bd_disk->private_data;
146 43
147 if (!capable(CAP_SYS_ADMIN)) 44 if (!capable(CAP_SYS_ADMIN))
148 return -EACCES; 45 return -EACCES;
149 device = bdev->bd_disk->private_data; 46
150 if (device == NULL)
151 return -ENODEV;
152 dasd_enable_device(device); 47 dasd_enable_device(device);
153 /* Formatting the dasd device can change the capacity. */ 48 /* Formatting the dasd device can change the capacity. */
154 mutex_lock(&bdev->bd_mutex); 49 mutex_lock(&bdev->bd_mutex);
@@ -162,15 +57,13 @@ dasd_ioctl_enable(struct block_device *bdev, int no, long args)
162 * Used by dasdfmt. Disable I/O operations but allow ioctls. 57 * Used by dasdfmt. Disable I/O operations but allow ioctls.
163 */ 58 */
164static int 59static int
165dasd_ioctl_disable(struct block_device *bdev, int no, long args) 60dasd_ioctl_disable(struct block_device *bdev)
166{ 61{
167 struct dasd_device *device; 62 struct dasd_device *device = bdev->bd_disk->private_data;
168 63
169 if (!capable(CAP_SYS_ADMIN)) 64 if (!capable(CAP_SYS_ADMIN))
170 return -EACCES; 65 return -EACCES;
171 device = bdev->bd_disk->private_data; 66
172 if (device == NULL)
173 return -ENODEV;
174 /* 67 /*
175 * Man this is sick. We don't do a real disable but only downgrade 68 * Man this is sick. We don't do a real disable but only downgrade
176 * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses 69 * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses
@@ -194,18 +87,13 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args)
194 * Quiesce device. 87 * Quiesce device.
195 */ 88 */
196static int 89static int
197dasd_ioctl_quiesce(struct block_device *bdev, int no, long args) 90dasd_ioctl_quiesce(struct dasd_device *device)
198{ 91{
199 struct dasd_device *device;
200 unsigned long flags; 92 unsigned long flags;
201 93
202 if (!capable (CAP_SYS_ADMIN)) 94 if (!capable (CAP_SYS_ADMIN))
203 return -EACCES; 95 return -EACCES;
204 96
205 device = bdev->bd_disk->private_data;
206 if (device == NULL)
207 return -ENODEV;
208
209 DEV_MESSAGE (KERN_DEBUG, device, "%s", 97 DEV_MESSAGE (KERN_DEBUG, device, "%s",
210 "Quiesce IO on device"); 98 "Quiesce IO on device");
211 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 99 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
@@ -219,18 +107,13 @@ dasd_ioctl_quiesce(struct block_device *bdev, int no, long args)
219 * Quiesce device. 107 * Quiesce device.
220 */ 108 */
221static int 109static int
222dasd_ioctl_resume(struct block_device *bdev, int no, long args) 110dasd_ioctl_resume(struct dasd_device *device)
223{ 111{
224 struct dasd_device *device;
225 unsigned long flags; 112 unsigned long flags;
226 113
227 if (!capable (CAP_SYS_ADMIN)) 114 if (!capable (CAP_SYS_ADMIN))
228 return -EACCES; 115 return -EACCES;
229 116
230 device = bdev->bd_disk->private_data;
231 if (device == NULL)
232 return -ENODEV;
233
234 DEV_MESSAGE (KERN_DEBUG, device, "%s", 117 DEV_MESSAGE (KERN_DEBUG, device, "%s",
235 "resume IO on device"); 118 "resume IO on device");
236 119
@@ -302,25 +185,19 @@ dasd_format(struct dasd_device * device, struct format_data_t * fdata)
302 * Format device. 185 * Format device.
303 */ 186 */
304static int 187static int
305dasd_ioctl_format(struct block_device *bdev, int no, long args) 188dasd_ioctl_format(struct block_device *bdev, void __user *argp)
306{ 189{
307 struct dasd_device *device; 190 struct dasd_device *device = bdev->bd_disk->private_data;
308 struct format_data_t fdata; 191 struct format_data_t fdata;
309 192
310 if (!capable(CAP_SYS_ADMIN)) 193 if (!capable(CAP_SYS_ADMIN))
311 return -EACCES; 194 return -EACCES;
312 if (!args) 195 if (!argp)
313 return -EINVAL; 196 return -EINVAL;
314 /* fdata == NULL is no longer a valid arg to dasd_format ! */
315 device = bdev->bd_disk->private_data;
316
317 if (device == NULL)
318 return -ENODEV;
319 197
320 if (device->features & DASD_FEATURE_READONLY) 198 if (device->features & DASD_FEATURE_READONLY)
321 return -EROFS; 199 return -EROFS;
322 if (copy_from_user(&fdata, (void __user *) args, 200 if (copy_from_user(&fdata, argp, sizeof(struct format_data_t)))
323 sizeof (struct format_data_t)))
324 return -EFAULT; 201 return -EFAULT;
325 if (bdev != bdev->bd_contains) { 202 if (bdev != bdev->bd_contains) {
326 DEV_MESSAGE(KERN_WARNING, device, "%s", 203 DEV_MESSAGE(KERN_WARNING, device, "%s",
@@ -335,17 +212,8 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
335 * Reset device profile information 212 * Reset device profile information
336 */ 213 */
337static int 214static int
338dasd_ioctl_reset_profile(struct block_device *bdev, int no, long args) 215dasd_ioctl_reset_profile(struct dasd_device *device)
339{ 216{
340 struct dasd_device *device;
341
342 if (!capable(CAP_SYS_ADMIN))
343 return -EACCES;
344
345 device = bdev->bd_disk->private_data;
346 if (device == NULL)
347 return -ENODEV;
348
349 memset(&device->profile, 0, sizeof (struct dasd_profile_info_t)); 217 memset(&device->profile, 0, sizeof (struct dasd_profile_info_t));
350 return 0; 218 return 0;
351} 219}
@@ -354,31 +222,24 @@ dasd_ioctl_reset_profile(struct block_device *bdev, int no, long args)
354 * Return device profile information 222 * Return device profile information
355 */ 223 */
356static int 224static int
357dasd_ioctl_read_profile(struct block_device *bdev, int no, long args) 225dasd_ioctl_read_profile(struct dasd_device *device, void __user *argp)
358{ 226{
359 struct dasd_device *device;
360
361 device = bdev->bd_disk->private_data;
362 if (device == NULL)
363 return -ENODEV;
364
365 if (dasd_profile_level == DASD_PROFILE_OFF) 227 if (dasd_profile_level == DASD_PROFILE_OFF)
366 return -EIO; 228 return -EIO;
367 229 if (copy_to_user(argp, &device->profile,
368 if (copy_to_user((long __user *) args, (long *) &device->profile,
369 sizeof (struct dasd_profile_info_t))) 230 sizeof (struct dasd_profile_info_t)))
370 return -EFAULT; 231 return -EFAULT;
371 return 0; 232 return 0;
372} 233}
373#else 234#else
374static int 235static int
375dasd_ioctl_reset_profile(struct block_device *bdev, int no, long args) 236dasd_ioctl_reset_profile(struct dasd_device *device)
376{ 237{
377 return -ENOSYS; 238 return -ENOSYS;
378} 239}
379 240
380static int 241static int
381dasd_ioctl_read_profile(struct block_device *bdev, int no, long args) 242dasd_ioctl_read_profile(struct dasd_device *device, void __user *argp)
382{ 243{
383 return -ENOSYS; 244 return -ENOSYS;
384} 245}
@@ -388,22 +249,18 @@ dasd_ioctl_read_profile(struct block_device *bdev, int no, long args)
388 * Return dasd information. Used for BIODASDINFO and BIODASDINFO2. 249 * Return dasd information. Used for BIODASDINFO and BIODASDINFO2.
389 */ 250 */
390static int 251static int
391dasd_ioctl_information(struct block_device *bdev, int no, long args) 252dasd_ioctl_information(struct dasd_device *device,
253 unsigned int cmd, void __user *argp)
392{ 254{
393 struct dasd_device *device;
394 struct dasd_information2_t *dasd_info; 255 struct dasd_information2_t *dasd_info;
395 unsigned long flags; 256 unsigned long flags;
396 int rc; 257 int rc;
397 struct ccw_device *cdev; 258 struct ccw_device *cdev;
398 259
399 device = bdev->bd_disk->private_data;
400 if (device == NULL)
401 return -ENODEV;
402
403 if (!device->discipline->fill_info) 260 if (!device->discipline->fill_info)
404 return -EINVAL; 261 return -EINVAL;
405 262
406 dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); 263 dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
407 if (dasd_info == NULL) 264 if (dasd_info == NULL)
408 return -ENOMEM; 265 return -ENOMEM;
409 266
@@ -446,8 +303,7 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
446 memcpy(dasd_info->type, device->discipline->name, 4); 303 memcpy(dasd_info->type, device->discipline->name, 4);
447 else 304 else
448 memcpy(dasd_info->type, "none", 4); 305 memcpy(dasd_info->type, "none", 4);
449 dasd_info->req_queue_len = 0; 306
450 dasd_info->chanq_len = 0;
451 if (device->request_queue->request_fn) { 307 if (device->request_queue->request_fn) {
452 struct list_head *l; 308 struct list_head *l;
453#ifdef DASD_EXTENDED_PROFILING 309#ifdef DASD_EXTENDED_PROFILING
@@ -467,8 +323,8 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
467 } 323 }
468 324
469 rc = 0; 325 rc = 0;
470 if (copy_to_user((long __user *) args, (long *) dasd_info, 326 if (copy_to_user(argp, dasd_info,
471 ((no == (unsigned int) BIODASDINFO2) ? 327 ((cmd == (unsigned int) BIODASDINFO2) ?
472 sizeof (struct dasd_information2_t) : 328 sizeof (struct dasd_information2_t) :
473 sizeof (struct dasd_information_t)))) 329 sizeof (struct dasd_information_t))))
474 rc = -EFAULT; 330 rc = -EFAULT;
@@ -480,69 +336,103 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
480 * Set read only 336 * Set read only
481 */ 337 */
482static int 338static int
483dasd_ioctl_set_ro(struct block_device *bdev, int no, long args) 339dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp)
484{ 340{
485 struct dasd_device *device; 341 struct dasd_device *device = bdev->bd_disk->private_data;
486 int intval, rc; 342 int intval;
487 343
488 if (!capable(CAP_SYS_ADMIN)) 344 if (!capable(CAP_SYS_ADMIN))
489 return -EACCES; 345 return -EACCES;
490 if (bdev != bdev->bd_contains) 346 if (bdev != bdev->bd_contains)
491 // ro setting is not allowed for partitions 347 // ro setting is not allowed for partitions
492 return -EINVAL; 348 return -EINVAL;
493 if (get_user(intval, (int __user *) args)) 349 if (get_user(intval, (int *)argp))
494 return -EFAULT; 350 return -EFAULT;
495 device = bdev->bd_disk->private_data;
496 if (device == NULL)
497 return -ENODEV;
498 351
499 set_disk_ro(bdev->bd_disk, intval); 352 set_disk_ro(bdev->bd_disk, intval);
500 rc = dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval); 353 return dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval);
501
502 return rc;
503} 354}
504 355
505/* 356static int
506 * List of static ioctls. 357dasd_ioctl_readall_cmb(struct dasd_device *device, unsigned int cmd,
507 */ 358 unsigned long arg)
508static struct { int no; dasd_ioctl_fn_t fn; } dasd_ioctls[] =
509{ 359{
510 { BIODASDDISABLE, dasd_ioctl_disable }, 360 struct cmbdata __user *argp = (void __user *) arg;
511 { BIODASDENABLE, dasd_ioctl_enable }, 361 size_t size = _IOC_SIZE(cmd);
512 { BIODASDQUIESCE, dasd_ioctl_quiesce }, 362 struct cmbdata data;
513 { BIODASDRESUME, dasd_ioctl_resume }, 363 int ret;
514 { BIODASDFMT, dasd_ioctl_format }, 364
515 { BIODASDINFO, dasd_ioctl_information }, 365 ret = cmf_readall(device->cdev, &data);
516 { BIODASDINFO2, dasd_ioctl_information }, 366 if (!ret && copy_to_user(argp, &data, min(size, sizeof(*argp))))
517 { BIODASDPRRD, dasd_ioctl_read_profile }, 367 return -EFAULT;
518 { BIODASDPRRST, dasd_ioctl_reset_profile }, 368 return ret;
519 { BLKROSET, dasd_ioctl_set_ro }, 369}
520 { DASDAPIVER, dasd_ioctl_api_version },
521 { -1, NULL }
522};
523 370
524int 371int
525dasd_ioctl_init(void) 372dasd_ioctl(struct inode *inode, struct file *file,
373 unsigned int cmd, unsigned long arg)
526{ 374{
527 int i; 375 struct block_device *bdev = inode->i_bdev;
376 struct dasd_device *device = bdev->bd_disk->private_data;
377 void __user *argp = (void __user *)arg;
528 378
529 for (i = 0; dasd_ioctls[i].no != -1; i++) 379 if (!device)
530 dasd_ioctl_no_register(NULL, dasd_ioctls[i].no, 380 return -ENODEV;
531 dasd_ioctls[i].fn); 381
532 return 0; 382 if ((_IOC_DIR(cmd) != _IOC_NONE) && !arg) {
383 PRINT_DEBUG("empty data ptr");
384 return -EINVAL;
385 }
533 386
387 switch (cmd) {
388 case BIODASDDISABLE:
389 return dasd_ioctl_disable(bdev);
390 case BIODASDENABLE:
391 return dasd_ioctl_enable(bdev);
392 case BIODASDQUIESCE:
393 return dasd_ioctl_quiesce(device);
394 case BIODASDRESUME:
395 return dasd_ioctl_resume(device);
396 case BIODASDFMT:
397 return dasd_ioctl_format(bdev, argp);
398 case BIODASDINFO:
399 return dasd_ioctl_information(device, cmd, argp);
400 case BIODASDINFO2:
401 return dasd_ioctl_information(device, cmd, argp);
402 case BIODASDPRRD:
403 return dasd_ioctl_read_profile(device, argp);
404 case BIODASDPRRST:
405 return dasd_ioctl_reset_profile(device);
406 case BLKROSET:
407 return dasd_ioctl_set_ro(bdev, argp);
408 case DASDAPIVER:
409 return dasd_ioctl_api_version(argp);
410 case BIODASDCMFENABLE:
411 return enable_cmf(device->cdev);
412 case BIODASDCMFDISABLE:
413 return disable_cmf(device->cdev);
414 case BIODASDREADALLCMB:
415 return dasd_ioctl_readall_cmb(device, cmd, arg);
416 default:
417 /* if the discipline has an ioctl method try it. */
418 if (device->discipline->ioctl) {
419 int rval = device->discipline->ioctl(device, cmd, argp);
420 if (rval != -ENOIOCTLCMD)
421 return rval;
422 }
423
424 return -EINVAL;
425 }
534} 426}
535 427
536void 428long
537dasd_ioctl_exit(void) 429dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
538{ 430{
539 int i; 431 int rval;
540 432
541 for (i = 0; dasd_ioctls[i].no != -1; i++) 433 lock_kernel();
542 dasd_ioctl_no_unregister(NULL, dasd_ioctls[i].no, 434 rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
543 dasd_ioctls[i].fn); 435 unlock_kernel();
544 436
437 return (rval == -EINVAL) ? -ENOIOCTLCMD : rval;
545} 438}
546
547EXPORT_SYMBOL(dasd_ioctl_no_register);
548EXPORT_SYMBOL(dasd_ioctl_no_unregister);
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index 44133250da2e..be9b05347b4f 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
388 /* 388 /*
389 * get a struct dcssblk_dev_info 389 * get a struct dcssblk_dev_info
390 */ 390 */
391 dev_info = kmalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL); 391 dev_info = kzalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL);
392 if (dev_info == NULL) { 392 if (dev_info == NULL) {
393 rc = -ENOMEM; 393 rc = -ENOMEM;
394 goto out; 394 goto out;
395 } 395 }
396 memset(dev_info, 0, sizeof(struct dcssblk_dev_info));
397 396
398 strcpy(dev_info->segment_name, local_buf); 397 strcpy(dev_info->segment_name, local_buf);
399 strlcpy(dev_info->dev.bus_id, local_buf, BUS_ID_SIZE); 398 strlcpy(dev_info->dev.bus_id, local_buf, BUS_ID_SIZE);
diff --git a/drivers/s390/char/Makefile b/drivers/s390/char/Makefile
index 6377a96735df..0c0162ff6c0c 100644
--- a/drivers/s390/char/Makefile
+++ b/drivers/s390/char/Makefile
@@ -26,4 +26,5 @@ tape-$(CONFIG_PROC_FS) += tape_proc.o
26tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y) 26tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y)
27obj-$(CONFIG_S390_TAPE) += tape.o tape_class.o 27obj-$(CONFIG_S390_TAPE) += tape.o tape_class.o
28obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o 28obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o
29obj-$(CONFIG_S390_TAPE_3590) += tape_3590.o
29obj-$(CONFIG_MONREADER) += monreader.o 30obj-$(CONFIG_MONREADER) += monreader.o
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 5f6fa4c67843..a6415377bc73 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -368,10 +368,9 @@ fs3270_alloc_view(void)
368{ 368{
369 struct fs3270 *fp; 369 struct fs3270 *fp;
370 370
371 fp = (struct fs3270 *) kmalloc(sizeof(struct fs3270),GFP_KERNEL); 371 fp = kzalloc(sizeof(struct fs3270),GFP_KERNEL);
372 if (!fp) 372 if (!fp)
373 return ERR_PTR(-ENOMEM); 373 return ERR_PTR(-ENOMEM);
374 memset(fp, 0, sizeof(struct fs3270));
375 fp->init = raw3270_request_alloc(0); 374 fp->init = raw3270_request_alloc(0);
376 if (IS_ERR(fp->init)) { 375 if (IS_ERR(fp->init)) {
377 kfree(fp); 376 kfree(fp);
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index a317a123daba..6badd8403409 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -50,14 +50,12 @@ kbd_alloc(void) {
50 struct kbd_data *kbd; 50 struct kbd_data *kbd;
51 int i, len; 51 int i, len;
52 52
53 kbd = kmalloc(sizeof(struct kbd_data), GFP_KERNEL); 53 kbd = kzalloc(sizeof(struct kbd_data), GFP_KERNEL);
54 if (!kbd) 54 if (!kbd)
55 goto out; 55 goto out;
56 memset(kbd, 0, sizeof(struct kbd_data)); 56 kbd->key_maps = kzalloc(sizeof(key_maps), GFP_KERNEL);
57 kbd->key_maps = kmalloc(sizeof(key_maps), GFP_KERNEL);
58 if (!key_maps) 57 if (!key_maps)
59 goto out_kbd; 58 goto out_kbd;
60 memset(kbd->key_maps, 0, sizeof(key_maps));
61 for (i = 0; i < ARRAY_SIZE(key_maps); i++) { 59 for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
62 if (key_maps[i]) { 60 if (key_maps[i]) {
63 kbd->key_maps[i] = 61 kbd->key_maps[i] =
@@ -68,10 +66,9 @@ kbd_alloc(void) {
68 sizeof(u_short)*NR_KEYS); 66 sizeof(u_short)*NR_KEYS);
69 } 67 }
70 } 68 }
71 kbd->func_table = kmalloc(sizeof(func_table), GFP_KERNEL); 69 kbd->func_table = kzalloc(sizeof(func_table), GFP_KERNEL);
72 if (!kbd->func_table) 70 if (!kbd->func_table)
73 goto out_maps; 71 goto out_maps;
74 memset(kbd->func_table, 0, sizeof(func_table));
75 for (i = 0; i < ARRAY_SIZE(func_table); i++) { 72 for (i = 0; i < ARRAY_SIZE(func_table); i++) {
76 if (func_table[i]) { 73 if (func_table[i]) {
77 len = strlen(func_table[i]) + 1; 74 len = strlen(func_table[i]) + 1;
@@ -82,10 +79,9 @@ kbd_alloc(void) {
82 } 79 }
83 } 80 }
84 kbd->fn_handler = 81 kbd->fn_handler =
85 kmalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL); 82 kzalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
86 if (!kbd->fn_handler) 83 if (!kbd->fn_handler)
87 goto out_func; 84 goto out_func;
88 memset(kbd->fn_handler, 0, sizeof(fn_handler_fn *) * NR_FN_HANDLER);
89 kbd->accent_table = 85 kbd->accent_table =
90 kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL); 86 kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL);
91 if (!kbd->accent_table) 87 if (!kbd->accent_table)
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 5fd3ad867386..fb7bc9e5eebc 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -257,14 +257,13 @@ mon_alloc_mem(void)
257 int i,j; 257 int i,j;
258 struct mon_private *monpriv; 258 struct mon_private *monpriv;
259 259
260 monpriv = kmalloc(sizeof(struct mon_private), GFP_KERNEL); 260 monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL);
261 if (!monpriv) { 261 if (!monpriv) {
262 P_ERROR("no memory for monpriv\n"); 262 P_ERROR("no memory for monpriv\n");
263 return NULL; 263 return NULL;
264 } 264 }
265 memset(monpriv, 0, sizeof(struct mon_private));
266 for (i = 0; i < MON_MSGLIM; i++) { 265 for (i = 0; i < MON_MSGLIM; i++) {
267 monpriv->msg_array[i] = kmalloc(sizeof(struct mon_msg), 266 monpriv->msg_array[i] = kzalloc(sizeof(struct mon_msg),
268 GFP_KERNEL); 267 GFP_KERNEL);
269 if (!monpriv->msg_array[i]) { 268 if (!monpriv->msg_array[i]) {
270 P_ERROR("open, no memory for msg_array\n"); 269 P_ERROR("open, no memory for msg_array\n");
@@ -272,7 +271,6 @@ mon_alloc_mem(void)
272 kfree(monpriv->msg_array[j]); 271 kfree(monpriv->msg_array[j]);
273 return NULL; 272 return NULL;
274 } 273 }
275 memset(monpriv->msg_array[i], 0, sizeof(struct mon_msg));
276 } 274 }
277 return monpriv; 275 return monpriv;
278} 276}
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 1026f2bc3185..bd06607a5dcc 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -115,10 +115,9 @@ raw3270_request_alloc(size_t size)
115 struct raw3270_request *rq; 115 struct raw3270_request *rq;
116 116
117 /* Allocate request structure */ 117 /* Allocate request structure */
118 rq = kmalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA); 118 rq = kzalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
119 if (!rq) 119 if (!rq)
120 return ERR_PTR(-ENOMEM); 120 return ERR_PTR(-ENOMEM);
121 memset(rq, 0, sizeof(struct raw3270_request));
122 121
123 /* alloc output buffer. */ 122 /* alloc output buffer. */
124 if (size > 0) { 123 if (size > 0) {
diff --git a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h
index 01d865d93791..cd51ace8b610 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 *);
250extern int tape_do_io(struct tape_device *, struct tape_request *); 250extern int tape_do_io(struct tape_device *, struct tape_request *);
251extern int tape_do_io_async(struct tape_device *, struct tape_request *); 251extern int tape_do_io_async(struct tape_device *, struct tape_request *);
252extern int tape_do_io_interruptible(struct tape_device *, struct tape_request *); 252extern int tape_do_io_interruptible(struct tape_device *, struct tape_request *);
253extern int tape_cancel_io(struct tape_device *, struct tape_request *);
253void tape_hotplug_event(struct tape_device *, int major, int action); 254void tape_hotplug_event(struct tape_device *, int major, int action);
254 255
255static inline int 256static inline int
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index 682039cac15b..d4f2da738078 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -2,8 +2,7 @@
2 * drivers/s390/char/tape_34xx.c 2 * drivers/s390/char/tape_34xx.c
3 * tape device discipline for 3480/3490 tapes. 3 * tape device discipline for 3480/3490 tapes.
4 * 4 *
5 * S390 and zSeries version 5 * Copyright (C) IBM Corp. 2001,2006
6 * Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Carsten Otte <cotte@de.ibm.com> 6 * Author(s): Carsten Otte <cotte@de.ibm.com>
8 * Tuan Ngo-Anh <ngoanh@de.ibm.com> 7 * Tuan Ngo-Anh <ngoanh@de.ibm.com>
9 * Martin Schwidefsky <schwidefsky@de.ibm.com> 8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -28,11 +27,6 @@
28debug_info_t *TAPE_DBF_AREA = NULL; 27debug_info_t *TAPE_DBF_AREA = NULL;
29EXPORT_SYMBOL(TAPE_DBF_AREA); 28EXPORT_SYMBOL(TAPE_DBF_AREA);
30 29
31enum tape_34xx_type {
32 tape_3480,
33 tape_3490,
34};
35
36#define TAPE34XX_FMT_3480 0 30#define TAPE34XX_FMT_3480 0
37#define TAPE34XX_FMT_3480_2_XF 1 31#define TAPE34XX_FMT_3480_2_XF 1
38#define TAPE34XX_FMT_3480_XF 2 32#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 000000000000..c3915f60a3aa
--- /dev/null
+++ b/drivers/s390/char/tape_3590.c
@@ -0,0 +1,1301 @@
1/*
2 * drivers/s390/char/tape_3590.c
3 * tape device discipline for 3590 tapes.
4 *
5 * Copyright (C) IBM Corp. 2001,2006
6 * Author(s): Stefan Bader <shbader@de.ibm.com>
7 * Michael Holzheu <holzheu@de.ibm.com>
8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
9 */
10
11#include <linux/config.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/bio.h>
15
16#define TAPE_DBF_AREA tape_3590_dbf
17
18#include "tape.h"
19#include "tape_std.h"
20#include "tape_3590.h"
21
22/*
23 * Pointer to debug area.
24 */
25debug_info_t *TAPE_DBF_AREA = NULL;
26EXPORT_SYMBOL(TAPE_DBF_AREA);
27
28/*******************************************************************
29 * Error Recovery fuctions:
30 * - Read Opposite: implemented
31 * - Read Device (buffered) log: BRA
32 * - Read Library log: BRA
33 * - Swap Devices: BRA
34 * - Long Busy: BRA
35 * - Special Intercept: BRA
36 * - Read Alternate: implemented
37 *******************************************************************/
38
39#define PRINTK_HEADER "TAPE_3590: "
40
41static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = {
42 [0x00] = "",
43 [0x10] = "Lost Sense",
44 [0x11] = "Assigned Elsewhere",
45 [0x12] = "Allegiance Reset",
46 [0x13] = "Shared Access Violation",
47 [0x20] = "Command Reject",
48 [0x21] = "Configuration Error",
49 [0x22] = "Protection Exception",
50 [0x23] = "Write Protect",
51 [0x24] = "Write Length",
52 [0x25] = "Read-Only Format",
53 [0x31] = "Beginning of Partition",
54 [0x33] = "End of Partition",
55 [0x34] = "End of Data",
56 [0x35] = "Block not found",
57 [0x40] = "Device Intervention",
58 [0x41] = "Loader Intervention",
59 [0x42] = "Library Intervention",
60 [0x50] = "Write Error",
61 [0x51] = "Erase Error",
62 [0x52] = "Formatting Error",
63 [0x53] = "Read Error",
64 [0x54] = "Unsupported Format",
65 [0x55] = "No Formatting",
66 [0x56] = "Positioning lost",
67 [0x57] = "Read Length",
68 [0x60] = "Unsupported Medium",
69 [0x61] = "Medium Length Error",
70 [0x62] = "Medium removed",
71 [0x64] = "Load Check",
72 [0x65] = "Unload Check",
73 [0x70] = "Equipment Check",
74 [0x71] = "Bus out Check",
75 [0x72] = "Protocol Error",
76 [0x73] = "Interface Error",
77 [0x74] = "Overrun",
78 [0x75] = "Halt Signal",
79 [0x90] = "Device fenced",
80 [0x91] = "Device Path fenced",
81 [0xa0] = "Volume misplaced",
82 [0xa1] = "Volume inaccessible",
83 [0xa2] = "Volume in input",
84 [0xa3] = "Volume ejected",
85 [0xa4] = "All categories reserved",
86 [0xa5] = "Duplicate Volume",
87 [0xa6] = "Library Manager Offline",
88 [0xa7] = "Library Output Station full",
89 [0xa8] = "Vision System non-operational",
90 [0xa9] = "Library Manager Equipment Check",
91 [0xaa] = "Library Equipment Check",
92 [0xab] = "All Library Cells full",
93 [0xac] = "No Cleaner Volumes in Library",
94 [0xad] = "I/O Station door open",
95 [0xae] = "Subsystem environmental alert",
96};
97
98/*
99 * 3590 IOCTL Overload
100 */
101static int
102tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
103{
104 switch (cmd) {
105 case TAPE390_DISPLAY: {
106 struct display_struct disp;
107
108 if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)))
109 return -EFAULT;
110
111 return tape_std_display(device, &disp);
112 }
113 default:
114 return -EINVAL; /* no additional ioctls */
115 }
116}
117
118/*
119 * SENSE Medium: Get Sense data about medium state
120 */
121static int
122tape_3590_sense_medium(struct tape_device *device)
123{
124 struct tape_request *request;
125
126 request = tape_alloc_request(1, 128);
127 if (IS_ERR(request))
128 return PTR_ERR(request);
129 request->op = TO_MSEN;
130 tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata);
131 return tape_do_io_free(device, request);
132}
133
134/*
135 * MTTELL: Tell block. Return the number of block relative to current file.
136 */
137static int
138tape_3590_mttell(struct tape_device *device, int mt_count)
139{
140 __u64 block_id;
141 int rc;
142
143 rc = tape_std_read_block_id(device, &block_id);
144 if (rc)
145 return rc;
146 return block_id >> 32;
147}
148
149/*
150 * MTSEEK: seek to the specified block.
151 */
152static int
153tape_3590_mtseek(struct tape_device *device, int count)
154{
155 struct tape_request *request;
156
157 DBF_EVENT(6, "xsee id: %x\n", count);
158 request = tape_alloc_request(3, 4);
159 if (IS_ERR(request))
160 return PTR_ERR(request);
161 request->op = TO_LBL;
162 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
163 *(__u32 *) request->cpdata = count;
164 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
165 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
166 return tape_do_io_free(device, request);
167}
168
169/*
170 * Read Opposite Error Recovery Function:
171 * Used, when Read Forward does not work
172 */
173static void
174tape_3590_read_opposite(struct tape_device *device,
175 struct tape_request *request)
176{
177 struct tape_3590_disc_data *data;
178
179 /*
180 * We have allocated 4 ccws in tape_std_read, so we can now
181 * transform the request to a read backward, followed by a
182 * forward space block.
183 */
184 request->op = TO_RBA;
185 tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
186 data = device->discdata;
187 tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op,
188 device->char_data.idal_buf);
189 tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
190 tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
191 DBF_EVENT(6, "xrop ccwg\n");
192}
193
194/*
195 * Read Attention Msg
196 * This should be done after an interrupt with attention bit (0x80)
197 * in device state.
198 *
199 * After a "read attention message" request there are two possible
200 * results:
201 *
202 * 1. A unit check is presented, when attention sense is present (e.g. when
203 * a medium has been unloaded). The attention sense comes then
204 * together with the unit check. The recovery action is either "retry"
205 * (in case there is an attention message pending) or "permanent error".
206 *
207 * 2. The attention msg is written to the "read subsystem data" buffer.
208 * In this case we probably should print it to the console.
209 */
210static int
211tape_3590_read_attmsg(struct tape_device *device)
212{
213 struct tape_request *request;
214 char *buf;
215
216 request = tape_alloc_request(3, 4096);
217 if (IS_ERR(request))
218 return PTR_ERR(request);
219 request->op = TO_READ_ATTMSG;
220 buf = request->cpdata;
221 buf[0] = PREP_RD_SS_DATA;
222 buf[6] = RD_ATTMSG; /* read att msg */
223 tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf);
224 tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12);
225 tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
226 return tape_do_io_free(device, request);
227}
228
229/*
230 * These functions are used to schedule follow-up actions from within an
231 * interrupt context (like unsolicited interrupts).
232 */
233static void
234tape_3590_work_handler(void *data)
235{
236 struct {
237 struct tape_device *device;
238 enum tape_op op;
239 struct work_struct work;
240 } *p = data;
241
242 switch (p->op) {
243 case TO_MSEN:
244 tape_3590_sense_medium(p->device);
245 break;
246 case TO_READ_ATTMSG:
247 tape_3590_read_attmsg(p->device);
248 break;
249 default:
250 DBF_EVENT(3, "T3590: work handler undefined for "
251 "operation 0x%02x\n", p->op);
252 }
253 tape_put_device(p->device);
254 kfree(p);
255}
256
257static int
258tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
259{
260 struct {
261 struct tape_device *device;
262 enum tape_op op;
263 struct work_struct work;
264 } *p;
265
266 if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
267 return -ENOMEM;
268
269 INIT_WORK(&p->work, tape_3590_work_handler, p);
270
271 p->device = tape_get_device_reference(device);
272 p->op = op;
273
274 schedule_work(&p->work);
275 return 0;
276}
277
278#ifdef CONFIG_S390_TAPE_BLOCK
279/*
280 * Tape Block READ
281 */
282static struct tape_request *
283tape_3590_bread(struct tape_device *device, struct request *req)
284{
285 struct tape_request *request;
286 struct ccw1 *ccw;
287 int count = 0, start_block, i;
288 unsigned off;
289 char *dst;
290 struct bio_vec *bv;
291 struct bio *bio;
292
293 DBF_EVENT(6, "xBREDid:");
294 start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
295 DBF_EVENT(6, "start_block = %i\n", start_block);
296
297 rq_for_each_bio(bio, req) {
298 bio_for_each_segment(bv, bio, i) {
299 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
300 }
301 }
302 request = tape_alloc_request(2 + count + 1, 4);
303 if (IS_ERR(request))
304 return request;
305 request->op = TO_BLOCK;
306 *(__u32 *) request->cpdata = start_block;
307 ccw = request->cpaddr;
308 ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
309
310 /*
311 * We always setup a nop after the mode set ccw. This slot is
312 * used in tape_std_check_locate to insert a locate ccw if the
313 * current tape position doesn't match the start block to be read.
314 */
315 ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
316
317 rq_for_each_bio(bio, req) {
318 bio_for_each_segment(bv, bio, i) {
319 dst = kmap(bv->bv_page) + bv->bv_offset;
320 for (off = 0; off < bv->bv_len;
321 off += TAPEBLOCK_HSEC_SIZE) {
322 ccw->flags = CCW_FLAG_CC;
323 ccw->cmd_code = READ_FORWARD;
324 ccw->count = TAPEBLOCK_HSEC_SIZE;
325 set_normalized_cda(ccw, (void *) __pa(dst));
326 ccw++;
327 dst += TAPEBLOCK_HSEC_SIZE;
328 }
329 if (off > bv->bv_len)
330 BUG();
331 }
332 }
333 ccw = tape_ccw_end(ccw, NOP, 0, NULL);
334 DBF_EVENT(6, "xBREDccwg\n");
335 return request;
336}
337
338static void
339tape_3590_free_bread(struct tape_request *request)
340{
341 struct ccw1 *ccw;
342
343 /* Last ccw is a nop and doesn't need clear_normalized_cda */
344 for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
345 if (ccw->cmd_code == READ_FORWARD)
346 clear_normalized_cda(ccw);
347 tape_free_request(request);
348}
349
350/*
351 * check_locate is called just before the tape request is passed to
352 * the common io layer for execution. It has to check the current
353 * tape position and insert a locate ccw if it doesn't match the
354 * start block for the request.
355 */
356static void
357tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
358{
359 __u32 *start_block;
360
361 start_block = (__u32 *) request->cpdata;
362 if (*start_block != device->blk_data.block_position) {
363 /* Add the start offset of the file to get the real block. */
364 *start_block += device->bof;
365 tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
366 }
367}
368#endif
369
370/*
371 * The done handler is called at device/channel end and wakes up the sleeping
372 * process
373 */
374static int
375tape_3590_done(struct tape_device *device, struct tape_request *request)
376{
377 struct tape_3590_med_sense *sense;
378
379 DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
380
381 switch (request->op) {
382 case TO_BSB:
383 case TO_BSF:
384 case TO_DSE:
385 case TO_FSB:
386 case TO_FSF:
387 case TO_LBL:
388 case TO_RFO:
389 case TO_RBA:
390 case TO_REW:
391 case TO_WRI:
392 case TO_WTM:
393 case TO_BLOCK:
394 case TO_LOAD:
395 tape_med_state_set(device, MS_LOADED);
396 break;
397 case TO_RUN:
398 tape_med_state_set(device, MS_UNLOADED);
399 break;
400 case TO_MSEN:
401 sense = (struct tape_3590_med_sense *) request->cpdata;
402 if (sense->masst == MSENSE_UNASSOCIATED)
403 tape_med_state_set(device, MS_UNLOADED);
404 if (sense->masst == MSENSE_ASSOCIATED_MOUNT)
405 tape_med_state_set(device, MS_LOADED);
406 break;
407 case TO_RBI: /* RBI seems to succeed even without medium loaded. */
408 case TO_NOP: /* Same to NOP. */
409 case TO_READ_CONFIG:
410 case TO_READ_ATTMSG:
411 case TO_DIS:
412 case TO_ASSIGN:
413 case TO_UNASSIGN:
414 break;
415 case TO_SIZE:
416 break;
417 }
418 return TAPE_IO_SUCCESS;
419}
420
421/*
422 * This fuction is called, when error recovery was successfull
423 */
424static inline int
425tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
426{
427 DBF_EVENT(3, "Error Recovery successfull for %s\n",
428 tape_op_verbose[request->op]);
429 return tape_3590_done(device, request);
430}
431
432/*
433 * This fuction is called, when error recovery was not successfull
434 */
435static inline int
436tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
437 struct irb *irb, int rc)
438{
439 DBF_EVENT(3, "Error Recovery failed for %s\n",
440 tape_op_verbose[request->op]);
441 tape_dump_sense_dbf(device, request, irb);
442 return rc;
443}
444
445/*
446 * Error Recovery do retry
447 */
448static inline int
449tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
450 struct irb *irb)
451{
452 DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
453 tape_dump_sense_dbf(device, request, irb);
454 return TAPE_IO_RETRY;
455}
456
457/*
458 * Handle unsolicited interrupts
459 */
460static int
461tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
462{
463 if (irb->scsw.dstat == DEV_STAT_CHN_END)
464 /* Probably result of halt ssch */
465 return TAPE_IO_PENDING;
466 else if (irb->scsw.dstat == 0x85)
467 /* Device Ready -> check medium state */
468 tape_3590_schedule_work(device, TO_MSEN);
469 else if (irb->scsw.dstat & DEV_STAT_ATTENTION)
470 tape_3590_schedule_work(device, TO_READ_ATTMSG);
471 else {
472 DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
473 PRINT_WARN("Unsolicited IRQ (Device End) caught.\n");
474 tape_dump_sense(device, NULL, irb);
475 }
476 return TAPE_IO_SUCCESS;
477}
478
479/*
480 * Basic Recovery routine
481 */
482static int
483tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
484 struct irb *irb, int rc)
485{
486 struct tape_3590_sense *sense;
487
488 sense = (struct tape_3590_sense *) irb->ecw;
489
490 switch (sense->bra) {
491 case SENSE_BRA_PER:
492 return tape_3590_erp_failed(device, request, irb, rc);
493 case SENSE_BRA_CONT:
494 return tape_3590_erp_succeded(device, request);
495 case SENSE_BRA_RE:
496 return tape_3590_erp_retry(device, request, irb);
497 case SENSE_BRA_DRE:
498 return tape_3590_erp_failed(device, request, irb, rc);
499 default:
500 PRINT_ERR("Unknown BRA %x - This should not happen!\n",
501 sense->bra);
502 BUG();
503 return TAPE_IO_STOP;
504 }
505}
506
507/*
508 * RDL: Read Device (buffered) log
509 */
510static int
511tape_3590_erp_read_buf_log(struct tape_device *device,
512 struct tape_request *request, struct irb *irb)
513{
514 /*
515 * We just do the basic error recovery at the moment (retry).
516 * Perhaps in the future, we read the log and dump it somewhere...
517 */
518 return tape_3590_erp_basic(device, request, irb, -EIO);
519}
520
521/*
522 * SWAP: Swap Devices
523 */
524static int
525tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
526 struct irb *irb)
527{
528 /*
529 * This error recovery should swap the tapes
530 * if the original has a problem. The operation
531 * should proceed with the new tape... this
532 * should probably be done in user space!
533 */
534 PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id);
535 return tape_3590_erp_basic(device, request, irb, -EIO);
536}
537
538/*
539 * LBY: Long Busy
540 */
541static int
542tape_3590_erp_long_busy(struct tape_device *device,
543 struct tape_request *request, struct irb *irb)
544{
545 /* FIXME: how about WAITING for a minute ? */
546 PRINT_WARN("(%s): Device is busy! Please wait a minute!\n",
547 device->cdev->dev.bus_id);
548 return tape_3590_erp_basic(device, request, irb, -EBUSY);
549}
550
551/*
552 * SPI: Special Intercept
553 */
554static int
555tape_3590_erp_special_interrupt(struct tape_device *device,
556 struct tape_request *request, struct irb *irb)
557{
558 return tape_3590_erp_basic(device, request, irb, -EIO);
559}
560
561/*
562 * RDA: Read Alternate
563 */
564static int
565tape_3590_erp_read_alternate(struct tape_device *device,
566 struct tape_request *request, struct irb *irb)
567{
568 struct tape_3590_disc_data *data;
569
570 /*
571 * The issued Read Backward or Read Previous command is not
572 * supported by the device
573 * The recovery action should be to issue another command:
574 * Read Revious: if Read Backward is not supported
575 * Read Backward: if Read Previous is not supported
576 */
577 data = device->discdata;
578 if (data->read_back_op == READ_PREVIOUS) {
579 DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
580 device->cdev_id);
581 data->read_back_op = READ_BACKWARD;
582 } else {
583 DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
584 device->cdev_id);
585 data->read_back_op = READ_PREVIOUS;
586 }
587 tape_3590_read_opposite(device, request);
588 return tape_3590_erp_retry(device, request, irb);
589}
590
591/*
592 * Error Recovery read opposite
593 */
594static int
595tape_3590_erp_read_opposite(struct tape_device *device,
596 struct tape_request *request, struct irb *irb)
597{
598 switch (request->op) {
599 case TO_RFO:
600 /*
601 * We did read forward, but the data could not be read.
602 * We will read backward and then skip forward again.
603 */
604 tape_3590_read_opposite(device, request);
605 return tape_3590_erp_retry(device, request, irb);
606 case TO_RBA:
607 /* We tried to read forward and backward, but hat no success */
608 return tape_3590_erp_failed(device, request, irb, -EIO);
609 break;
610 default:
611 PRINT_WARN("read_opposite_recovery_called_with_op: %s\n",
612 tape_op_verbose[request->op]);
613 return tape_3590_erp_failed(device, request, irb, -EIO);
614 }
615}
616
617/*
618 * Print an MIM (Media Information Message) (message code f0)
619 */
620static void
621tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
622{
623 struct tape_3590_sense *sense;
624
625 sense = (struct tape_3590_sense *) irb->ecw;
626 /* Exception Message */
627 switch (sense->fmt.f70.emc) {
628 case 0x02:
629 PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id);
630 break;
631 case 0x03:
632 PRINT_WARN("(%s): Data degraded in partion %i\n",
633 device->cdev->dev.bus_id, sense->fmt.f70.mp);
634 break;
635 case 0x04:
636 PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id);
637 break;
638 case 0x05:
639 PRINT_WARN("(%s): Medium degraded in partition %i\n",
640 device->cdev->dev.bus_id, sense->fmt.f70.mp);
641 break;
642 case 0x06:
643 PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id);
644 break;
645 case 0x07:
646 PRINT_WARN("(%s): Medium Exception 0x%02x\n",
647 device->cdev->dev.bus_id, sense->fmt.f70.md);
648 break;
649 default:
650 PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n",
651 device->cdev->dev.bus_id, sense->fmt.f70.emc);
652 break;
653 }
654 /* Service Message */
655 switch (sense->fmt.f70.smc) {
656 case 0x02:
657 PRINT_WARN("(%s): Reference Media maintenance procedure %i\n",
658 device->cdev->dev.bus_id, sense->fmt.f70.md);
659 break;
660 default:
661 PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n",
662 device->cdev->dev.bus_id, sense->fmt.f70.smc);
663 break;
664 }
665}
666
667/*
668 * Print an I/O Subsystem Service Information Message (message code f1)
669 */
670static void
671tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
672{
673 struct tape_3590_sense *sense;
674
675 sense = (struct tape_3590_sense *) irb->ecw;
676 /* Exception Message */
677 switch (sense->fmt.f71.emc) {
678 case 0x01:
679 PRINT_WARN("(%s): Effect of failure is unknown\n",
680 device->cdev->dev.bus_id);
681 break;
682 case 0x02:
683 PRINT_WARN("(%s): CU Exception - no performance impact\n",
684 device->cdev->dev.bus_id);
685 break;
686 case 0x03:
687 PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n",
688 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
689 break;
690 case 0x04:
691 PRINT_WARN("(%s): CU Exception on device path 0x%02x\n",
692 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
693 break;
694 case 0x05:
695 PRINT_WARN("(%s): CU Exception on library path 0x%02x\n",
696 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
697 break;
698 case 0x06:
699 PRINT_WARN("(%s): CU Exception on node 0x%02x\n",
700 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
701 break;
702 case 0x07:
703 PRINT_WARN("(%s): CU Exception on partition 0x%02x\n",
704 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
705 break;
706 default:
707 PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n",
708 device->cdev->dev.bus_id, sense->fmt.f71.emc);
709 }
710 /* Service Message */
711 switch (sense->fmt.f71.smc) {
712 case 0x01:
713 PRINT_WARN("(%s): Repair impact is unknown\n",
714 device->cdev->dev.bus_id);
715 break;
716 case 0x02:
717 PRINT_WARN("(%s): Repair will not impact cu performance\n",
718 device->cdev->dev.bus_id);
719 break;
720 case 0x03:
721 if (sense->fmt.f71.mdf == 0)
722 PRINT_WARN("(%s): Repair will disable node "
723 "0x%x on CU\n",
724 device->cdev->dev.bus_id,
725 sense->fmt.f71.md[1]);
726 else
727 PRINT_WARN("(%s): Repair will disable nodes "
728 "(0x%x-0x%x) on CU\n",
729 device->cdev->dev.bus_id,
730 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
731 break;
732 case 0x04:
733 if (sense->fmt.f71.mdf == 0)
734 PRINT_WARN("(%s): Repair will disable cannel path "
735 "0x%x on CU\n",
736 device->cdev->dev.bus_id,
737 sense->fmt.f71.md[1]);
738 else
739 PRINT_WARN("(%s): Repair will disable cannel paths "
740 "(0x%x-0x%x) on CU\n",
741 device->cdev->dev.bus_id,
742 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
743 break;
744 case 0x05:
745 if (sense->fmt.f71.mdf == 0)
746 PRINT_WARN("(%s): Repair will disable device path "
747 "0x%x on CU\n",
748 device->cdev->dev.bus_id,
749 sense->fmt.f71.md[1]);
750 else
751 PRINT_WARN("(%s): Repair will disable device paths "
752 "(0x%x-0x%x) on CU\n",
753 device->cdev->dev.bus_id,
754 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
755 break;
756 case 0x06:
757 if (sense->fmt.f71.mdf == 0)
758 PRINT_WARN("(%s): Repair will disable library path "
759 "0x%x on CU\n",
760 device->cdev->dev.bus_id,
761 sense->fmt.f71.md[1]);
762 else
763 PRINT_WARN("(%s): Repair will disable library paths "
764 "(0x%x-0x%x) on CU\n",
765 device->cdev->dev.bus_id,
766 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
767 break;
768 case 0x07:
769 PRINT_WARN("(%s): Repair will disable access to CU\n",
770 device->cdev->dev.bus_id);
771 break;
772 default:
773 PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n",
774 device->cdev->dev.bus_id, sense->fmt.f71.smc);
775 }
776}
777
778/*
779 * Print an Device Subsystem Service Information Message (message code f2)
780 */
781static void
782tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
783{
784 struct tape_3590_sense *sense;
785
786 sense = (struct tape_3590_sense *) irb->ecw;
787 /* Exception Message */
788 switch (sense->fmt.f71.emc) {
789 case 0x01:
790 PRINT_WARN("(%s): Effect of failure is unknown\n",
791 device->cdev->dev.bus_id);
792 break;
793 case 0x02:
794 PRINT_WARN("(%s): DV Exception - no performance impact\n",
795 device->cdev->dev.bus_id);
796 break;
797 case 0x03:
798 PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n",
799 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
800 break;
801 case 0x04:
802 PRINT_WARN("(%s): DV Exception on loader 0x%02x\n",
803 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
804 break;
805 case 0x05:
806 PRINT_WARN("(%s): DV Exception on message display 0x%02x\n",
807 device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
808 break;
809 case 0x06:
810 PRINT_WARN("(%s): DV Exception in tape path\n",
811 device->cdev->dev.bus_id);
812 break;
813 case 0x07:
814 PRINT_WARN("(%s): DV Exception in drive\n",
815 device->cdev->dev.bus_id);
816 break;
817 default:
818 PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n",
819 device->cdev->dev.bus_id, sense->fmt.f71.emc);
820 }
821 /* Service Message */
822 switch (sense->fmt.f71.smc) {
823 case 0x01:
824 PRINT_WARN("(%s): Repair impact is unknown\n",
825 device->cdev->dev.bus_id);
826 break;
827 case 0x02:
828 PRINT_WARN("(%s): Repair will not impact device performance\n",
829 device->cdev->dev.bus_id);
830 break;
831 case 0x03:
832 if (sense->fmt.f71.mdf == 0)
833 PRINT_WARN("(%s): Repair will disable channel path "
834 "0x%x on DV\n",
835 device->cdev->dev.bus_id,
836 sense->fmt.f71.md[1]);
837 else
838 PRINT_WARN("(%s): Repair will disable channel path "
839 "(0x%x-0x%x) on DV\n",
840 device->cdev->dev.bus_id,
841 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
842 break;
843 case 0x04:
844 if (sense->fmt.f71.mdf == 0)
845 PRINT_WARN("(%s): Repair will disable interface 0x%x "
846 "on DV\n",
847 device->cdev->dev.bus_id,
848 sense->fmt.f71.md[1]);
849 else
850 PRINT_WARN("(%s): Repair will disable interfaces "
851 "(0x%x-0x%x) on DV\n",
852 device->cdev->dev.bus_id,
853 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
854 break;
855 case 0x05:
856 if (sense->fmt.f71.mdf == 0)
857 PRINT_WARN("(%s): Repair will disable loader 0x%x "
858 "on DV\n",
859 device->cdev->dev.bus_id,
860 sense->fmt.f71.md[1]);
861 else
862 PRINT_WARN("(%s): Repair will disable loader "
863 "(0x%x-0x%x) on DV\n",
864 device->cdev->dev.bus_id,
865 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
866 break;
867 case 0x07:
868 PRINT_WARN("(%s): Repair will disable access to DV\n",
869 device->cdev->dev.bus_id);
870 break;
871 case 0x08:
872 if (sense->fmt.f71.mdf == 0)
873 PRINT_WARN("(%s): Repair will disable message "
874 "display 0x%x on DV\n",
875 device->cdev->dev.bus_id,
876 sense->fmt.f71.md[1]);
877 else
878 PRINT_WARN("(%s): Repair will disable message "
879 "displays (0x%x-0x%x) on DV\n",
880 device->cdev->dev.bus_id,
881 sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
882 break;
883 case 0x09:
884 PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id);
885 break;
886 default:
887 PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n",
888 device->cdev->dev.bus_id, sense->fmt.f71.smc);
889 }
890}
891
892/*
893 * Print standard ERA Message
894 */
895static void
896tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
897{
898 struct tape_3590_sense *sense;
899
900 sense = (struct tape_3590_sense *) irb->ecw;
901 if (sense->mc == 0)
902 return;
903 if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
904 if (tape_3590_msg[sense->mc] != NULL)
905 PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id,
906 tape_3590_msg[sense->mc]);
907 else {
908 PRINT_WARN("(%s): Message Code 0x%x\n",
909 device->cdev->dev.bus_id, sense->mc);
910 }
911 return;
912 }
913 if (sense->mc == 0xf0) {
914 /* Standard Media Information Message */
915 PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, "
916 "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id,
917 sense->fmt.f70.sev, sense->mc,
918 sense->fmt.f70.emc, sense->fmt.f70.smc,
919 sense->fmt.f70.refcode, sense->fmt.f70.mid,
920 sense->fmt.f70.fid);
921 tape_3590_print_mim_msg_f0(device, irb);
922 return;
923 }
924 if (sense->mc == 0xf1) {
925 /* Standard I/O Subsystem Service Information Message */
926 PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, "
927 "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
928 device->cdev->dev.bus_id, sense->fmt.f71.sev,
929 device->cdev->id.dev_model,
930 sense->mc, sense->fmt.f71.emc,
931 sense->fmt.f71.smc, sense->fmt.f71.refcode1,
932 sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
933 tape_3590_print_io_sim_msg_f1(device, irb);
934 return;
935 }
936 if (sense->mc == 0xf2) {
937 /* Standard Device Service Information Message */
938 PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, "
939 "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
940 device->cdev->dev.bus_id, sense->fmt.f71.sev,
941 device->cdev->id.dev_model,
942 sense->mc, sense->fmt.f71.emc,
943 sense->fmt.f71.smc, sense->fmt.f71.refcode1,
944 sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
945 tape_3590_print_dev_sim_msg_f2(device, irb);
946 return;
947 }
948 if (sense->mc == 0xf3) {
949 /* Standard Library Service Information Message */
950 return;
951 }
952 PRINT_WARN("(%s): Device Message(%x)\n",
953 device->cdev->dev.bus_id, sense->mc);
954}
955
956/*
957 * 3590 error Recovery routine:
958 * If possible, it tries to recover from the error. If this is not possible,
959 * inform the user about the problem.
960 */
961static int
962tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
963 struct irb *irb)
964{
965 struct tape_3590_sense *sense;
966 int rc;
967
968#ifdef CONFIG_S390_TAPE_BLOCK
969 if (request->op == TO_BLOCK) {
970 /*
971 * Recovery for block device requests. Set the block_position
972 * to something invalid and retry.
973 */
974 device->blk_data.block_position = -1;
975 if (request->retries-- <= 0)
976 return tape_3590_erp_failed(device, request, irb, -EIO);
977 else
978 return tape_3590_erp_retry(device, request, irb);
979 }
980#endif
981
982 sense = (struct tape_3590_sense *) irb->ecw;
983
984 /*
985 * First check all RC-QRCs where we want to do something special
986 * - "break": basic error recovery is done
987 * - "goto out:": just print error message if available
988 */
989 rc = -EIO;
990 switch (sense->rc_rqc) {
991
992 case 0x1110:
993 tape_3590_print_era_msg(device, irb);
994 return tape_3590_erp_read_buf_log(device, request, irb);
995
996 case 0x2011:
997 tape_3590_print_era_msg(device, irb);
998 return tape_3590_erp_read_alternate(device, request, irb);
999
1000 case 0x2230:
1001 case 0x2231:
1002 tape_3590_print_era_msg(device, irb);
1003 return tape_3590_erp_special_interrupt(device, request, irb);
1004
1005 case 0x3010:
1006 DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
1007 device->cdev_id);
1008 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1009 case 0x3012:
1010 DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
1011 device->cdev_id);
1012 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1013 case 0x3020:
1014 DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
1015 return tape_3590_erp_basic(device, request, irb, -ENOSPC);
1016
1017 case 0x3122:
1018 DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
1019 device->cdev_id);
1020 return tape_3590_erp_basic(device, request, irb, -EIO);
1021 case 0x3123:
1022 DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
1023 device->cdev_id);
1024 tape_med_state_set(device, MS_UNLOADED);
1025 return tape_3590_erp_basic(device, request, irb, 0);
1026
1027 case 0x4010:
1028 /*
1029 * print additional msg since default msg
1030 * "device intervention" is not very meaningfull
1031 */
1032 PRINT_WARN("(%s): Tape operation when medium not loaded\n",
1033 device->cdev->dev.bus_id);
1034 tape_med_state_set(device, MS_UNLOADED);
1035 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1036 case 0x4012: /* Device Long Busy */
1037 tape_3590_print_era_msg(device, irb);
1038 return tape_3590_erp_long_busy(device, request, irb);
1039
1040 case 0x5010:
1041 if (sense->rac == 0xd0) {
1042 /* Swap */
1043 tape_3590_print_era_msg(device, irb);
1044 return tape_3590_erp_swap(device, request, irb);
1045 }
1046 if (sense->rac == 0x26) {
1047 /* Read Opposite */
1048 tape_3590_print_era_msg(device, irb);
1049 return tape_3590_erp_read_opposite(device, request,
1050 irb);
1051 }
1052 return tape_3590_erp_basic(device, request, irb, -EIO);
1053 case 0x5020:
1054 case 0x5021:
1055 case 0x5022:
1056 case 0x5040:
1057 case 0x5041:
1058 case 0x5042:
1059 tape_3590_print_era_msg(device, irb);
1060 return tape_3590_erp_swap(device, request, irb);
1061
1062 case 0x5110:
1063 case 0x5111:
1064 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1065
1066 case 0x5120:
1067 case 0x1120:
1068 tape_med_state_set(device, MS_UNLOADED);
1069 return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
1070
1071 case 0x6020:
1072 PRINT_WARN("(%s): Cartridge of wrong type ?\n",
1073 device->cdev->dev.bus_id);
1074 return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
1075
1076 case 0x8011:
1077 PRINT_WARN("(%s): Another host has reserved the tape device\n",
1078 device->cdev->dev.bus_id);
1079 return tape_3590_erp_basic(device, request, irb, -EPERM);
1080 case 0x8013:
1081 PRINT_WARN("(%s): Another host has priviliged access to the "
1082 "tape device\n", device->cdev->dev.bus_id);
1083 PRINT_WARN("(%s): To solve the problem unload the current "
1084 "cartridge!\n", device->cdev->dev.bus_id);
1085 return tape_3590_erp_basic(device, request, irb, -EPERM);
1086 default:
1087 return tape_3590_erp_basic(device, request, irb, -EIO);
1088 }
1089}
1090
1091/*
1092 * 3590 interrupt handler:
1093 */
1094static int
1095tape_3590_irq(struct tape_device *device, struct tape_request *request,
1096 struct irb *irb)
1097{
1098 if (request == NULL)
1099 return tape_3590_unsolicited_irq(device, irb);
1100
1101 if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) &&
1102 (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) {
1103 /* Write at end of volume */
1104 DBF_EVENT(2, "End of volume\n");
1105 return tape_3590_erp_failed(device, request, irb, -ENOSPC);
1106 }
1107
1108 if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
1109 return tape_3590_unit_check(device, request, irb);
1110
1111 if (irb->scsw.dstat & DEV_STAT_DEV_END) {
1112 if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) {
1113 if (request->op == TO_FSB || request->op == TO_BSB)
1114 request->rescnt++;
1115 else
1116 DBF_EVENT(5, "Unit Exception!\n");
1117 }
1118
1119 return tape_3590_done(device, request);
1120 }
1121
1122 if (irb->scsw.dstat & DEV_STAT_CHN_END) {
1123 DBF_EVENT(2, "cannel end\n");
1124 return TAPE_IO_PENDING;
1125 }
1126
1127 if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
1128 DBF_EVENT(2, "Unit Attention when busy..\n");
1129 return TAPE_IO_PENDING;
1130 }
1131
1132 DBF_EVENT(6, "xunknownirq\n");
1133 PRINT_ERR("Unexpected interrupt.\n");
1134 PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]);
1135 tape_dump_sense(device, request, irb);
1136 return TAPE_IO_STOP;
1137}
1138
1139/*
1140 * Setup device function
1141 */
1142static int
1143tape_3590_setup_device(struct tape_device *device)
1144{
1145 int rc;
1146 struct tape_3590_disc_data *data;
1147
1148 DBF_EVENT(6, "3590 device setup\n");
1149 data = kmalloc(sizeof(struct tape_3590_disc_data),
1150 GFP_KERNEL | GFP_DMA);
1151 if (data == NULL)
1152 return -ENOMEM;
1153 data->read_back_op = READ_PREVIOUS;
1154 device->discdata = data;
1155
1156 if ((rc = tape_std_assign(device)) == 0) {
1157 /* Try to find out if medium is loaded */
1158 if ((rc = tape_3590_sense_medium(device)) != 0)
1159 DBF_LH(3, "3590 medium sense returned %d\n", rc);
1160 }
1161
1162 return rc;
1163}
1164
1165/*
1166 * Cleanup device function
1167 */
1168static void
1169tape_3590_cleanup_device(struct tape_device *device)
1170{
1171 tape_std_unassign(device);
1172
1173 kfree(device->discdata);
1174 device->discdata = NULL;
1175}
1176
1177/*
1178 * List of 3590 magnetic tape commands.
1179 */
1180static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
1181 [MTRESET] = tape_std_mtreset,
1182 [MTFSF] = tape_std_mtfsf,
1183 [MTBSF] = tape_std_mtbsf,
1184 [MTFSR] = tape_std_mtfsr,
1185 [MTBSR] = tape_std_mtbsr,
1186 [MTWEOF] = tape_std_mtweof,
1187 [MTREW] = tape_std_mtrew,
1188 [MTOFFL] = tape_std_mtoffl,
1189 [MTNOP] = tape_std_mtnop,
1190 [MTRETEN] = tape_std_mtreten,
1191 [MTBSFM] = tape_std_mtbsfm,
1192 [MTFSFM] = tape_std_mtfsfm,
1193 [MTEOM] = tape_std_mteom,
1194 [MTERASE] = tape_std_mterase,
1195 [MTRAS1] = NULL,
1196 [MTRAS2] = NULL,
1197 [MTRAS3] = NULL,
1198 [MTSETBLK] = tape_std_mtsetblk,
1199 [MTSETDENSITY] = NULL,
1200 [MTSEEK] = tape_3590_mtseek,
1201 [MTTELL] = tape_3590_mttell,
1202 [MTSETDRVBUFFER] = NULL,
1203 [MTFSS] = NULL,
1204 [MTBSS] = NULL,
1205 [MTWSM] = NULL,
1206 [MTLOCK] = NULL,
1207 [MTUNLOCK] = NULL,
1208 [MTLOAD] = tape_std_mtload,
1209 [MTUNLOAD] = tape_std_mtunload,
1210 [MTCOMPRESSION] = tape_std_mtcompression,
1211 [MTSETPART] = NULL,
1212 [MTMKPART] = NULL
1213};
1214
1215/*
1216 * Tape discipline structure for 3590.
1217 */
1218static struct tape_discipline tape_discipline_3590 = {
1219 .owner = THIS_MODULE,
1220 .setup_device = tape_3590_setup_device,
1221 .cleanup_device = tape_3590_cleanup_device,
1222 .process_eov = tape_std_process_eov,
1223 .irq = tape_3590_irq,
1224 .read_block = tape_std_read_block,
1225 .write_block = tape_std_write_block,
1226#ifdef CONFIG_S390_TAPE_BLOCK
1227 .bread = tape_3590_bread,
1228 .free_bread = tape_3590_free_bread,
1229 .check_locate = tape_3590_check_locate,
1230#endif
1231 .ioctl_fn = tape_3590_ioctl,
1232 .mtop_array = tape_3590_mtop
1233};
1234
1235static struct ccw_device_id tape_3590_ids[] = {
1236 {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
1237 { /* end of list */ }
1238};
1239
1240static int
1241tape_3590_online(struct ccw_device *cdev)
1242{
1243 return tape_generic_online(cdev->dev.driver_data,
1244 &tape_discipline_3590);
1245}
1246
1247static int
1248tape_3590_offline(struct ccw_device *cdev)
1249{
1250 return tape_generic_offline(cdev->dev.driver_data);
1251}
1252
1253static struct ccw_driver tape_3590_driver = {
1254 .name = "tape_3590",
1255 .owner = THIS_MODULE,
1256 .ids = tape_3590_ids,
1257 .probe = tape_generic_probe,
1258 .remove = tape_generic_remove,
1259 .set_offline = tape_3590_offline,
1260 .set_online = tape_3590_online,
1261};
1262
1263/*
1264 * Setup discipline structure.
1265 */
1266static int
1267tape_3590_init(void)
1268{
1269 int rc;
1270
1271 TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
1272 debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
1273#ifdef DBF_LIKE_HELL
1274 debug_set_level(TAPE_DBF_AREA, 6);
1275#endif
1276
1277 DBF_EVENT(3, "3590 init\n");
1278 /* Register driver for 3590 tapes. */
1279 rc = ccw_driver_register(&tape_3590_driver);
1280 if (rc)
1281 DBF_EVENT(3, "3590 init failed\n");
1282 else
1283 DBF_EVENT(3, "3590 registered\n");
1284 return rc;
1285}
1286
1287static void
1288tape_3590_exit(void)
1289{
1290 ccw_driver_unregister(&tape_3590_driver);
1291
1292 debug_unregister(TAPE_DBF_AREA);
1293}
1294
1295MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
1296MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
1297MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
1298MODULE_LICENSE("GPL");
1299
1300module_init(tape_3590_init);
1301module_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 000000000000..cf274b9445a6
--- /dev/null
+++ b/drivers/s390/char/tape_3590.h
@@ -0,0 +1,124 @@
1/*
2 * drivers/s390/char/tape_3590.h
3 * tape device discipline for 3590 tapes.
4 *
5 * Copyright (C) IBM Corp. 2001,2006
6 * Author(s): Stefan Bader <shbader@de.ibm.com>
7 * Michael Holzheu <holzheu@de.ibm.com>
8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
9 */
10
11#ifndef _TAPE_3590_H
12#define _TAPE_3590_H
13
14#define MEDIUM_SENSE 0xc2
15#define READ_PREVIOUS 0x0a
16#define MODE_SENSE 0xcf
17#define PERFORM_SS_FUNC 0x77
18#define READ_SS_DATA 0x3e
19
20#define PREP_RD_SS_DATA 0x18
21#define RD_ATTMSG 0x3
22
23#define SENSE_BRA_PER 0
24#define SENSE_BRA_CONT 1
25#define SENSE_BRA_RE 2
26#define SENSE_BRA_DRE 3
27
28#define SENSE_FMT_LIBRARY 0x23
29#define SENSE_FMT_UNSOLICITED 0x40
30#define SENSE_FMT_COMMAND_REJ 0x41
31#define SENSE_FMT_COMMAND_EXEC0 0x50
32#define SENSE_FMT_COMMAND_EXEC1 0x51
33#define SENSE_FMT_EVENT0 0x60
34#define SENSE_FMT_EVENT1 0x61
35#define SENSE_FMT_MIM 0x70
36#define SENSE_FMT_SIM 0x71
37
38#define MSENSE_UNASSOCIATED 0x00
39#define MSENSE_ASSOCIATED_MOUNT 0x01
40#define MSENSE_ASSOCIATED_UMOUNT 0x02
41
42#define TAPE_3590_MAX_MSG 0xb0
43
44/* Datatypes */
45
46struct tape_3590_disc_data {
47 unsigned char modeset_byte;
48 int read_back_op;
49};
50
51struct tape_3590_sense {
52
53 unsigned int command_rej:1;
54 unsigned int interv_req:1;
55 unsigned int bus_out_check:1;
56 unsigned int eq_check:1;
57 unsigned int data_check:1;
58 unsigned int overrun:1;
59 unsigned int def_unit_check:1;
60 unsigned int assgnd_elsew:1;
61
62 unsigned int locate_fail:1;
63 unsigned int inst_online:1;
64 unsigned int reserved:1;
65 unsigned int blk_seq_err:1;
66 unsigned int begin_part:1;
67 unsigned int wr_mode:1;
68 unsigned int wr_prot:1;
69 unsigned int not_cap:1;
70
71 unsigned int bra:2;
72 unsigned int lc:3;
73 unsigned int vlf_active:1;
74 unsigned int stm:1;
75 unsigned int med_pos:1;
76
77 unsigned int rac:8;
78
79 unsigned int rc_rqc:16;
80
81 unsigned int mc:8;
82
83 unsigned int sense_fmt:8;
84
85 union {
86 struct {
87 unsigned int emc:4;
88 unsigned int smc:4;
89 unsigned int sev:2;
90 unsigned int reserved:6;
91 unsigned int md:8;
92 unsigned int refcode:8;
93 unsigned int mid:16;
94 unsigned int mp:16;
95 unsigned char volid[6];
96 unsigned int fid:8;
97 } f70;
98 struct {
99 unsigned int emc:4;
100 unsigned int smc:4;
101 unsigned int sev:2;
102 unsigned int reserved1:5;
103 unsigned int mdf:1;
104 unsigned char md[3];
105 unsigned int simid:8;
106 unsigned int uid:16;
107 unsigned int refcode1:16;
108 unsigned int refcode2:16;
109 unsigned int refcode3:16;
110 unsigned int reserved2:8;
111 } f71;
112 unsigned char data[14];
113 } fmt;
114 unsigned char pad[10];
115
116} __attribute__ ((packed));
117
118struct tape_3590_med_sense {
119 unsigned int macst:4;
120 unsigned int masst:4;
121 char pad[127];
122} __attribute__ ((packed));
123
124#endif /* _TAPE_3590_H */
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index b3569c82bb16..a5c68e60fcf4 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(
44 int rc; 44 int rc;
45 char * s; 45 char * s;
46 46
47 tcd = kmalloc(sizeof(struct tape_class_device), GFP_KERNEL); 47 tcd = kzalloc(sizeof(struct tape_class_device), GFP_KERNEL);
48 if (!tcd) 48 if (!tcd)
49 return ERR_PTR(-ENOMEM); 49 return ERR_PTR(-ENOMEM);
50 50
51 memset(tcd, 0, sizeof(struct tape_class_device));
52 strncpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN); 51 strncpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN);
53 for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/')) 52 for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/'))
54 *s = '!'; 53 *s = '!';
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 4ea438c749c9..389ee2c0f443 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -453,16 +453,14 @@ tape_alloc_device(void)
453{ 453{
454 struct tape_device *device; 454 struct tape_device *device;
455 455
456 device = (struct tape_device *) 456 device = kzalloc(sizeof(struct tape_device), GFP_KERNEL);
457 kmalloc(sizeof(struct tape_device), GFP_KERNEL);
458 if (device == NULL) { 457 if (device == NULL) {
459 DBF_EXCEPTION(2, "ti:no mem\n"); 458 DBF_EXCEPTION(2, "ti:no mem\n");
460 PRINT_INFO ("can't allocate memory for " 459 PRINT_INFO ("can't allocate memory for "
461 "tape info structure\n"); 460 "tape info structure\n");
462 return ERR_PTR(-ENOMEM); 461 return ERR_PTR(-ENOMEM);
463 } 462 }
464 memset(device, 0, sizeof(struct tape_device)); 463 device->modeset_byte = kmalloc(1, GFP_KERNEL | GFP_DMA);
465 device->modeset_byte = (char *) kmalloc(1, GFP_KERNEL | GFP_DMA);
466 if (device->modeset_byte == NULL) { 464 if (device->modeset_byte == NULL) {
467 DBF_EXCEPTION(2, "ti:no mem\n"); 465 DBF_EXCEPTION(2, "ti:no mem\n");
468 PRINT_INFO("can't allocate memory for modeset byte\n"); 466 PRINT_INFO("can't allocate memory for modeset byte\n");
@@ -659,34 +657,30 @@ tape_alloc_request(int cplength, int datasize)
659 657
660 DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize); 658 DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize);
661 659
662 request = (struct tape_request *) kmalloc(sizeof(struct tape_request), 660 request = kzalloc(sizeof(struct tape_request), GFP_KERNEL);
663 GFP_KERNEL);
664 if (request == NULL) { 661 if (request == NULL) {
665 DBF_EXCEPTION(1, "cqra nomem\n"); 662 DBF_EXCEPTION(1, "cqra nomem\n");
666 return ERR_PTR(-ENOMEM); 663 return ERR_PTR(-ENOMEM);
667 } 664 }
668 memset(request, 0, sizeof(struct tape_request));
669 /* allocate channel program */ 665 /* allocate channel program */
670 if (cplength > 0) { 666 if (cplength > 0) {
671 request->cpaddr = kmalloc(cplength*sizeof(struct ccw1), 667 request->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
672 GFP_ATOMIC | GFP_DMA); 668 GFP_ATOMIC | GFP_DMA);
673 if (request->cpaddr == NULL) { 669 if (request->cpaddr == NULL) {
674 DBF_EXCEPTION(1, "cqra nomem\n"); 670 DBF_EXCEPTION(1, "cqra nomem\n");
675 kfree(request); 671 kfree(request);
676 return ERR_PTR(-ENOMEM); 672 return ERR_PTR(-ENOMEM);
677 } 673 }
678 memset(request->cpaddr, 0, cplength*sizeof(struct ccw1));
679 } 674 }
680 /* alloc small kernel buffer */ 675 /* alloc small kernel buffer */
681 if (datasize > 0) { 676 if (datasize > 0) {
682 request->cpdata = kmalloc(datasize, GFP_KERNEL | GFP_DMA); 677 request->cpdata = kzalloc(datasize, GFP_KERNEL | GFP_DMA);
683 if (request->cpdata == NULL) { 678 if (request->cpdata == NULL) {
684 DBF_EXCEPTION(1, "cqra nomem\n"); 679 DBF_EXCEPTION(1, "cqra nomem\n");
685 kfree(request->cpaddr); 680 kfree(request->cpaddr);
686 kfree(request); 681 kfree(request);
687 return ERR_PTR(-ENOMEM); 682 return ERR_PTR(-ENOMEM);
688 } 683 }
689 memset(request->cpdata, 0, datasize);
690 } 684 }
691 DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr, 685 DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr,
692 request->cpdata); 686 request->cpdata);
@@ -761,6 +755,13 @@ __tape_start_next_request(struct tape_device *device)
761 */ 755 */
762 if (request->status == TAPE_REQUEST_IN_IO) 756 if (request->status == TAPE_REQUEST_IN_IO)
763 return; 757 return;
758 /*
759 * Request has already been stopped. We have to wait until
760 * the request is removed from the queue in the interrupt
761 * handling.
762 */
763 if (request->status == TAPE_REQUEST_DONE)
764 return;
764 765
765 /* 766 /*
766 * We wanted to cancel the request but the common I/O layer 767 * We wanted to cancel the request but the common I/O layer
@@ -1015,7 +1016,7 @@ tape_do_io_interruptible(struct tape_device *device,
1015 wq, 1016 wq,
1016 (request->callback == NULL) 1017 (request->callback == NULL)
1017 ); 1018 );
1018 } while (rc != -ERESTARTSYS); 1019 } while (rc == -ERESTARTSYS);
1019 1020
1020 DBF_EVENT(3, "IO stopped on %08x\n", device->cdev_id); 1021 DBF_EVENT(3, "IO stopped on %08x\n", device->cdev_id);
1021 rc = -ERESTARTSYS; 1022 rc = -ERESTARTSYS;
@@ -1024,6 +1025,20 @@ tape_do_io_interruptible(struct tape_device *device,
1024} 1025}
1025 1026
1026/* 1027/*
1028 * Stop running ccw.
1029 */
1030int
1031tape_cancel_io(struct tape_device *device, struct tape_request *request)
1032{
1033 int rc;
1034
1035 spin_lock_irq(get_ccwdev_lock(device->cdev));
1036 rc = __tape_cancel_io(device, request);
1037 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1038 return rc;
1039}
1040
1041/*
1027 * Tape interrupt routine, called from the ccw_device layer 1042 * Tape interrupt routine, called from the ccw_device layer
1028 */ 1043 */
1029static void 1044static void
@@ -1064,15 +1079,16 @@ __tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1064 /* 1079 /*
1065 * If the condition code is not zero and the start function bit is 1080 * If the condition code is not zero and the start function bit is
1066 * still set, this is an deferred error and the last start I/O did 1081 * still set, this is an deferred error and the last start I/O did
1067 * not succeed. Restart the request now. 1082 * not succeed. At this point the condition that caused the deferred
1083 * error might still apply. So we just schedule the request to be
1084 * started later.
1068 */ 1085 */
1069 if (irb->scsw.cc != 0 && (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) { 1086 if (irb->scsw.cc != 0 && (irb->scsw.fctl & SCSW_FCTL_START_FUNC) &&
1070 PRINT_WARN("(%s): deferred cc=%i. restaring\n", 1087 (request->status == TAPE_REQUEST_IN_IO)) {
1071 cdev->dev.bus_id, 1088 DBF_EVENT(3,"(%08x): deferred cc=%i, fctl=%i. restarting\n",
1072 irb->scsw.cc); 1089 device->cdev_id, irb->scsw.cc, irb->scsw.fctl);
1073 rc = __tape_start_io(device, request); 1090 request->status = TAPE_REQUEST_QUEUED;
1074 if (rc) 1091 schedule_delayed_work(&device->tape_dnr, HZ);
1075 __tape_end_request(device, request, rc);
1076 return; 1092 return;
1077 } 1093 }
1078 1094
@@ -1286,4 +1302,5 @@ EXPORT_SYMBOL(tape_dump_sense_dbf);
1286EXPORT_SYMBOL(tape_do_io); 1302EXPORT_SYMBOL(tape_do_io);
1287EXPORT_SYMBOL(tape_do_io_async); 1303EXPORT_SYMBOL(tape_do_io_async);
1288EXPORT_SYMBOL(tape_do_io_interruptible); 1304EXPORT_SYMBOL(tape_do_io_interruptible);
1305EXPORT_SYMBOL(tape_cancel_io);
1289EXPORT_SYMBOL(tape_mtop); 1306EXPORT_SYMBOL(tape_mtop);
diff --git a/drivers/s390/char/tape_std.c b/drivers/s390/char/tape_std.c
index 2f9fe30989a7..99cf881f41db 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)
37{ 37{
38 struct tape_request * request; 38 struct tape_request * request;
39 struct tape_device * device; 39 struct tape_device * device;
40 int rc;
40 41
41 request = (struct tape_request *) data; 42 request = (struct tape_request *) data;
42 if ((device = request->device) == NULL) 43 if ((device = request->device) == NULL)
43 BUG(); 44 BUG();
44 45
45 spin_lock_irq(get_ccwdev_lock(device->cdev)); 46 DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
46 if (request->callback != NULL) {
47 DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
48 device->cdev_id); 47 device->cdev_id);
49 PRINT_ERR("%s: Assignment timeout. Device busy.\n", 48 rc = tape_cancel_io(device, request);
50 device->cdev->dev.bus_id); 49 if(rc)
51 ccw_device_clear(device->cdev, (long) request); 50 PRINT_ERR("(%s): Assign timeout: Cancel failed with rc = %i\n",
52 } 51 device->cdev->dev.bus_id, rc);
53 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 52
54} 53}
55 54
56int 55int
diff --git a/drivers/s390/char/tape_std.h b/drivers/s390/char/tape_std.h
index 3ab6aafb7343..2d311798edf4 100644
--- a/drivers/s390/char/tape_std.h
+++ b/drivers/s390/char/tape_std.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * drivers/s390/char/tape_34xx.h 2 * drivers/s390/char/tape_std.h
3 * standard tape device functions for ibm tapes. 3 * standard tape device functions for ibm tapes.
4 * 4 *
5 * S390 and zSeries version 5 * Copyright (C) IBM Corp. 2001,2006
6 * Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Carsten Otte <cotte@de.ibm.com> 6 * Author(s): Carsten Otte <cotte@de.ibm.com>
8 * Tuan Ngo-Anh <ngoanh@de.ibm.com> 7 * Tuan Ngo-Anh <ngoanh@de.ibm.com>
9 * Martin Schwidefsky <schwidefsky@de.ibm.com> 8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -149,4 +148,11 @@ void tape_std_error_recovery_do_retry(struct tape_device *);
149void tape_std_error_recovery_read_opposite(struct tape_device *); 148void tape_std_error_recovery_read_opposite(struct tape_device *);
150void tape_std_error_recovery_HWBUG(struct tape_device *, int condno); 149void tape_std_error_recovery_HWBUG(struct tape_device *, int condno);
151 150
151/* S390 tape types */
152enum s390_tape_type {
153 tape_3480,
154 tape_3490,
155 tape_3590,
156};
157
152#endif // _TAPE_STD_H 158#endif // _TAPE_STD_H
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 4b9069370388..9a141776873f 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -691,10 +691,9 @@ tty3270_alloc_view(void)
691 struct tty3270 *tp; 691 struct tty3270 *tp;
692 int pages; 692 int pages;
693 693
694 tp = kmalloc(sizeof(struct tty3270),GFP_KERNEL); 694 tp = kzalloc(sizeof(struct tty3270), GFP_KERNEL);
695 if (!tp) 695 if (!tp)
696 goto out_err; 696 goto out_err;
697 memset(tp, 0, sizeof(struct tty3270));
698 tp->freemem_pages = 697 tp->freemem_pages =
699 kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL); 698 kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL);
700 if (!tp->freemem_pages) 699 if (!tp->freemem_pages)
@@ -767,16 +766,14 @@ tty3270_alloc_screen(struct tty3270 *tp)
767 int lines; 766 int lines;
768 767
769 size = sizeof(struct tty3270_line) * (tp->view.rows - 2); 768 size = sizeof(struct tty3270_line) * (tp->view.rows - 2);
770 tp->screen = kmalloc(size, GFP_KERNEL); 769 tp->screen = kzalloc(size, GFP_KERNEL);
771 if (!tp->screen) 770 if (!tp->screen)
772 goto out_err; 771 goto out_err;
773 memset(tp->screen, 0, size);
774 for (lines = 0; lines < tp->view.rows - 2; lines++) { 772 for (lines = 0; lines < tp->view.rows - 2; lines++) {
775 size = sizeof(struct tty3270_cell) * tp->view.cols; 773 size = sizeof(struct tty3270_cell) * tp->view.cols;
776 tp->screen[lines].cells = kmalloc(size, GFP_KERNEL); 774 tp->screen[lines].cells = kzalloc(size, GFP_KERNEL);
777 if (!tp->screen[lines].cells) 775 if (!tp->screen[lines].cells)
778 goto out_screen; 776 goto out_screen;
779 memset(tp->screen[lines].cells, 0, size);
780 } 777 }
781 return 0; 778 return 0;
782out_screen: 779out_screen:
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index b2d75de144c6..c625b69ebd19 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) {
759 struct device *dev; 759 struct device *dev;
760 int ret; 760 int ret;
761 761
762 dev = kmalloc(sizeof(struct device), GFP_KERNEL); 762 dev = kzalloc(sizeof(struct device), GFP_KERNEL);
763 if (dev) { 763 if (dev) {
764 memset(dev, 0, sizeof(struct device));
765 snprintf(dev->bus_id, BUS_ID_SIZE, "%s", 764 snprintf(dev->bus_id, BUS_ID_SIZE, "%s",
766 priv->internal_name); 765 priv->internal_name);
767 dev->bus = &iucv_bus; 766 dev->bus = &iucv_bus;
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 8013c8eb76fe..bdfee7fbaa2e 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -157,11 +157,10 @@ ccwgroup_create(struct device *root,
157 if (argc > 256) /* disallow dumb users */ 157 if (argc > 256) /* disallow dumb users */
158 return -EINVAL; 158 return -EINVAL;
159 159
160 gdev = kmalloc(sizeof(*gdev) + argc*sizeof(gdev->cdev[0]), GFP_KERNEL); 160 gdev = kzalloc(sizeof(*gdev) + argc*sizeof(gdev->cdev[0]), GFP_KERNEL);
161 if (!gdev) 161 if (!gdev)
162 return -ENOMEM; 162 return -ENOMEM;
163 163
164 memset(gdev, 0, sizeof(*gdev) + argc*sizeof(gdev->cdev[0]));
165 atomic_set(&gdev->onoff, 0); 164 atomic_set(&gdev->onoff, 0);
166 165
167 del_drvdata = 0; 166 del_drvdata = 0;
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index f4183d660258..6412b2c3edd3 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)
98 98
99 ssd_area = page; 99 ssd_area = page;
100 100
101 ssd_area->request = (struct chsc_header) { 101 ssd_area->request.length = 0x0010;
102 .length = 0x0010, 102 ssd_area->request.code = 0x0004;
103 .code = 0x0004,
104 };
105 103
106 ssd_area->ssid = sch->schid.ssid; 104 ssd_area->ssid = sch->schid.ssid;
107 ssd_area->f_sch = sch->schid.sch_no; 105 ssd_area->f_sch = sch->schid.sch_no;
@@ -517,10 +515,8 @@ chsc_process_crw(void)
517 struct device *dev; 515 struct device *dev;
518 memset(sei_area, 0, sizeof(*sei_area)); 516 memset(sei_area, 0, sizeof(*sei_area));
519 memset(&res_data, 0, sizeof(struct res_acc_data)); 517 memset(&res_data, 0, sizeof(struct res_acc_data));
520 sei_area->request = (struct chsc_header) { 518 sei_area->request.length = 0x0010;
521 .length = 0x0010, 519 sei_area->request.code = 0x000e;
522 .code = 0x000e,
523 };
524 520
525 ccode = chsc(sei_area); 521 ccode = chsc(sei_area);
526 if (ccode > 0) 522 if (ccode > 0)
@@ -875,6 +871,264 @@ s390_vary_chpid( __u8 chpid, int on)
875} 871}
876 872
877/* 873/*
874 * Channel measurement related functions
875 */
876static ssize_t
877chp_measurement_chars_read(struct kobject *kobj, char *buf, loff_t off,
878 size_t count)
879{
880 struct channel_path *chp;
881 unsigned int size;
882
883 chp = to_channelpath(container_of(kobj, struct device, kobj));
884 if (!chp->cmg_chars)
885 return 0;
886
887 size = sizeof(struct cmg_chars);
888
889 if (off > size)
890 return 0;
891 if (off + count > size)
892 count = size - off;
893 memcpy(buf, chp->cmg_chars + off, count);
894 return count;
895}
896
897static struct bin_attribute chp_measurement_chars_attr = {
898 .attr = {
899 .name = "measurement_chars",
900 .mode = S_IRUSR,
901 .owner = THIS_MODULE,
902 },
903 .size = sizeof(struct cmg_chars),
904 .read = chp_measurement_chars_read,
905};
906
907static void
908chp_measurement_copy_block(struct cmg_entry *buf,
909 struct channel_subsystem *css, int chpid)
910{
911 void *area;
912 struct cmg_entry *entry, reference_buf;
913 int idx;
914
915 if (chpid < 128) {
916 area = css->cub_addr1;
917 idx = chpid;
918 } else {
919 area = css->cub_addr2;
920 idx = chpid - 128;
921 }
922 entry = area + (idx * sizeof(struct cmg_entry));
923 do {
924 memcpy(buf, entry, sizeof(*entry));
925 memcpy(&reference_buf, entry, sizeof(*entry));
926 } while (reference_buf.values[0] != buf->values[0]);
927}
928
929static ssize_t
930chp_measurement_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
931{
932 struct channel_path *chp;
933 struct channel_subsystem *css;
934 unsigned int size;
935
936 chp = to_channelpath(container_of(kobj, struct device, kobj));
937 css = to_css(chp->dev.parent);
938
939 size = sizeof(struct cmg_chars);
940
941 /* Only allow single reads. */
942 if (off || count < size)
943 return 0;
944 chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->id);
945 return count;
946}
947
948static struct bin_attribute chp_measurement_attr = {
949 .attr = {
950 .name = "measurement",
951 .mode = S_IRUSR,
952 .owner = THIS_MODULE,
953 },
954 .size = sizeof(struct cmg_entry),
955 .read = chp_measurement_read,
956};
957
958static void
959chsc_remove_chp_cmg_attr(struct channel_path *chp)
960{
961 sysfs_remove_bin_file(&chp->dev.kobj, &chp_measurement_chars_attr);
962 sysfs_remove_bin_file(&chp->dev.kobj, &chp_measurement_attr);
963}
964
965static int
966chsc_add_chp_cmg_attr(struct channel_path *chp)
967{
968 int ret;
969
970 ret = sysfs_create_bin_file(&chp->dev.kobj,
971 &chp_measurement_chars_attr);
972 if (ret)
973 return ret;
974 ret = sysfs_create_bin_file(&chp->dev.kobj, &chp_measurement_attr);
975 if (ret)
976 sysfs_remove_bin_file(&chp->dev.kobj,
977 &chp_measurement_chars_attr);
978 return ret;
979}
980
981static void
982chsc_remove_cmg_attr(struct channel_subsystem *css)
983{
984 int i;
985
986 for (i = 0; i <= __MAX_CHPID; i++) {
987 if (!css->chps[i])
988 continue;
989 chsc_remove_chp_cmg_attr(css->chps[i]);
990 }
991}
992
993static int
994chsc_add_cmg_attr(struct channel_subsystem *css)
995{
996 int i, ret;
997
998 ret = 0;
999 for (i = 0; i <= __MAX_CHPID; i++) {
1000 if (!css->chps[i])
1001 continue;
1002 ret = chsc_add_chp_cmg_attr(css->chps[i]);
1003 if (ret)
1004 goto cleanup;
1005 }
1006 return ret;
1007cleanup:
1008 for (--i; i >= 0; i--) {
1009 if (!css->chps[i])
1010 continue;
1011 chsc_remove_chp_cmg_attr(css->chps[i]);
1012 }
1013 return ret;
1014}
1015
1016
1017static int
1018__chsc_do_secm(struct channel_subsystem *css, int enable, void *page)
1019{
1020 struct {
1021 struct chsc_header request;
1022 u32 operation_code : 2;
1023 u32 : 30;
1024 u32 key : 4;
1025 u32 : 28;
1026 u32 zeroes1;
1027 u32 cub_addr1;
1028 u32 zeroes2;
1029 u32 cub_addr2;
1030 u32 reserved[13];
1031 struct chsc_header response;
1032 u32 status : 8;
1033 u32 : 4;
1034 u32 fmt : 4;
1035 u32 : 16;
1036 } *secm_area;
1037 int ret, ccode;
1038
1039 secm_area = page;
1040 secm_area->request.length = 0x0050;
1041 secm_area->request.code = 0x0016;
1042
1043 secm_area->key = PAGE_DEFAULT_KEY;
1044 secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1;
1045 secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2;
1046
1047 secm_area->operation_code = enable ? 0 : 1;
1048
1049 ccode = chsc(secm_area);
1050 if (ccode > 0)
1051 return (ccode == 3) ? -ENODEV : -EBUSY;
1052
1053 switch (secm_area->response.code) {
1054 case 0x0001: /* Success. */
1055 ret = 0;
1056 break;
1057 case 0x0003: /* Invalid block. */
1058 case 0x0007: /* Invalid format. */
1059 case 0x0008: /* Other invalid block. */
1060 CIO_CRW_EVENT(2, "Error in chsc request block!\n");
1061 ret = -EINVAL;
1062 break;
1063 case 0x0004: /* Command not provided in model. */
1064 CIO_CRW_EVENT(2, "Model does not provide secm\n");
1065 ret = -EOPNOTSUPP;
1066 break;
1067 case 0x0102: /* cub adresses incorrect */
1068 CIO_CRW_EVENT(2, "Invalid addresses in chsc request block\n");
1069 ret = -EINVAL;
1070 break;
1071 case 0x0103: /* key error */
1072 CIO_CRW_EVENT(2, "Access key error in secm\n");
1073 ret = -EINVAL;
1074 break;
1075 case 0x0105: /* error while starting */
1076 CIO_CRW_EVENT(2, "Error while starting channel measurement\n");
1077 ret = -EIO;
1078 break;
1079 default:
1080 CIO_CRW_EVENT(2, "Unknown CHSC response %d\n",
1081 secm_area->response.code);
1082 ret = -EIO;
1083 }
1084 return ret;
1085}
1086
1087int
1088chsc_secm(struct channel_subsystem *css, int enable)
1089{
1090 void *secm_area;
1091 int ret;
1092
1093 secm_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
1094 if (!secm_area)
1095 return -ENOMEM;
1096
1097 mutex_lock(&css->mutex);
1098 if (enable && !css->cm_enabled) {
1099 css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
1100 css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
1101 if (!css->cub_addr1 || !css->cub_addr2) {
1102 free_page((unsigned long)css->cub_addr1);
1103 free_page((unsigned long)css->cub_addr2);
1104 free_page((unsigned long)secm_area);
1105 mutex_unlock(&css->mutex);
1106 return -ENOMEM;
1107 }
1108 }
1109 ret = __chsc_do_secm(css, enable, secm_area);
1110 if (!ret) {
1111 css->cm_enabled = enable;
1112 if (css->cm_enabled) {
1113 ret = chsc_add_cmg_attr(css);
1114 if (ret) {
1115 memset(secm_area, 0, PAGE_SIZE);
1116 __chsc_do_secm(css, 0, secm_area);
1117 css->cm_enabled = 0;
1118 }
1119 } else
1120 chsc_remove_cmg_attr(css);
1121 }
1122 if (enable && !css->cm_enabled) {
1123 free_page((unsigned long)css->cub_addr1);
1124 free_page((unsigned long)css->cub_addr2);
1125 }
1126 mutex_unlock(&css->mutex);
1127 free_page((unsigned long)secm_area);
1128 return ret;
1129}
1130
1131/*
878 * Files for the channel path entries. 1132 * Files for the channel path entries.
879 */ 1133 */
880static ssize_t 1134static ssize_t
@@ -925,9 +1179,39 @@ chp_type_show(struct device *dev, struct device_attribute *attr, char *buf)
925 1179
926static DEVICE_ATTR(type, 0444, chp_type_show, NULL); 1180static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
927 1181
1182static ssize_t
1183chp_cmg_show(struct device *dev, struct device_attribute *attr, char *buf)
1184{
1185 struct channel_path *chp = to_channelpath(dev);
1186
1187 if (!chp)
1188 return 0;
1189 if (chp->cmg == -1) /* channel measurements not available */
1190 return sprintf(buf, "unknown\n");
1191 return sprintf(buf, "%x\n", chp->cmg);
1192}
1193
1194static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
1195
1196static ssize_t
1197chp_shared_show(struct device *dev, struct device_attribute *attr, char *buf)
1198{
1199 struct channel_path *chp = to_channelpath(dev);
1200
1201 if (!chp)
1202 return 0;
1203 if (chp->shared == -1) /* channel measurements not available */
1204 return sprintf(buf, "unknown\n");
1205 return sprintf(buf, "%x\n", chp->shared);
1206}
1207
1208static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
1209
928static struct attribute * chp_attrs[] = { 1210static struct attribute * chp_attrs[] = {
929 &dev_attr_status.attr, 1211 &dev_attr_status.attr,
930 &dev_attr_type.attr, 1212 &dev_attr_type.attr,
1213 &dev_attr_cmg.attr,
1214 &dev_attr_shared.attr,
931 NULL, 1215 NULL,
932}; 1216};
933 1217
@@ -966,10 +1250,8 @@ chsc_determine_channel_path_description(int chpid,
966 if (!scpd_area) 1250 if (!scpd_area)
967 return -ENOMEM; 1251 return -ENOMEM;
968 1252
969 scpd_area->request = (struct chsc_header) { 1253 scpd_area->request.length = 0x0010;
970 .length = 0x0010, 1254 scpd_area->request.code = 0x0002;
971 .code = 0x0002,
972 };
973 1255
974 scpd_area->first_chpid = chpid; 1256 scpd_area->first_chpid = chpid;
975 scpd_area->last_chpid = chpid; 1257 scpd_area->last_chpid = chpid;
@@ -1006,6 +1288,111 @@ out:
1006 return ret; 1288 return ret;
1007} 1289}
1008 1290
1291static void
1292chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
1293 struct cmg_chars *chars)
1294{
1295 switch (chp->cmg) {
1296 case 2:
1297 case 3:
1298 chp->cmg_chars = kmalloc(sizeof(struct cmg_chars),
1299 GFP_KERNEL);
1300 if (chp->cmg_chars) {
1301 int i, mask;
1302 struct cmg_chars *cmg_chars;
1303
1304 cmg_chars = chp->cmg_chars;
1305 for (i = 0; i < NR_MEASUREMENT_CHARS; i++) {
1306 mask = 0x80 >> (i + 3);
1307 if (cmcv & mask)
1308 cmg_chars->values[i] = chars->values[i];
1309 else
1310 cmg_chars->values[i] = 0;
1311 }
1312 }
1313 break;
1314 default:
1315 /* No cmg-dependent data. */
1316 break;
1317 }
1318}
1319
1320static int
1321chsc_get_channel_measurement_chars(struct channel_path *chp)
1322{
1323 int ccode, ret;
1324
1325 struct {
1326 struct chsc_header request;
1327 u32 : 24;
1328 u32 first_chpid : 8;
1329 u32 : 24;
1330 u32 last_chpid : 8;
1331 u32 zeroes1;
1332 struct chsc_header response;
1333 u32 zeroes2;
1334 u32 not_valid : 1;
1335 u32 shared : 1;
1336 u32 : 22;
1337 u32 chpid : 8;
1338 u32 cmcv : 5;
1339 u32 : 11;
1340 u32 cmgq : 8;
1341 u32 cmg : 8;
1342 u32 zeroes3;
1343 u32 data[NR_MEASUREMENT_CHARS];
1344 } *scmc_area;
1345
1346 scmc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
1347 if (!scmc_area)
1348 return -ENOMEM;
1349
1350 scmc_area->request.length = 0x0010;
1351 scmc_area->request.code = 0x0022;
1352
1353 scmc_area->first_chpid = chp->id;
1354 scmc_area->last_chpid = chp->id;
1355
1356 ccode = chsc(scmc_area);
1357 if (ccode > 0) {
1358 ret = (ccode == 3) ? -ENODEV : -EBUSY;
1359 goto out;
1360 }
1361
1362 switch (scmc_area->response.code) {
1363 case 0x0001: /* Success. */
1364 if (!scmc_area->not_valid) {
1365 chp->cmg = scmc_area->cmg;
1366 chp->shared = scmc_area->shared;
1367 chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
1368 (struct cmg_chars *)
1369 &scmc_area->data);
1370 } else {
1371 chp->cmg = -1;
1372 chp->shared = -1;
1373 }
1374 ret = 0;
1375 break;
1376 case 0x0003: /* Invalid block. */
1377 case 0x0007: /* Invalid format. */
1378 case 0x0008: /* Invalid bit combination. */
1379 CIO_CRW_EVENT(2, "Error in chsc request block!\n");
1380 ret = -EINVAL;
1381 break;
1382 case 0x0004: /* Command not provided. */
1383 CIO_CRW_EVENT(2, "Model does not provide scmc\n");
1384 ret = -EOPNOTSUPP;
1385 break;
1386 default:
1387 CIO_CRW_EVENT(2, "Unknown CHSC response %d\n",
1388 scmc_area->response.code);
1389 ret = -EIO;
1390 }
1391out:
1392 free_page((unsigned long)scmc_area);
1393 return ret;
1394}
1395
1009/* 1396/*
1010 * Entries for chpids on the system bus. 1397 * Entries for chpids on the system bus.
1011 * This replaces /proc/chpids. 1398 * This replaces /proc/chpids.
@@ -1016,10 +1403,9 @@ new_channel_path(int chpid)
1016 struct channel_path *chp; 1403 struct channel_path *chp;
1017 int ret; 1404 int ret;
1018 1405
1019 chp = kmalloc(sizeof(struct channel_path), GFP_KERNEL); 1406 chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
1020 if (!chp) 1407 if (!chp)
1021 return -ENOMEM; 1408 return -ENOMEM;
1022 memset(chp, 0, sizeof(struct channel_path));
1023 1409
1024 /* fill in status, etc. */ 1410 /* fill in status, etc. */
1025 chp->id = chpid; 1411 chp->id = chpid;
@@ -1034,6 +1420,22 @@ new_channel_path(int chpid)
1034 ret = chsc_determine_channel_path_description(chpid, &chp->desc); 1420 ret = chsc_determine_channel_path_description(chpid, &chp->desc);
1035 if (ret) 1421 if (ret)
1036 goto out_free; 1422 goto out_free;
1423 /* Get channel-measurement characteristics. */
1424 if (css_characteristics_avail && css_chsc_characteristics.scmc
1425 && css_chsc_characteristics.secm) {
1426 ret = chsc_get_channel_measurement_chars(chp);
1427 if (ret)
1428 goto out_free;
1429 } else {
1430 static int msg_done;
1431
1432 if (!msg_done) {
1433 printk(KERN_WARNING "cio: Channel measurements not "
1434 "available, continuing.\n");
1435 msg_done = 1;
1436 }
1437 chp->cmg = -1;
1438 }
1037 1439
1038 /* make it known to the system */ 1440 /* make it known to the system */
1039 ret = device_register(&chp->dev); 1441 ret = device_register(&chp->dev);
@@ -1046,8 +1448,19 @@ new_channel_path(int chpid)
1046 if (ret) { 1448 if (ret) {
1047 device_unregister(&chp->dev); 1449 device_unregister(&chp->dev);
1048 goto out_free; 1450 goto out_free;
1049 } else 1451 }
1050 css[0]->chps[chpid] = chp; 1452 mutex_lock(&css[0]->mutex);
1453 if (css[0]->cm_enabled) {
1454 ret = chsc_add_chp_cmg_attr(chp);
1455 if (ret) {
1456 sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
1457 device_unregister(&chp->dev);
1458 mutex_unlock(&css[0]->mutex);
1459 goto out_free;
1460 }
1461 }
1462 css[0]->chps[chpid] = chp;
1463 mutex_unlock(&css[0]->mutex);
1051 return ret; 1464 return ret;
1052out_free: 1465out_free:
1053 kfree(chp); 1466 kfree(chp);
@@ -1103,10 +1516,8 @@ chsc_enable_facility(int operation_code)
1103 sda_area = (void *)get_zeroed_page(GFP_KERNEL|GFP_DMA); 1516 sda_area = (void *)get_zeroed_page(GFP_KERNEL|GFP_DMA);
1104 if (!sda_area) 1517 if (!sda_area)
1105 return -ENOMEM; 1518 return -ENOMEM;
1106 sda_area->request = (struct chsc_header) { 1519 sda_area->request.length = 0x0400;
1107 .length = 0x0400, 1520 sda_area->request.code = 0x0031;
1108 .code = 0x0031,
1109 };
1110 sda_area->operation_code = operation_code; 1521 sda_area->operation_code = operation_code;
1111 1522
1112 ret = chsc(sda_area); 1523 ret = chsc(sda_area);
@@ -1161,10 +1572,8 @@ chsc_determine_css_characteristics(void)
1161 return -ENOMEM; 1572 return -ENOMEM;
1162 } 1573 }
1163 1574
1164 scsc_area->request = (struct chsc_header) { 1575 scsc_area->request.length = 0x0010;
1165 .length = 0x0010, 1576 scsc_area->request.code = 0x0010;
1166 .code = 0x0010,
1167 };
1168 1577
1169 result = chsc(scsc_area); 1578 result = chsc(scsc_area);
1170 if (result) { 1579 if (result) {
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index 3e75095f35d0..a259245780ae 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -12,6 +12,16 @@ struct chsc_header {
12 u16 code; 12 u16 code;
13}; 13};
14 14
15#define NR_MEASUREMENT_CHARS 5
16struct cmg_chars {
17 u32 values[NR_MEASUREMENT_CHARS];
18};
19
20#define NR_MEASUREMENT_ENTRIES 8
21struct cmg_entry {
22 u32 values[NR_MEASUREMENT_ENTRIES];
23};
24
15struct channel_path_desc { 25struct channel_path_desc {
16 u8 flags; 26 u8 flags;
17 u8 lsn; 27 u8 lsn;
@@ -27,6 +37,10 @@ struct channel_path {
27 int id; 37 int id;
28 int state; 38 int state;
29 struct channel_path_desc desc; 39 struct channel_path_desc desc;
40 /* Channel-measurement related stuff: */
41 int cmg;
42 int shared;
43 void *cmg_chars;
30 struct device dev; 44 struct device dev;
31}; 45};
32 46
@@ -52,7 +66,11 @@ struct css_general_char {
52 66
53struct css_chsc_char { 67struct css_chsc_char {
54 u64 res; 68 u64 res;
55 u64 : 43; 69 u64 : 20;
70 u32 secm : 1; /* bit 84 */
71 u32 : 1;
72 u32 scmc : 1; /* bit 86 */
73 u32 : 20;
56 u32 scssc : 1; /* bit 107 */ 74 u32 scssc : 1; /* bit 107 */
57 u32 scsscf : 1; /* bit 108 */ 75 u32 scsscf : 1; /* bit 108 */
58 u32 : 19; 76 u32 : 19;
@@ -67,6 +85,8 @@ extern int css_characteristics_avail;
67extern void *chsc_get_chp_desc(struct subchannel*, int); 85extern void *chsc_get_chp_desc(struct subchannel*, int);
68 86
69extern int chsc_enable_facility(int); 87extern int chsc_enable_facility(int);
88struct channel_subsystem;
89extern int chsc_secm(struct channel_subsystem *, int);
70 90
71#define to_channelpath(device) container_of(device, struct channel_path, dev) 91#define to_channelpath(device) container_of(device, struct channel_path, dev)
72 92
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 3c77d65960db..74ea8aac4b7d 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -452,15 +452,50 @@ channel_subsystem_release(struct device *dev)
452 struct channel_subsystem *css; 452 struct channel_subsystem *css;
453 453
454 css = to_css(dev); 454 css = to_css(dev);
455 mutex_destroy(&css->mutex);
455 kfree(css); 456 kfree(css);
456} 457}
457 458
459static ssize_t
460css_cm_enable_show(struct device *dev, struct device_attribute *attr,
461 char *buf)
462{
463 struct channel_subsystem *css = to_css(dev);
464
465 if (!css)
466 return 0;
467 return sprintf(buf, "%x\n", css->cm_enabled);
468}
469
470static ssize_t
471css_cm_enable_store(struct device *dev, struct device_attribute *attr,
472 const char *buf, size_t count)
473{
474 struct channel_subsystem *css = to_css(dev);
475 int ret;
476
477 switch (buf[0]) {
478 case '0':
479 ret = css->cm_enabled ? chsc_secm(css, 0) : 0;
480 break;
481 case '1':
482 ret = css->cm_enabled ? 0 : chsc_secm(css, 1);
483 break;
484 default:
485 ret = -EINVAL;
486 }
487 return ret < 0 ? ret : count;
488}
489
490static DEVICE_ATTR(cm_enable, 0644, css_cm_enable_show, css_cm_enable_store);
491
458static inline void __init 492static inline void __init
459setup_css(int nr) 493setup_css(int nr)
460{ 494{
461 u32 tod_high; 495 u32 tod_high;
462 496
463 memset(css[nr], 0, sizeof(struct channel_subsystem)); 497 memset(css[nr], 0, sizeof(struct channel_subsystem));
498 mutex_init(&css[nr]->mutex);
464 css[nr]->valid = 1; 499 css[nr]->valid = 1;
465 css[nr]->cssid = nr; 500 css[nr]->cssid = nr;
466 sprintf(css[nr]->device.bus_id, "css%x", nr); 501 sprintf(css[nr]->device.bus_id, "css%x", nr);
@@ -507,6 +542,9 @@ init_channel_subsystem (void)
507 ret = device_register(&css[i]->device); 542 ret = device_register(&css[i]->device);
508 if (ret) 543 if (ret)
509 goto out_free; 544 goto out_free;
545 if (css_characteristics_avail && css_chsc_characteristics.secm)
546 device_create_file(&css[i]->device,
547 &dev_attr_cm_enable);
510 } 548 }
511 css_init_done = 1; 549 css_init_done = 1;
512 550
@@ -519,6 +557,9 @@ out_free:
519out_unregister: 557out_unregister:
520 while (i > 0) { 558 while (i > 0) {
521 i--; 559 i--;
560 if (css_characteristics_avail && css_chsc_characteristics.secm)
561 device_remove_file(&css[i]->device,
562 &dev_attr_cm_enable);
522 device_unregister(&css[i]->device); 563 device_unregister(&css[i]->device);
523 } 564 }
524out_bus: 565out_bus:
@@ -589,10 +630,9 @@ css_enqueue_subchannel_slow(struct subchannel_id schid)
589 struct slow_subchannel *new_slow_sch; 630 struct slow_subchannel *new_slow_sch;
590 unsigned long flags; 631 unsigned long flags;
591 632
592 new_slow_sch = kmalloc(sizeof(struct slow_subchannel), GFP_ATOMIC); 633 new_slow_sch = kzalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
593 if (!new_slow_sch) 634 if (!new_slow_sch)
594 return -ENOMEM; 635 return -ENOMEM;
595 memset(new_slow_sch, 0, sizeof(struct slow_subchannel));
596 new_slow_sch->schid = schid; 636 new_slow_sch->schid = schid;
597 spin_lock_irqsave(&slow_subchannel_lock, flags); 637 spin_lock_irqsave(&slow_subchannel_lock, flags);
598 list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head); 638 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 b6375861cb37..74a257b23383 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -1,6 +1,7 @@
1#ifndef _CSS_H 1#ifndef _CSS_H
2#define _CSS_H 2#define _CSS_H
3 3
4#include <linux/mutex.h>
4#include <linux/wait.h> 5#include <linux/wait.h>
5#include <linux/workqueue.h> 6#include <linux/workqueue.h>
6 7
@@ -150,6 +151,11 @@ struct channel_subsystem {
150 struct channel_path *chps[__MAX_CHPID + 1]; 151 struct channel_path *chps[__MAX_CHPID + 1];
151 struct device device; 152 struct device device;
152 struct pgid global_pgid; 153 struct pgid global_pgid;
154 struct mutex mutex;
155 /* channel measurement related */
156 int cm_enabled;
157 void *cub_addr1;
158 void *cub_addr2;
153}; 159};
154#define to_css(dev) container_of(dev, struct channel_subsystem, device) 160#define to_css(dev) container_of(dev, struct channel_subsystem, device)
155 161
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index afc4e88551ad..8e3053c2a451 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -826,17 +826,15 @@ io_subchannel_probe (struct subchannel *sch)
826 get_device(&cdev->dev); 826 get_device(&cdev->dev);
827 return 0; 827 return 0;
828 } 828 }
829 cdev = kmalloc (sizeof(*cdev), GFP_KERNEL); 829 cdev = kzalloc (sizeof(*cdev), GFP_KERNEL);
830 if (!cdev) 830 if (!cdev)
831 return -ENOMEM; 831 return -ENOMEM;
832 memset(cdev, 0, sizeof(struct ccw_device)); 832 cdev->private = kzalloc(sizeof(struct ccw_device_private),
833 cdev->private = kmalloc(sizeof(struct ccw_device_private),
834 GFP_KERNEL | GFP_DMA); 833 GFP_KERNEL | GFP_DMA);
835 if (!cdev->private) { 834 if (!cdev->private) {
836 kfree(cdev); 835 kfree(cdev);
837 return -ENOMEM; 836 return -ENOMEM;
838 } 837 }
839 memset(cdev->private, 0, sizeof(struct ccw_device_private));
840 atomic_set(&cdev->private->onoff, 0); 838 atomic_set(&cdev->private->onoff, 0);
841 cdev->dev = (struct device) { 839 cdev->dev = (struct device) {
842 .parent = &sch->dev, 840 .parent = &sch->dev,
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index b302779e7cff..180b3bf8b90d 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)
827 } 827 }
828 return; 828 return;
829 } 829 }
830 /*
831 * Check if a halt or clear has been issued in the meanwhile. If yes,
832 * only deliver the halt/clear interrupt to the device driver as if it
833 * had killed the original request.
834 */
835 if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC | SCSW_FCTL_HALT_FUNC)) {
836 cdev->private->flags.dosense = 0;
837 memset(&cdev->private->irb, 0, sizeof(struct irb));
838 ccw_device_accumulate_irb(cdev, irb);
839 goto call_handler;
840 }
830 /* Add basic sense info to irb. */ 841 /* Add basic sense info to irb. */
831 ccw_device_accumulate_basic_sense(cdev, irb); 842 ccw_device_accumulate_basic_sense(cdev, irb);
832 if (cdev->private->flags.dosense) { 843 if (cdev->private->flags.dosense) {
@@ -834,6 +845,7 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
834 ccw_device_do_sense(cdev, irb); 845 ccw_device_do_sense(cdev, irb);
835 return; 846 return;
836 } 847 }
848call_handler:
837 cdev->private->state = DEV_STATE_ONLINE; 849 cdev->private->state = DEV_STATE_ONLINE;
838 /* Call the handler. */ 850 /* Call the handler. */
839 if (ccw_device_call_handler(cdev) && cdev->private->flags.doverify) 851 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 3a50b1903287..795abb5a65ba 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)
359 CIO_TRACE_EVENT (4, "rddevch"); 359 CIO_TRACE_EVENT (4, "rddevch");
360 CIO_TRACE_EVENT (4, sch->dev.bus_id); 360 CIO_TRACE_EVENT (4, sch->dev.bus_id);
361 361
362 rdc_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA); 362 rdc_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
363 if (!rdc_ccw) 363 if (!rdc_ccw)
364 return -ENOMEM; 364 return -ENOMEM;
365 memset(rdc_ccw, 0, sizeof(struct ccw1));
366 rdc_ccw->cmd_code = CCW_CMD_RDC; 365 rdc_ccw->cmd_code = CCW_CMD_RDC;
367 rdc_ccw->count = length; 366 rdc_ccw->count = length;
368 rdc_ccw->flags = CCW_FLAG_SLI; 367 rdc_ccw->flags = CCW_FLAG_SLI;
@@ -426,16 +425,14 @@ read_conf_data_lpm (struct ccw_device *cdev, void **buffer, int *length, __u8 lp
426 if (!ciw || ciw->cmd == 0) 425 if (!ciw || ciw->cmd == 0)
427 return -EOPNOTSUPP; 426 return -EOPNOTSUPP;
428 427
429 rcd_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA); 428 rcd_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
430 if (!rcd_ccw) 429 if (!rcd_ccw)
431 return -ENOMEM; 430 return -ENOMEM;
432 memset(rcd_ccw, 0, sizeof(struct ccw1)); 431 rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
433 rcd_buf = kmalloc(ciw->count, GFP_KERNEL | GFP_DMA);
434 if (!rcd_buf) { 432 if (!rcd_buf) {
435 kfree(rcd_ccw); 433 kfree(rcd_ccw);
436 return -ENOMEM; 434 return -ENOMEM;
437 } 435 }
438 memset (rcd_buf, 0, ciw->count);
439 rcd_ccw->cmd_code = ciw->cmd; 436 rcd_ccw->cmd_code = ciw->cmd;
440 rcd_ccw->cda = (__u32) __pa (rcd_buf); 437 rcd_ccw->cda = (__u32) __pa (rcd_buf);
441 rcd_ccw->count = ciw->count; 438 rcd_ccw->count = ciw->count;
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 9ed37dc9a1b0..814f9258ce00 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,
1686 int result=-ENOMEM; 1686 int result=-ENOMEM;
1687 1687
1688 for (i=0;i<no_input_qs;i++) { 1688 for (i=0;i<no_input_qs;i++) {
1689 q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL); 1689 q = kzalloc(sizeof(struct qdio_q), GFP_KERNEL);
1690 1690
1691 if (!q) { 1691 if (!q) {
1692 QDIO_PRINT_ERR("kmalloc of q failed!\n"); 1692 QDIO_PRINT_ERR("kmalloc of q failed!\n");
1693 goto out; 1693 goto out;
1694 } 1694 }
1695 1695
1696 memset(q,0,sizeof(struct qdio_q)); 1696 q->slib = kmalloc(PAGE_SIZE, GFP_KERNEL);
1697
1698 q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
1699 if (!q->slib) { 1697 if (!q->slib) {
1700 QDIO_PRINT_ERR("kmalloc of slib failed!\n"); 1698 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1701 goto out; 1699 goto out;
@@ -1705,14 +1703,12 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr,
1705 } 1703 }
1706 1704
1707 for (i=0;i<no_output_qs;i++) { 1705 for (i=0;i<no_output_qs;i++) {
1708 q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL); 1706 q = kzalloc(sizeof(struct qdio_q), GFP_KERNEL);
1709 1707
1710 if (!q) { 1708 if (!q) {
1711 goto out; 1709 goto out;
1712 } 1710 }
1713 1711
1714 memset(q,0,sizeof(struct qdio_q));
1715
1716 q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL); 1712 q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
1717 if (!q->slib) { 1713 if (!q->slib) {
1718 QDIO_PRINT_ERR("kmalloc of slib failed!\n"); 1714 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
@@ -2984,7 +2980,7 @@ qdio_allocate(struct qdio_initialize *init_data)
2984 qdio_allocate_do_dbf(init_data); 2980 qdio_allocate_do_dbf(init_data);
2985 2981
2986 /* create irq */ 2982 /* create irq */
2987 irq_ptr=kmalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA); 2983 irq_ptr = kzalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
2988 2984
2989 QDIO_DBF_TEXT0(0,setup,"irq_ptr:"); 2985 QDIO_DBF_TEXT0(0,setup,"irq_ptr:");
2990 QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*)); 2986 QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*));
@@ -2994,8 +2990,6 @@ qdio_allocate(struct qdio_initialize *init_data)
2994 return -ENOMEM; 2990 return -ENOMEM;
2995 } 2991 }
2996 2992
2997 memset(irq_ptr,0,sizeof(struct qdio_irq));
2998
2999 init_MUTEX(&irq_ptr->setting_up_sema); 2993 init_MUTEX(&irq_ptr->setting_up_sema);
3000 2994
3001 /* QDR must be in DMA area since CCW data address is only 32 bit */ 2995 /* QDR must be in DMA area since CCW data address is only 32 bit */
@@ -3686,10 +3680,10 @@ qdio_get_qdio_memory(void)
3686 3680
3687 for (i=1;i<INDICATORS_PER_CACHELINE;i++) 3681 for (i=1;i<INDICATORS_PER_CACHELINE;i++)
3688 indicator_used[i]=0; 3682 indicator_used[i]=0;
3689 indicators=(__u32*)kmalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE), 3683 indicators = kzalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE),
3690 GFP_KERNEL); 3684 GFP_KERNEL);
3691 if (!indicators) return -ENOMEM; 3685 if (!indicators)
3692 memset(indicators,0,sizeof(__u32)*(INDICATORS_PER_CACHELINE)); 3686 return -ENOMEM;
3693 return 0; 3687 return 0;
3694} 3688}
3695 3689
diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c
index 4141919da805..be60795f4a74 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,
2214 long_len = 128; 2214 long_len = 128;
2215 } 2215 }
2216 2216
2217 tmp_size = ((mod_len <= 128) ? TYPE50_CRB1_LEN : TYPE50_CRB2_LEN) + 2217 tmp_size = ((long_len <= 64) ? TYPE50_CRB1_LEN : TYPE50_CRB2_LEN) +
2218 CALLER_HEADER; 2218 CALLER_HEADER;
2219 2219
2220 memset(z90cMsg_p, 0, tmp_size); 2220 memset(z90cMsg_p, 0, tmp_size);
@@ -2479,8 +2479,16 @@ convert_response(unsigned char *response, unsigned char *buffer,
2479 2479
2480 if (reply_code) 2480 if (reply_code)
2481 switch (reply_code) { 2481 switch (reply_code) {
2482 case REP82_ERROR_MACHINE_FAILURE:
2483 if (errh_p->type == TYPE82_RSP_CODE)
2484 PRINTKW("Machine check failure\n");
2485 else
2486 PRINTKW("Module failure\n");
2487 return REC_HARDWAR_ERR;
2482 case REP82_ERROR_OPERAND_INVALID: 2488 case REP82_ERROR_OPERAND_INVALID:
2489 return REC_OPERAND_INV;
2483 case REP88_ERROR_MESSAGE_MALFORMD: 2490 case REP88_ERROR_MESSAGE_MALFORMD:
2491 PRINTKW("Message malformed\n");
2484 return REC_OPERAND_INV; 2492 return REC_OPERAND_INV;
2485 case REP82_ERROR_OPERAND_SIZE: 2493 case REP82_ERROR_OPERAND_SIZE:
2486 return REC_OPERAND_SIZE; 2494 return REC_OPERAND_SIZE;
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 7d6f19030ef9..982acc7303ea 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * linux/drivers/s390/crypto/z90main.c 2 * linux/drivers/s390/crypto/z90main.c
3 * 3 *
4 * z90crypt 1.3.2 4 * z90crypt 1.3.3
5 * 5 *
6 * Copyright (C) 2001, 2004 IBM Corporation 6 * Copyright (C) 2001, 2005 IBM Corporation
7 * Author(s): Robert Burroughs (burrough@us.ibm.com) 7 * Author(s): Robert Burroughs (burrough@us.ibm.com)
8 * Eric Rossman (edrossma@us.ibm.com) 8 * Eric Rossman (edrossma@us.ibm.com)
9 * 9 *
@@ -707,13 +707,12 @@ z90crypt_open(struct inode *inode, struct file *filp)
707 if (quiesce_z90crypt) 707 if (quiesce_z90crypt)
708 return -EQUIESCE; 708 return -EQUIESCE;
709 709
710 private_data_p = kmalloc(sizeof(struct priv_data), GFP_KERNEL); 710 private_data_p = kzalloc(sizeof(struct priv_data), GFP_KERNEL);
711 if (!private_data_p) { 711 if (!private_data_p) {
712 PRINTK("Memory allocate failed\n"); 712 PRINTK("Memory allocate failed\n");
713 return -ENOMEM; 713 return -ENOMEM;
714 } 714 }
715 715
716 memset((void *)private_data_p, 0, sizeof(struct priv_data));
717 private_data_p->status = STAT_OPEN; 716 private_data_p->status = STAT_OPEN;
718 private_data_p->opener_pid = PID(); 717 private_data_p->opener_pid = PID();
719 filp->private_data = private_data_p; 718 filp->private_data = private_data_p;
@@ -991,6 +990,7 @@ remove_device(struct device *device_p)
991 * PCIXCC_MCL2 512-2048 ----- (applying any GA LIC will make an MCL3 card) 990 * PCIXCC_MCL2 512-2048 ----- (applying any GA LIC will make an MCL3 card)
992 * PCIXCC_MCL3 ----- 128-2048 991 * PCIXCC_MCL3 ----- 128-2048
993 * CEX2C 512-2048 128-2048 992 * CEX2C 512-2048 128-2048
993 * CEX2A ??-2048 same (the lower limit is less than 128 bit...)
994 * 994 *
995 * ext_bitlens (extended bitlengths) is a global, since you should not apply an 995 * ext_bitlens (extended bitlengths) is a global, since you should not apply an
996 * MCL to just one card in a machine. We assume, at first, that all cards have 996 * 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)
2736 z90crypt.max_count = Z90CRYPT_NUM_DEVS; 2736 z90crypt.max_count = Z90CRYPT_NUM_DEVS;
2737 z90crypt.cdx = *cdx_p; 2737 z90crypt.cdx = *cdx_p;
2738 2738
2739 hdware_blk_p = (struct hdware_block *) 2739 hdware_blk_p = kzalloc(sizeof(struct hdware_block), GFP_ATOMIC);
2740 kmalloc(sizeof(struct hdware_block), GFP_ATOMIC);
2741 if (!hdware_blk_p) { 2740 if (!hdware_blk_p) {
2742 PDEBUG("kmalloc for hardware block failed\n"); 2741 PDEBUG("kmalloc for hardware block failed\n");
2743 return ENOMEM; 2742 return ENOMEM;
2744 } 2743 }
2745 memset(hdware_blk_p, 0x00, sizeof(struct hdware_block));
2746 z90crypt.hdware_info = hdware_blk_p; 2744 z90crypt.hdware_info = hdware_blk_p;
2747 2745
2748 return 0; 2746 return 0;
@@ -2977,12 +2975,11 @@ create_crypto_device(int index)
2977 total_size = sizeof(struct device) + 2975 total_size = sizeof(struct device) +
2978 z90crypt.q_depth_array[index] * sizeof(int); 2976 z90crypt.q_depth_array[index] * sizeof(int);
2979 2977
2980 dev_ptr = (struct device *) kmalloc(total_size, GFP_ATOMIC); 2978 dev_ptr = kzalloc(total_size, GFP_ATOMIC);
2981 if (!dev_ptr) { 2979 if (!dev_ptr) {
2982 PRINTK("kmalloc device %d failed\n", index); 2980 PRINTK("kmalloc device %d failed\n", index);
2983 return ENOMEM; 2981 return ENOMEM;
2984 } 2982 }
2985 memset(dev_ptr, 0, total_size);
2986 dev_ptr->dev_resp_p = kmalloc(MAX_RESPONSE_SIZE, GFP_ATOMIC); 2983 dev_ptr->dev_resp_p = kmalloc(MAX_RESPONSE_SIZE, GFP_ATOMIC);
2987 if (!dev_ptr->dev_resp_p) { 2984 if (!dev_ptr->dev_resp_p) {
2988 kfree(dev_ptr); 2985 kfree(dev_ptr);
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index acd2a3f005f1..23d53bf9daf1 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -310,7 +310,7 @@ claw_probe(struct ccwgroup_device *cgdev)
310 printk(KERN_INFO "claw: variable cgdev =\n"); 310 printk(KERN_INFO "claw: variable cgdev =\n");
311 dumpit((char *)cgdev, sizeof(struct ccwgroup_device)); 311 dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
312#endif 312#endif
313 privptr = kmalloc(sizeof(struct claw_privbk), GFP_KERNEL); 313 privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
314 if (privptr == NULL) { 314 if (privptr == NULL) {
315 probe_error(cgdev); 315 probe_error(cgdev);
316 put_device(&cgdev->dev); 316 put_device(&cgdev->dev);
@@ -319,7 +319,6 @@ claw_probe(struct ccwgroup_device *cgdev)
319 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM); 319 CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
320 return -ENOMEM; 320 return -ENOMEM;
321 } 321 }
322 memset(privptr,0x00,sizeof(struct claw_privbk));
323 privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL); 322 privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
324 privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL); 323 privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL);
325 if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) { 324 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 6caf5fa6a3b5..7145e2134cf0 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_
21 fsm_function_t *m; 21 fsm_function_t *m;
22 fsm *f; 22 fsm *f;
23 23
24 this = (fsm_instance *)kmalloc(sizeof(fsm_instance), order); 24 this = kzalloc(sizeof(fsm_instance), order);
25 if (this == NULL) { 25 if (this == NULL) {
26 printk(KERN_WARNING 26 printk(KERN_WARNING
27 "fsm(%s): init_fsm: Couldn't alloc instance\n", name); 27 "fsm(%s): init_fsm: Couldn't alloc instance\n", name);
28 return NULL; 28 return NULL;
29 } 29 }
30 memset(this, 0, sizeof(fsm_instance));
31 strlcpy(this->name, name, sizeof(this->name)); 30 strlcpy(this->name, name, sizeof(this->name));
32 31
33 f = (fsm *)kmalloc(sizeof(fsm), order); 32 f = kzalloc(sizeof(fsm), order);
34 if (f == NULL) { 33 if (f == NULL) {
35 printk(KERN_WARNING 34 printk(KERN_WARNING
36 "fsm(%s): init_fsm: Couldn't alloc fsm\n", name); 35 "fsm(%s): init_fsm: Couldn't alloc fsm\n", name);
37 kfree_fsm(this); 36 kfree_fsm(this);
38 return NULL; 37 return NULL;
39 } 38 }
40 memset(f, 0, sizeof(fsm));
41 f->nr_events = nr_events; 39 f->nr_events = nr_events;
42 f->nr_states = nr_states; 40 f->nr_states = nr_states;
43 f->event_names = event_names; 41 f->event_names = event_names;
44 f->state_names = state_names; 42 f->state_names = state_names;
45 this->f = f; 43 this->f = f;
46 44
47 m = (fsm_function_t *)kmalloc( 45 m = kcalloc(nr_states*nr_events, sizeof(fsm_function_t), order);
48 sizeof(fsm_function_t) * nr_states * nr_events, order);
49 if (m == NULL) { 46 if (m == NULL) {
50 printk(KERN_WARNING 47 printk(KERN_WARNING
51 "fsm(%s): init_fsm: Couldn't alloc jumptable\n", name); 48 "fsm(%s): init_fsm: Couldn't alloc jumptable\n", name);
52 kfree_fsm(this); 49 kfree_fsm(this);
53 return NULL; 50 return NULL;
54 } 51 }
55 memset(m, 0, sizeof(fsm_function_t) * f->nr_states * f->nr_events);
56 f->jumpmatrix = m; 52 f->jumpmatrix = m;
57 53
58 for (i = 0; i < tmpl_len; i++) { 54 for (i = 0; i < tmpl_len; i++) {
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index 760e77ec5a11..6190be9dca99 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -386,7 +386,7 @@ iucv_init(void)
386 } 386 }
387 387
388 /* Note: GFP_DMA used used to get memory below 2G */ 388 /* Note: GFP_DMA used used to get memory below 2G */
389 iucv_external_int_buffer = kmalloc(sizeof(iucv_GeneralInterrupt), 389 iucv_external_int_buffer = kzalloc(sizeof(iucv_GeneralInterrupt),
390 GFP_KERNEL|GFP_DMA); 390 GFP_KERNEL|GFP_DMA);
391 if (!iucv_external_int_buffer) { 391 if (!iucv_external_int_buffer) {
392 printk(KERN_WARNING 392 printk(KERN_WARNING
@@ -396,10 +396,9 @@ iucv_init(void)
396 bus_unregister(&iucv_bus); 396 bus_unregister(&iucv_bus);
397 return -ENOMEM; 397 return -ENOMEM;
398 } 398 }
399 memset(iucv_external_int_buffer, 0, sizeof(iucv_GeneralInterrupt));
400 399
401 /* Initialize parameter pool */ 400 /* Initialize parameter pool */
402 iucv_param_pool = kmalloc(sizeof(iucv_param) * PARAM_POOL_SIZE, 401 iucv_param_pool = kzalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
403 GFP_KERNEL|GFP_DMA); 402 GFP_KERNEL|GFP_DMA);
404 if (!iucv_param_pool) { 403 if (!iucv_param_pool) {
405 printk(KERN_WARNING "%s: Could not allocate param pool\n", 404 printk(KERN_WARNING "%s: Could not allocate param pool\n",
@@ -410,7 +409,6 @@ iucv_init(void)
410 bus_unregister(&iucv_bus); 409 bus_unregister(&iucv_bus);
411 return -ENOMEM; 410 return -ENOMEM;
412 } 411 }
413 memset(iucv_param_pool, 0, sizeof(iucv_param) * PARAM_POOL_SIZE);
414 412
415 /* Initialize irq queue */ 413 /* Initialize irq queue */
416 INIT_LIST_HEAD(&iucv_irq_queue); 414 INIT_LIST_HEAD(&iucv_irq_queue);
@@ -793,15 +791,14 @@ iucv_register_program (__u8 pgmname[16],
793 } 791 }
794 792
795 max_connections = iucv_query_maxconn(); 793 max_connections = iucv_query_maxconn();
796 iucv_pathid_table = kmalloc(max_connections * sizeof(handler *), 794 iucv_pathid_table = kcalloc(max_connections, sizeof(handler *),
797 GFP_ATOMIC); 795 GFP_ATOMIC);
798 if (iucv_pathid_table == NULL) { 796 if (iucv_pathid_table == NULL) {
799 printk(KERN_WARNING "%s: iucv_pathid_table storage " 797 printk(KERN_WARNING "%s: iucv_pathid_table storage "
800 "allocation failed\n", __FUNCTION__); 798 "allocation failed\n", __FUNCTION__);
801 kfree(new_handler); 799 kfree(new_handler);
802 return NULL; 800 return NULL;
803 } 801 }
804 memset (iucv_pathid_table, 0, max_connections * sizeof(handler *));
805 } 802 }
806 memset(new_handler, 0, sizeof (handler)); 803 memset(new_handler, 0, sizeof (handler));
807 memcpy(new_handler->id.user_data, pgmname, 804 memcpy(new_handler->id.user_data, pgmname,
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 9cf88d7201d3..edcf05d5d568 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -115,11 +115,10 @@ lcs_alloc_channel(struct lcs_channel *channel)
115 LCS_DBF_TEXT(2, setup, "ichalloc"); 115 LCS_DBF_TEXT(2, setup, "ichalloc");
116 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) { 116 for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
117 /* alloc memory fo iobuffer */ 117 /* alloc memory fo iobuffer */
118 channel->iob[cnt].data = (void *) 118 channel->iob[cnt].data =
119 kmalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL); 119 kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
120 if (channel->iob[cnt].data == NULL) 120 if (channel->iob[cnt].data == NULL)
121 break; 121 break;
122 memset(channel->iob[cnt].data, 0, LCS_IOBUFFERSIZE);
123 channel->iob[cnt].state = BUF_STATE_EMPTY; 122 channel->iob[cnt].state = BUF_STATE_EMPTY;
124 } 123 }
125 if (cnt < LCS_NUM_BUFFS) { 124 if (cnt < LCS_NUM_BUFFS) {
@@ -182,10 +181,9 @@ lcs_alloc_card(void)
182 181
183 LCS_DBF_TEXT(2, setup, "alloclcs"); 182 LCS_DBF_TEXT(2, setup, "alloclcs");
184 183
185 card = kmalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA); 184 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
186 if (card == NULL) 185 if (card == NULL)
187 return NULL; 186 return NULL;
188 memset(card, 0, sizeof(struct lcs_card));
189 card->lan_type = LCS_FRAME_TYPE_AUTO; 187 card->lan_type = LCS_FRAME_TYPE_AUTO;
190 card->pkt_seq = 0; 188 card->pkt_seq = 0;
191 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT; 189 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
@@ -793,10 +791,9 @@ lcs_alloc_reply(struct lcs_cmd *cmd)
793 791
794 LCS_DBF_TEXT(4, trace, "getreply"); 792 LCS_DBF_TEXT(4, trace, "getreply");
795 793
796 reply = kmalloc(sizeof(struct lcs_reply), GFP_ATOMIC); 794 reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
797 if (!reply) 795 if (!reply)
798 return NULL; 796 return NULL;
799 memset(reply,0,sizeof(struct lcs_reply));
800 atomic_set(&reply->refcnt,1); 797 atomic_set(&reply->refcnt,1);
801 reply->sequence_no = cmd->sequence_no; 798 reply->sequence_no = cmd->sequence_no;
802 reply->received = 0; 799 reply->received = 0;
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 71d3853e8682..260a93c8c442 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1728,14 +1728,13 @@ static int
1728netiucv_register_device(struct net_device *ndev) 1728netiucv_register_device(struct net_device *ndev)
1729{ 1729{
1730 struct netiucv_priv *priv = ndev->priv; 1730 struct netiucv_priv *priv = ndev->priv;
1731 struct device *dev = kmalloc(sizeof(struct device), GFP_KERNEL); 1731 struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
1732 int ret; 1732 int ret;
1733 1733
1734 1734
1735 IUCV_DBF_TEXT(trace, 3, __FUNCTION__); 1735 IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
1736 1736
1737 if (dev) { 1737 if (dev) {
1738 memset(dev, 0, sizeof(struct device));
1739 snprintf(dev->bus_id, BUS_ID_SIZE, "net%s", ndev->name); 1738 snprintf(dev->bus_id, BUS_ID_SIZE, "net%s", ndev->name);
1740 dev->bus = &iucv_bus; 1739 dev->bus = &iucv_bus;
1741 dev->parent = iucv_root; 1740 dev->parent = iucv_root;
@@ -1784,11 +1783,9 @@ netiucv_new_connection(struct net_device *dev, char *username)
1784{ 1783{
1785 struct iucv_connection **clist = &iucv_connections; 1784 struct iucv_connection **clist = &iucv_connections;
1786 struct iucv_connection *conn = 1785 struct iucv_connection *conn =
1787 (struct iucv_connection *) 1786 kzalloc(sizeof(struct iucv_connection), GFP_KERNEL);
1788 kmalloc(sizeof(struct iucv_connection), GFP_KERNEL);
1789 1787
1790 if (conn) { 1788 if (conn) {
1791 memset(conn, 0, sizeof(struct iucv_connection));
1792 skb_queue_head_init(&conn->collect_queue); 1789 skb_queue_head_init(&conn->collect_queue);
1793 skb_queue_head_init(&conn->commit_queue); 1790 skb_queue_head_init(&conn->commit_queue);
1794 conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT; 1791 conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index 82cb4af2f0e7..44e226f211e7 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)
389 struct qeth_eddp_data *eddp; 389 struct qeth_eddp_data *eddp;
390 390
391 QETH_DBF_TEXT(trace, 5, "eddpcrda"); 391 QETH_DBF_TEXT(trace, 5, "eddpcrda");
392 eddp = kmalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC); 392 eddp = kzalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
393 if (eddp){ 393 if (eddp){
394 memset(eddp, 0, sizeof(struct qeth_eddp_data));
395 eddp->nhl = nhl; 394 eddp->nhl = nhl;
396 eddp->thl = thl; 395 eddp->thl = thl;
397 memcpy(&eddp->qh, qh, sizeof(struct qeth_hdr)); 396 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,
542 541
543 QETH_DBF_TEXT(trace, 5, "creddpcg"); 542 QETH_DBF_TEXT(trace, 5, "creddpcg");
544 /* create the context and allocate pages */ 543 /* create the context and allocate pages */
545 ctx = kmalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC); 544 ctx = kzalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
546 if (ctx == NULL){ 545 if (ctx == NULL){
547 QETH_DBF_TEXT(trace, 2, "ceddpcn1"); 546 QETH_DBF_TEXT(trace, 2, "ceddpcn1");
548 return NULL; 547 return NULL;
549 } 548 }
550 memset(ctx, 0, sizeof(struct qeth_eddp_context));
551 ctx->type = QETH_LARGE_SEND_EDDP; 549 ctx->type = QETH_LARGE_SEND_EDDP;
552 qeth_eddp_calc_num_pages(ctx, skb, hdr_len); 550 qeth_eddp_calc_num_pages(ctx, skb, hdr_len);
553 if (ctx->elements_per_skb > QETH_MAX_BUFFER_ELEMENTS(card)){ 551 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,
555 kfree(ctx); 553 kfree(ctx);
556 return NULL; 554 return NULL;
557 } 555 }
558 ctx->pages = kmalloc(ctx->num_pages * sizeof(u8 *), GFP_ATOMIC); 556 ctx->pages = kcalloc(ctx->num_pages, sizeof(u8 *), GFP_ATOMIC);
559 if (ctx->pages == NULL){ 557 if (ctx->pages == NULL){
560 QETH_DBF_TEXT(trace, 2, "ceddpcn2"); 558 QETH_DBF_TEXT(trace, 2, "ceddpcn2");
561 kfree(ctx); 559 kfree(ctx);
562 return NULL; 560 return NULL;
563 } 561 }
564 memset(ctx->pages, 0, ctx->num_pages * sizeof(u8 *));
565 for (i = 0; i < ctx->num_pages; ++i){ 562 for (i = 0; i < ctx->num_pages; ++i){
566 addr = (u8 *)__get_free_page(GFP_ATOMIC); 563 addr = (u8 *)__get_free_page(GFP_ATOMIC);
567 if (addr == NULL){ 564 if (addr == NULL){
@@ -573,15 +570,13 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
573 memset(addr, 0, PAGE_SIZE); 570 memset(addr, 0, PAGE_SIZE);
574 ctx->pages[i] = addr; 571 ctx->pages[i] = addr;
575 } 572 }
576 ctx->elements = kmalloc(ctx->num_elements * 573 ctx->elements = kcalloc(ctx->num_elements,
577 sizeof(struct qeth_eddp_element), GFP_ATOMIC); 574 sizeof(struct qeth_eddp_element), GFP_ATOMIC);
578 if (ctx->elements == NULL){ 575 if (ctx->elements == NULL){
579 QETH_DBF_TEXT(trace, 2, "ceddpcn4"); 576 QETH_DBF_TEXT(trace, 2, "ceddpcn4");
580 qeth_eddp_free_context(ctx); 577 qeth_eddp_free_context(ctx);
581 return NULL; 578 return NULL;
582 } 579 }
583 memset(ctx->elements, 0,
584 ctx->num_elements * sizeof(struct qeth_eddp_element));
585 /* reset num_elements; will be incremented again in fill_buffer to 580 /* reset num_elements; will be incremented again in fill_buffer to
586 * reflect number of actually used elements */ 581 * reflect number of actually used elements */
587 ctx->num_elements = 0; 582 ctx->num_elements = 0;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 021cd5d08c61..b3c6e7907790 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -297,12 +297,10 @@ qeth_alloc_card(void)
297 struct qeth_card *card; 297 struct qeth_card *card;
298 298
299 QETH_DBF_TEXT(setup, 2, "alloccrd"); 299 QETH_DBF_TEXT(setup, 2, "alloccrd");
300 card = (struct qeth_card *) kmalloc(sizeof(struct qeth_card), 300 card = kzalloc(sizeof(struct qeth_card), GFP_DMA|GFP_KERNEL);
301 GFP_DMA|GFP_KERNEL);
302 if (!card) 301 if (!card)
303 return NULL; 302 return NULL;
304 QETH_DBF_HEX(setup, 2, &card, sizeof(void *)); 303 QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
305 memset(card, 0, sizeof(struct qeth_card));
306 if (qeth_setup_channel(&card->read)) { 304 if (qeth_setup_channel(&card->read)) {
307 kfree(card); 305 kfree(card);
308 return NULL; 306 return NULL;
@@ -1632,9 +1630,8 @@ qeth_alloc_reply(struct qeth_card *card)
1632{ 1630{
1633 struct qeth_reply *reply; 1631 struct qeth_reply *reply;
1634 1632
1635 reply = kmalloc(sizeof(struct qeth_reply), GFP_ATOMIC); 1633 reply = kzalloc(sizeof(struct qeth_reply), GFP_ATOMIC);
1636 if (reply){ 1634 if (reply){
1637 memset(reply, 0, sizeof(struct qeth_reply));
1638 atomic_set(&reply->refcnt, 1); 1635 atomic_set(&reply->refcnt, 1);
1639 reply->card = card; 1636 reply->card = card;
1640 }; 1637 };
@@ -3348,13 +3345,11 @@ qeth_qdio_establish(struct qeth_card *card)
3348 3345
3349 QETH_DBF_TEXT(setup, 2, "qdioest"); 3346 QETH_DBF_TEXT(setup, 2, "qdioest");
3350 3347
3351 qib_param_field = kmalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char), 3348 qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
3352 GFP_KERNEL); 3349 GFP_KERNEL);
3353 if (!qib_param_field) 3350 if (!qib_param_field)
3354 return -ENOMEM; 3351 return -ENOMEM;
3355 3352
3356 memset(qib_param_field, 0, QDIO_MAX_BUFFERS_PER_Q * sizeof(char));
3357
3358 qeth_create_qib_param_field(card, qib_param_field); 3353 qeth_create_qib_param_field(card, qib_param_field);
3359 qeth_create_qib_param_field_blkt(card, qib_param_field); 3354 qeth_create_qib_param_field_blkt(card, qib_param_field);
3360 3355
@@ -4819,9 +4814,8 @@ qeth_arp_query(struct qeth_card *card, char *udata)
4819 /* get size of userspace buffer and mask_bits -> 6 bytes */ 4814 /* get size of userspace buffer and mask_bits -> 6 bytes */
4820 if (copy_from_user(&qinfo, udata, 6)) 4815 if (copy_from_user(&qinfo, udata, 6))
4821 return -EFAULT; 4816 return -EFAULT;
4822 if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL))) 4817 if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL)))
4823 return -ENOMEM; 4818 return -ENOMEM;
4824 memset(qinfo.udata, 0, qinfo.udata_len);
4825 qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET; 4819 qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET;
4826 iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, 4820 iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
4827 IPA_CMD_ASS_ARP_QUERY_INFO, 4821 IPA_CMD_ASS_ARP_QUERY_INFO,
@@ -4969,11 +4963,10 @@ qeth_snmp_command(struct qeth_card *card, char *udata)
4969 return -EFAULT; 4963 return -EFAULT;
4970 } 4964 }
4971 qinfo.udata_len = ureq->hdr.data_len; 4965 qinfo.udata_len = ureq->hdr.data_len;
4972 if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL))){ 4966 if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL))){
4973 kfree(ureq); 4967 kfree(ureq);
4974 return -ENOMEM; 4968 return -ENOMEM;
4975 } 4969 }
4976 memset(qinfo.udata, 0, qinfo.udata_len);
4977 qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr); 4970 qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);
4978 4971
4979 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL, 4972 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL,
@@ -5564,12 +5557,11 @@ qeth_get_addr_buffer(enum qeth_prot_versions prot)
5564{ 5557{
5565 struct qeth_ipaddr *addr; 5558 struct qeth_ipaddr *addr;
5566 5559
5567 addr = kmalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC); 5560 addr = kzalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
5568 if (addr == NULL) { 5561 if (addr == NULL) {
5569 PRINT_WARN("Not enough memory to add address\n"); 5562 PRINT_WARN("Not enough memory to add address\n");
5570 return NULL; 5563 return NULL;
5571 } 5564 }
5572 memset(addr,0,sizeof(struct qeth_ipaddr));
5573 addr->type = QETH_IP_TYPE_NORMAL; 5565 addr->type = QETH_IP_TYPE_NORMAL;
5574 addr->proto = prot; 5566 addr->proto = prot;
5575 return addr; 5567 return addr;
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index f2a076a2b2f1..882d419e4160 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -1145,11 +1145,10 @@ qeth_dev_ipato_add_store(const char *buf, size_t count,
1145 if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits))) 1145 if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits)))
1146 return rc; 1146 return rc;
1147 1147
1148 if (!(ipatoe = kmalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){ 1148 if (!(ipatoe = kzalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){
1149 PRINT_WARN("No memory to allocate ipato entry\n"); 1149 PRINT_WARN("No memory to allocate ipato entry\n");
1150 return -ENOMEM; 1150 return -ENOMEM;
1151 } 1151 }
1152 memset(ipatoe, 0, sizeof(struct qeth_ipato_entry));
1153 ipatoe->proto = proto; 1152 ipatoe->proto = proto;
1154 memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16); 1153 memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16);
1155 ipatoe->mask_bits = mask_bits; 1154 ipatoe->mask_bits = mask_bits;
diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c
index e3f647169827..3c7145d9f9a1 100644
--- a/drivers/s390/s390_rdev.c
+++ b/drivers/s390/s390_rdev.c
@@ -27,10 +27,9 @@ s390_root_dev_register(const char *name)
27 27
28 if (!strlen(name)) 28 if (!strlen(name))
29 return ERR_PTR(-EINVAL); 29 return ERR_PTR(-EINVAL);
30 dev = kmalloc(sizeof(struct device), GFP_KERNEL); 30 dev = kzalloc(sizeof(struct device), GFP_KERNEL);
31 if (!dev) 31 if (!dev)
32 return ERR_PTR(-ENOMEM); 32 return ERR_PTR(-ENOMEM);
33 memset(dev, 0, sizeof(struct device));
34 strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE)); 33 strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
35 dev->release = s390_root_dev_release; 34 dev->release = s390_root_dev_release;
36 ret = device_register(dev); 35 ret = device_register(dev);
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
index 583d2d8c8335..fad2109268bb 100644
--- a/drivers/scsi/arm/cumana_2.c
+++ b/drivers/scsi/arm/cumana_2.c
@@ -550,6 +550,6 @@ module_exit(cumanascsi2_exit);
550 550
551MODULE_AUTHOR("Russell King"); 551MODULE_AUTHOR("Russell King");
552MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines"); 552MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines");
553MODULE_PARM(term, "1-8i"); 553module_param_array(term, int, NULL, 0);
554MODULE_PARM_DESC(term, "SCSI bus termination"); 554MODULE_PARM_DESC(term, "SCSI bus termination");
555MODULE_LICENSE("GPL"); 555MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
index 3ffec7efc9d5..dcbb4b2b3fe0 100644
--- a/drivers/scsi/arm/eesox.c
+++ b/drivers/scsi/arm/eesox.c
@@ -674,6 +674,6 @@ module_exit(eesox_exit);
674 674
675MODULE_AUTHOR("Russell King"); 675MODULE_AUTHOR("Russell King");
676MODULE_DESCRIPTION("EESOX 'Fast' SCSI driver for Acorn machines"); 676MODULE_DESCRIPTION("EESOX 'Fast' SCSI driver for Acorn machines");
677MODULE_PARM(term, "1-8i"); 677module_param_array(term, int, NULL, 0);
678MODULE_PARM_DESC(term, "SCSI bus termination"); 678MODULE_PARM_DESC(term, "SCSI bus termination");
679MODULE_LICENSE("GPL"); 679MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
index 3113bdcedb13..3d69f6c45a6b 100644
--- a/drivers/scsi/arm/powertec.c
+++ b/drivers/scsi/arm/powertec.c
@@ -466,6 +466,6 @@ module_exit(powertecscsi_exit);
466 466
467MODULE_AUTHOR("Russell King"); 467MODULE_AUTHOR("Russell King");
468MODULE_DESCRIPTION("Powertec SCSI driver"); 468MODULE_DESCRIPTION("Powertec SCSI driver");
469MODULE_PARM(term, "1-8i"); 469module_param_array(term, int, NULL, 0);
470MODULE_PARM_DESC(term, "SCSI bus termination"); 470MODULE_PARM_DESC(term, "SCSI bus termination");
471MODULE_LICENSE("GPL"); 471MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index a74e23d39ba9..2d5be84d8bd4 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)
742/** 742/**
743 * piix_check_450nx_errata - Check for problem 450NX setup 743 * piix_check_450nx_errata - Check for problem 450NX setup
744 * @ata_dev: the PCI device to check 744 * @ata_dev: the PCI device to check
745 * 745 *
746 * Check for the present of 450NX errata #19 and errata #25. If 746 * Check for the present of 450NX errata #19 and errata #25. If
747 * they are found return an error code so we can turn off DMA 747 * they are found return an error code so we can turn off DMA
748 */ 748 */
@@ -753,7 +753,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
753 u16 cfg; 753 u16 cfg;
754 u8 rev; 754 u8 rev;
755 int no_piix_dma = 0; 755 int no_piix_dma = 0;
756 756
757 while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) 757 while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL)
758 { 758 {
759 /* Look for 450NX PXB. Check for problem configurations 759 /* Look for 450NX PXB. Check for problem configurations
@@ -772,7 +772,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
772 if(no_piix_dma == 2) 772 if(no_piix_dma == 2)
773 dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n"); 773 dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n");
774 return no_piix_dma; 774 return no_piix_dma;
775} 775}
776 776
777static void __devinit piix_init_sata_map(struct pci_dev *pdev, 777static void __devinit piix_init_sata_map(struct pci_dev *pdev,
778 struct ata_port_info *pinfo) 778 struct ata_port_info *pinfo)
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index f4c1ca7c1572..f677c5a32a68 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -239,17 +239,17 @@ static int atari_read_overruns = 0;
239#endif 239#endif
240 240
241static int setup_can_queue = -1; 241static int setup_can_queue = -1;
242MODULE_PARM(setup_can_queue, "i"); 242module_param(setup_can_queue, int, 0);
243static int setup_cmd_per_lun = -1; 243static int setup_cmd_per_lun = -1;
244MODULE_PARM(setup_cmd_per_lun, "i"); 244module_param(setup_cmd_per_lun, int, 0);
245static int setup_sg_tablesize = -1; 245static int setup_sg_tablesize = -1;
246MODULE_PARM(setup_sg_tablesize, "i"); 246module_param(setup_sg_tablesize, int, 0);
247#ifdef SUPPORT_TAGS 247#ifdef SUPPORT_TAGS
248static int setup_use_tagged_queuing = -1; 248static int setup_use_tagged_queuing = -1;
249MODULE_PARM(setup_use_tagged_queuing, "i"); 249module_param(setup_use_tagged_queuing, int, 0);
250#endif 250#endif
251static int setup_hostid = -1; 251static int setup_hostid = -1;
252MODULE_PARM(setup_hostid, "i"); 252module_param(setup_hostid, int, 0);
253 253
254 254
255#if defined(CONFIG_TT_DMA_EMUL) 255#if defined(CONFIG_TT_DMA_EMUL)
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 45756fa90777..e6bcfe949340 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -127,7 +127,7 @@ static int ncr_53c400a = NCR_NOT_SET;
127static int dtc_3181e = NCR_NOT_SET; 127static int dtc_3181e = NCR_NOT_SET;
128 128
129static struct override { 129static struct override {
130 NCR5380_implementation_fields; 130 NCR5380_map_type NCR5380_map_name;
131 int irq; 131 int irq;
132 int dma; 132 int dma;
133 int board; /* Use NCR53c400, Ricoh, etc. extensions ? */ 133 int board; /* Use NCR53c400, Ricoh, etc. extensions ? */
@@ -299,6 +299,10 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
299 }; 299 };
300 int flags = 0; 300 int flags = 0;
301 struct Scsi_Host *instance; 301 struct Scsi_Host *instance;
302#ifdef CONFIG_SCSI_G_NCR5380_MEM
303 unsigned long base;
304 void __iomem *iomem;
305#endif
302 306
303 if (ncr_irq != NCR_NOT_SET) 307 if (ncr_irq != NCR_NOT_SET)
304 overrides[0].irq = ncr_irq; 308 overrides[0].irq = ncr_irq;
@@ -424,15 +428,22 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
424 region_size = NCR5380_region_size; 428 region_size = NCR5380_region_size;
425 } 429 }
426#else 430#else
427 if(!request_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380")) 431 base = overrides[current_override].NCR5380_map_name;
432 if (!request_mem_region(base, NCR5380_region_size, "ncr5380"))
433 continue;
434 iomem = ioremap(base, NCR5380_region_size);
435 if (!iomem) {
436 release_mem_region(base, NCR5380_region_size);
428 continue; 437 continue;
438 }
429#endif 439#endif
430 instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); 440 instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
431 if (instance == NULL) { 441 if (instance == NULL) {
432#ifndef CONFIG_SCSI_G_NCR5380_MEM 442#ifndef CONFIG_SCSI_G_NCR5380_MEM
433 release_region(overrides[current_override].NCR5380_map_name, region_size); 443 release_region(overrides[current_override].NCR5380_map_name, region_size);
434#else 444#else
435 release_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size); 445 iounmap(iomem);
446 release_mem_region(base, NCR5380_region_size);
436#endif 447#endif
437 continue; 448 continue;
438 } 449 }
@@ -440,6 +451,8 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
440 instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name; 451 instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name;
441#ifndef CONFIG_SCSI_G_NCR5380_MEM 452#ifndef CONFIG_SCSI_G_NCR5380_MEM
442 instance->n_io_port = region_size; 453 instance->n_io_port = region_size;
454#else
455 ((struct NCR5380_hostdata *)instance->hostdata).iomem = iomem;
443#endif 456#endif
444 457
445 NCR5380_init(instance, flags); 458 NCR5380_init(instance, flags);
@@ -509,6 +522,7 @@ int generic_NCR5380_release_resources(struct Scsi_Host *instance)
509#ifndef CONFIG_SCSI_G_NCR5380_MEM 522#ifndef CONFIG_SCSI_G_NCR5380_MEM
510 release_region(instance->NCR5380_instance_name, instance->n_io_port); 523 release_region(instance->NCR5380_instance_name, instance->n_io_port);
511#else 524#else
525 iounmap(((struct NCR5380_hostdata *)instance->hostdata).iomem);
512 release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size); 526 release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size);
513#endif 527#endif
514 528
@@ -586,7 +600,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst,
586 } 600 }
587#else 601#else
588 /* implies CONFIG_SCSI_G_NCR5380_MEM */ 602 /* implies CONFIG_SCSI_G_NCR5380_MEM */
589 isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128); 603 memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
590#endif 604#endif
591 start += 128; 605 start += 128;
592 blocks--; 606 blocks--;
@@ -606,7 +620,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst,
606 } 620 }
607#else 621#else
608 /* implies CONFIG_SCSI_G_NCR5380_MEM */ 622 /* implies CONFIG_SCSI_G_NCR5380_MEM */
609 isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128); 623 memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
610#endif 624#endif
611 start += 128; 625 start += 128;
612 blocks--; 626 blocks--;
@@ -671,7 +685,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
671 } 685 }
672#else 686#else
673 /* implies CONFIG_SCSI_G_NCR5380_MEM */ 687 /* implies CONFIG_SCSI_G_NCR5380_MEM */
674 isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128); 688 memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
675#endif 689#endif
676 start += 128; 690 start += 128;
677 blocks--; 691 blocks--;
@@ -687,7 +701,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
687 } 701 }
688#else 702#else
689 /* implies CONFIG_SCSI_G_NCR5380_MEM */ 703 /* implies CONFIG_SCSI_G_NCR5380_MEM */
690 isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128); 704 memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
691#endif 705#endif
692 start += 128; 706 start += 128;
693 blocks--; 707 blocks--;
diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h
index 656fbe2f91f6..d60a89cb8052 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 *);
82#define NCR5380_read(reg) (inb(NCR5380_map_name + (reg))) 82#define NCR5380_read(reg) (inb(NCR5380_map_name + (reg)))
83#define NCR5380_write(reg, value) (outb((value), (NCR5380_map_name + (reg)))) 83#define NCR5380_write(reg, value) (outb((value), (NCR5380_map_name + (reg))))
84 84
85#define NCR5380_implementation_fields \
86 NCR5380_map_type NCR5380_map_name
87
88#define NCR5380_local_declare() \
89 register NCR5380_implementation_fields
90
91#define NCR5380_setup(instance) \
92 NCR5380_map_name = (NCR5380_map_type)((instance)->NCR5380_instance_name)
93
85#else 94#else
86/* therefore CONFIG_SCSI_G_NCR5380_MEM */ 95/* therefore CONFIG_SCSI_G_NCR5380_MEM */
87 96
@@ -95,18 +104,20 @@ static const char* generic_NCR5380_info(struct Scsi_Host *);
95#define NCR53C400_host_buffer 0x3900 104#define NCR53C400_host_buffer 0x3900
96#define NCR5380_region_size 0x3a00 105#define NCR5380_region_size 0x3a00
97 106
98#define NCR5380_read(reg) isa_readb(NCR5380_map_name + NCR53C400_mem_base + (reg)) 107#define NCR5380_read(reg) readb(iomem + NCR53C400_mem_base + (reg))
99#define NCR5380_write(reg, value) isa_writeb(value, NCR5380_map_name + NCR53C400_mem_base + (reg)) 108#define NCR5380_write(reg, value) writeb(value, iomem + NCR53C400_mem_base + (reg))
100#endif
101 109
102#define NCR5380_implementation_fields \ 110#define NCR5380_implementation_fields \
103 NCR5380_map_type NCR5380_map_name 111 NCR5380_map_type NCR5380_map_name; \
112 void __iomem *iomem;
104 113
105#define NCR5380_local_declare() \ 114#define NCR5380_local_declare() \
106 register NCR5380_implementation_fields 115 register void __iomem *iomem
107 116
108#define NCR5380_setup(instance) \ 117#define NCR5380_setup(instance) \
109 NCR5380_map_name = (NCR5380_map_type)((instance)->NCR5380_instance_name) 118 iomem = (((struct NCR5380_hostdata *)(instance)->hostdata).iomem)
119
120#endif
110 121
111#define NCR5380_intr generic_NCR5380_intr 122#define NCR5380_intr generic_NCR5380_intr
112#define NCR5380_queue_command generic_NCR5380_queue_command 123#define NCR5380_queue_command generic_NCR5380_queue_command
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index 34daa3e068de..9c519876f8a0 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -1898,6 +1898,21 @@ static int int_tab[] in2000__INITDATA = {
1898 10 1898 10
1899}; 1899};
1900 1900
1901static int probe_bios(u32 addr, u32 *s1, uchar *switches)
1902{
1903 void __iomem *p = ioremap(addr, 0x34);
1904 if (!p)
1905 return 0;
1906 *s1 = readl(p + 0x10);
1907 if (*s1 == 0x41564f4e || readl(p + 0x30) == 0x61776c41) {
1908 /* Read the switch image that's mapped into EPROM space */
1909 *switches = ~readb(p + 0x20);
1910 iounmap(p);
1911 return 1;
1912 }
1913 iounmap(p);
1914 return 0;
1915}
1901 1916
1902static int __init in2000_detect(struct scsi_host_template * tpnt) 1917static int __init in2000_detect(struct scsi_host_template * tpnt)
1903{ 1918{
@@ -1930,6 +1945,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
1930 1945
1931 detect_count = 0; 1946 detect_count = 0;
1932 for (bios = 0; bios_tab[bios]; bios++) { 1947 for (bios = 0; bios_tab[bios]; bios++) {
1948 u32 s1 = 0;
1933 if (check_setup_args("ioport", &val, buf)) { 1949 if (check_setup_args("ioport", &val, buf)) {
1934 base = val; 1950 base = val;
1935 switches = ~inb(base + IO_SWITCHES) & 0xff; 1951 switches = ~inb(base + IO_SWITCHES) & 0xff;
@@ -1941,13 +1957,9 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
1941 * for the obvious ID strings. We look for the 2 most common ones and 1957 * for the obvious ID strings. We look for the 2 most common ones and
1942 * hope that they cover all the cases... 1958 * hope that they cover all the cases...
1943 */ 1959 */
1944 else if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e || isa_readl(bios_tab[bios] + 0x30) == 0x61776c41) { 1960 else if (probe_bios(bios_tab[bios], &s1, &switches)) {
1945 printk("Found IN2000 BIOS at 0x%x ", (unsigned int) bios_tab[bios]); 1961 printk("Found IN2000 BIOS at 0x%x ", (unsigned int) bios_tab[bios]);
1946 1962
1947/* Read the switch image that's mapped into EPROM space */
1948
1949 switches = ~((isa_readb(bios_tab[bios] + 0x20) & 0xff));
1950
1951/* Find out where the IO space is */ 1963/* Find out where the IO space is */
1952 1964
1953 x = switches & (SW_ADDR0 | SW_ADDR1); 1965 x = switches & (SW_ADDR0 | SW_ADDR1);
@@ -2037,7 +2049,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
2037 2049
2038/* Older BIOS's had a 'sync on/off' switch - use its setting */ 2050/* Older BIOS's had a 'sync on/off' switch - use its setting */
2039 2051
2040 if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e && (switches & SW_SYNC_DOS5)) 2052 if (s1 == 0x41564f4e && (switches & SW_SYNC_DOS5))
2041 hostdata->sync_off = 0x00; /* sync defaults to on */ 2053 hostdata->sync_off = 0x00; /* sync defaults to on */
2042 else 2054 else
2043 hostdata->sync_off = 0xff; /* sync defaults to off */ 2055 hostdata->sync_off = 0xff; /* sync defaults to off */
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index 96b4d2160df8..95d81d86d8b7 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -418,6 +418,240 @@ u8 ata_altstatus(struct ata_port *ap)
418 return inb(ap->ioaddr.altstatus_addr); 418 return inb(ap->ioaddr.altstatus_addr);
419} 419}
420 420
421/**
422 * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction
423 * @qc: Info associated with this ATA transaction.
424 *
425 * LOCKING:
426 * spin_lock_irqsave(host_set lock)
427 */
428
429static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
430{
431 struct ata_port *ap = qc->ap;
432 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
433 u8 dmactl;
434 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
435
436 /* load PRD table addr. */
437 mb(); /* make sure PRD table writes are visible to controller */
438 writel(ap->prd_dma, mmio + ATA_DMA_TABLE_OFS);
439
440 /* specify data direction, triple-check start bit is clear */
441 dmactl = readb(mmio + ATA_DMA_CMD);
442 dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
443 if (!rw)
444 dmactl |= ATA_DMA_WR;
445 writeb(dmactl, mmio + ATA_DMA_CMD);
446
447 /* issue r/w command */
448 ap->ops->exec_command(ap, &qc->tf);
449}
450
451/**
452 * ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction
453 * @qc: Info associated with this ATA transaction.
454 *
455 * LOCKING:
456 * spin_lock_irqsave(host_set lock)
457 */
458
459static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
460{
461 struct ata_port *ap = qc->ap;
462 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
463 u8 dmactl;
464
465 /* start host DMA transaction */
466 dmactl = readb(mmio + ATA_DMA_CMD);
467 writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
468
469 /* Strictly, one may wish to issue a readb() here, to
470 * flush the mmio write. However, control also passes
471 * to the hardware at this point, and it will interrupt
472 * us when we are to resume control. So, in effect,
473 * we don't care when the mmio write flushes.
474 * Further, a read of the DMA status register _immediately_
475 * following the write may not be what certain flaky hardware
476 * is expected, so I think it is best to not add a readb()
477 * without first all the MMIO ATA cards/mobos.
478 * Or maybe I'm just being paranoid.
479 */
480}
481
482/**
483 * ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO)
484 * @qc: Info associated with this ATA transaction.
485 *
486 * LOCKING:
487 * spin_lock_irqsave(host_set lock)
488 */
489
490static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
491{
492 struct ata_port *ap = qc->ap;
493 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
494 u8 dmactl;
495
496 /* load PRD table addr. */
497 outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
498
499 /* specify data direction, triple-check start bit is clear */
500 dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
501 dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
502 if (!rw)
503 dmactl |= ATA_DMA_WR;
504 outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
505
506 /* issue r/w command */
507 ap->ops->exec_command(ap, &qc->tf);
508}
509
510/**
511 * ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO)
512 * @qc: Info associated with this ATA transaction.
513 *
514 * LOCKING:
515 * spin_lock_irqsave(host_set lock)
516 */
517
518static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
519{
520 struct ata_port *ap = qc->ap;
521 u8 dmactl;
522
523 /* start host DMA transaction */
524 dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
525 outb(dmactl | ATA_DMA_START,
526 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
527}
528
529
530/**
531 * ata_bmdma_start - Start a PCI IDE BMDMA transaction
532 * @qc: Info associated with this ATA transaction.
533 *
534 * Writes the ATA_DMA_START flag to the DMA command register.
535 *
536 * May be used as the bmdma_start() entry in ata_port_operations.
537 *
538 * LOCKING:
539 * spin_lock_irqsave(host_set lock)
540 */
541void ata_bmdma_start(struct ata_queued_cmd *qc)
542{
543 if (qc->ap->flags & ATA_FLAG_MMIO)
544 ata_bmdma_start_mmio(qc);
545 else
546 ata_bmdma_start_pio(qc);
547}
548
549
550/**
551 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
552 * @qc: Info associated with this ATA transaction.
553 *
554 * Writes address of PRD table to device's PRD Table Address
555 * register, sets the DMA control register, and calls
556 * ops->exec_command() to start the transfer.
557 *
558 * May be used as the bmdma_setup() entry in ata_port_operations.
559 *
560 * LOCKING:
561 * spin_lock_irqsave(host_set lock)
562 */
563void ata_bmdma_setup(struct ata_queued_cmd *qc)
564{
565 if (qc->ap->flags & ATA_FLAG_MMIO)
566 ata_bmdma_setup_mmio(qc);
567 else
568 ata_bmdma_setup_pio(qc);
569}
570
571
572/**
573 * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.
574 * @ap: Port associated with this ATA transaction.
575 *
576 * Clear interrupt and error flags in DMA status register.
577 *
578 * May be used as the irq_clear() entry in ata_port_operations.
579 *
580 * LOCKING:
581 * spin_lock_irqsave(host_set lock)
582 */
583
584void ata_bmdma_irq_clear(struct ata_port *ap)
585{
586 if (!ap->ioaddr.bmdma_addr)
587 return;
588
589 if (ap->flags & ATA_FLAG_MMIO) {
590 void __iomem *mmio =
591 ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
592 writeb(readb(mmio), mmio);
593 } else {
594 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
595 outb(inb(addr), addr);
596 }
597}
598
599
600/**
601 * ata_bmdma_status - Read PCI IDE BMDMA status
602 * @ap: Port associated with this ATA transaction.
603 *
604 * Read and return BMDMA status register.
605 *
606 * May be used as the bmdma_status() entry in ata_port_operations.
607 *
608 * LOCKING:
609 * spin_lock_irqsave(host_set lock)
610 */
611
612u8 ata_bmdma_status(struct ata_port *ap)
613{
614 u8 host_stat;
615 if (ap->flags & ATA_FLAG_MMIO) {
616 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
617 host_stat = readb(mmio + ATA_DMA_STATUS);
618 } else
619 host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
620 return host_stat;
621}
622
623
624/**
625 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
626 * @qc: Command we are ending DMA for
627 *
628 * Clears the ATA_DMA_START flag in the dma control register
629 *
630 * May be used as the bmdma_stop() entry in ata_port_operations.
631 *
632 * LOCKING:
633 * spin_lock_irqsave(host_set lock)
634 */
635
636void ata_bmdma_stop(struct ata_queued_cmd *qc)
637{
638 struct ata_port *ap = qc->ap;
639 if (ap->flags & ATA_FLAG_MMIO) {
640 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
641
642 /* clear start/stop bit */
643 writeb(readb(mmio + ATA_DMA_CMD) & ~ATA_DMA_START,
644 mmio + ATA_DMA_CMD);
645 } else {
646 /* clear start/stop bit */
647 outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
648 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
649 }
650
651 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
652 ata_altstatus(ap); /* dummy read */
653}
654
421#ifdef CONFIG_PCI 655#ifdef CONFIG_PCI
422static struct ata_probe_ent * 656static struct ata_probe_ent *
423ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port) 657ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
@@ -707,7 +941,7 @@ err_out:
707 * @pdev: PCI device 941 * @pdev: PCI device
708 * 942 *
709 * Some PCI ATA devices report simplex mode but in fact can be told to 943 * Some PCI ATA devices report simplex mode but in fact can be told to
710 * enter non simplex mode. This implements the neccessary logic to 944 * enter non simplex mode. This implements the neccessary logic to
711 * perform the task on such devices. Calling it on other devices will 945 * perform the task on such devices. Calling it on other devices will
712 * have -undefined- behaviour. 946 * have -undefined- behaviour.
713 */ 947 */
@@ -732,7 +966,7 @@ unsigned long ata_pci_default_filter(const struct ata_port *ap, struct ata_devic
732{ 966{
733 /* Filter out DMA modes if the device has been configured by 967 /* Filter out DMA modes if the device has been configured by
734 the BIOS as PIO only */ 968 the BIOS as PIO only */
735 969
736 if (ap->ioaddr.bmdma_addr == 0) 970 if (ap->ioaddr.bmdma_addr == 0)
737 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 971 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
738 return xfer_mask; 972 return xfer_mask;
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 0314abd97f2d..d279666dcb38 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -64,9 +64,9 @@
64static unsigned int ata_dev_init_params(struct ata_port *ap, 64static unsigned int ata_dev_init_params(struct ata_port *ap,
65 struct ata_device *dev); 65 struct ata_device *dev);
66static void ata_set_mode(struct ata_port *ap); 66static void ata_set_mode(struct ata_port *ap);
67static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); 67static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
68static unsigned int ata_dev_xfermask(struct ata_port *ap, 68 struct ata_device *dev);
69 struct ata_device *dev); 69static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev);
70 70
71static unsigned int ata_unique_id = 1; 71static unsigned int ata_unique_id = 1;
72static struct workqueue_struct *ata_wq; 72static struct workqueue_struct *ata_wq;
@@ -190,7 +190,7 @@ static const u8 ata_rw_cmds[] = {
190 * ata_rwcmd_protocol - set taskfile r/w commands and protocol 190 * ata_rwcmd_protocol - set taskfile r/w commands and protocol
191 * @qc: command to examine and configure 191 * @qc: command to examine and configure
192 * 192 *
193 * Examine the device configuration and tf->flags to calculate 193 * Examine the device configuration and tf->flags to calculate
194 * the proper read/write commands and protocol to use. 194 * the proper read/write commands and protocol to use.
195 * 195 *
196 * LOCKING: 196 * LOCKING:
@@ -203,7 +203,7 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
203 u8 cmd; 203 u8 cmd;
204 204
205 int index, fua, lba48, write; 205 int index, fua, lba48, write;
206 206
207 fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; 207 fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0;
208 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; 208 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0;
209 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; 209 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0;
@@ -252,6 +252,29 @@ static unsigned int ata_pack_xfermask(unsigned int pio_mask,
252 ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA); 252 ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA);
253} 253}
254 254
255/**
256 * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks
257 * @xfer_mask: xfer_mask to unpack
258 * @pio_mask: resulting pio_mask
259 * @mwdma_mask: resulting mwdma_mask
260 * @udma_mask: resulting udma_mask
261 *
262 * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask.
263 * Any NULL distination masks will be ignored.
264 */
265static void ata_unpack_xfermask(unsigned int xfer_mask,
266 unsigned int *pio_mask,
267 unsigned int *mwdma_mask,
268 unsigned int *udma_mask)
269{
270 if (pio_mask)
271 *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO;
272 if (mwdma_mask)
273 *mwdma_mask = (xfer_mask & ATA_MASK_MWDMA) >> ATA_SHIFT_MWDMA;
274 if (udma_mask)
275 *udma_mask = (xfer_mask & ATA_MASK_UDMA) >> ATA_SHIFT_UDMA;
276}
277
255static const struct ata_xfer_ent { 278static const struct ata_xfer_ent {
256 unsigned int shift, bits; 279 unsigned int shift, bits;
257 u8 base; 280 u8 base;
@@ -372,6 +395,15 @@ static const char *ata_mode_string(unsigned int xfer_mask)
372 return "<n/a>"; 395 return "<n/a>";
373} 396}
374 397
398static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
399{
400 if (ata_dev_present(dev)) {
401 printk(KERN_WARNING "ata%u: dev %u disabled\n",
402 ap->id, dev->devno);
403 dev->class++;
404 }
405}
406
375/** 407/**
376 * ata_pio_devchk - PATA device presence detection 408 * ata_pio_devchk - PATA device presence detection
377 * @ap: ATA channel to examine 409 * @ap: ATA channel to examine
@@ -987,6 +1019,22 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
987 1019
988 ata_qc_free(qc); 1020 ata_qc_free(qc);
989 1021
1022 /* XXX - Some LLDDs (sata_mv) disable port on command failure.
1023 * Until those drivers are fixed, we detect the condition
1024 * here, fail the command with AC_ERR_SYSTEM and reenable the
1025 * port.
1026 *
1027 * Note that this doesn't change any behavior as internal
1028 * command failure results in disabling the device in the
1029 * higher layer for LLDDs without new reset/EH callbacks.
1030 *
1031 * Kill the following code as soon as those drivers are fixed.
1032 */
1033 if (ap->flags & ATA_FLAG_PORT_DISABLED) {
1034 err_mask |= AC_ERR_SYSTEM;
1035 ata_port_probe(ap);
1036 }
1037
990 return err_mask; 1038 return err_mask;
991} 1039}
992 1040
@@ -1007,7 +1055,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1007 return 0; 1055 return 0;
1008 if (speed > 2) 1056 if (speed > 2)
1009 return 1; 1057 return 1;
1010 1058
1011 /* If we have no drive specific rule, then PIO 2 is non IORDY */ 1059 /* If we have no drive specific rule, then PIO 2 is non IORDY */
1012 1060
1013 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */ 1061 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */
@@ -1305,7 +1353,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1305 if (print_info) 1353 if (print_info)
1306 printk(KERN_INFO "ata%u(%u): applying bridge limits\n", 1354 printk(KERN_INFO "ata%u(%u): applying bridge limits\n",
1307 ap->id, dev->devno); 1355 ap->id, dev->devno);
1308 ap->udma_mask &= ATA_UDMA5; 1356 dev->udma_mask &= ATA_UDMA5;
1309 dev->max_sectors = ATA_MAX_SECTORS; 1357 dev->max_sectors = ATA_MAX_SECTORS;
1310 } 1358 }
1311 1359
@@ -1316,8 +1364,6 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1316 return 0; 1364 return 0;
1317 1365
1318err_out_nosup: 1366err_out_nosup:
1319 printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n",
1320 ap->id, dev->devno);
1321 DPRINTK("EXIT, err\n"); 1367 DPRINTK("EXIT, err\n");
1322 return rc; 1368 return rc;
1323} 1369}
@@ -1384,7 +1430,7 @@ static int ata_bus_probe(struct ata_port *ap)
1384 } 1430 }
1385 1431
1386 if (ata_dev_configure(ap, dev, 1)) { 1432 if (ata_dev_configure(ap, dev, 1)) {
1387 dev->class++; /* disable device */ 1433 ata_dev_disable(ap, dev);
1388 continue; 1434 continue;
1389 } 1435 }
1390 1436
@@ -1530,6 +1576,23 @@ void sata_phy_reset(struct ata_port *ap)
1530} 1576}
1531 1577
1532/** 1578/**
1579 * ata_dev_pair - return other device on cable
1580 * @ap: port
1581 * @adev: device
1582 *
1583 * Obtain the other device on the same cable, or if none is
1584 * present NULL is returned
1585 */
1586
1587struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev)
1588{
1589 struct ata_device *pair = &ap->device[1 - adev->devno];
1590 if (!ata_dev_present(pair))
1591 return NULL;
1592 return pair;
1593}
1594
1595/**
1533 * ata_port_disable - Disable port. 1596 * ata_port_disable - Disable port.
1534 * @ap: Port to be disabled. 1597 * @ap: Port to be disabled.
1535 * 1598 *
@@ -1557,7 +1620,7 @@ void ata_port_disable(struct ata_port *ap)
1557 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). 1620 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
1558 * These were taken from ATA/ATAPI-6 standard, rev 0a, except 1621 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
1559 * for PIO 5, which is a nonstandard extension and UDMA6, which 1622 * for PIO 5, which is a nonstandard extension and UDMA6, which
1560 * is currently supported only by Maxtor drives. 1623 * is currently supported only by Maxtor drives.
1561 */ 1624 */
1562 1625
1563static const struct ata_timing ata_timing[] = { 1626static const struct ata_timing ata_timing[] = {
@@ -1572,11 +1635,11 @@ static const struct ata_timing ata_timing[] = {
1572 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, 1635 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
1573 1636
1574/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */ 1637/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */
1575 1638
1576 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, 1639 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
1577 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, 1640 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
1578 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 }, 1641 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
1579 1642
1580 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 }, 1643 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
1581 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, 1644 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
1582 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, 1645 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
@@ -1629,7 +1692,7 @@ static const struct ata_timing* ata_timing_find_mode(unsigned short speed)
1629 for (t = ata_timing; t->mode != speed; t++) 1692 for (t = ata_timing; t->mode != speed; t++)
1630 if (t->mode == 0xFF) 1693 if (t->mode == 0xFF)
1631 return NULL; 1694 return NULL;
1632 return t; 1695 return t;
1633} 1696}
1634 1697
1635int ata_timing_compute(struct ata_device *adev, unsigned short speed, 1698int ata_timing_compute(struct ata_device *adev, unsigned short speed,
@@ -1639,7 +1702,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1639 struct ata_timing p; 1702 struct ata_timing p;
1640 1703
1641 /* 1704 /*
1642 * Find the mode. 1705 * Find the mode.
1643 */ 1706 */
1644 1707
1645 if (!(s = ata_timing_find_mode(speed))) 1708 if (!(s = ata_timing_find_mode(speed)))
@@ -1697,20 +1760,28 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1697 return 0; 1760 return 0;
1698} 1761}
1699 1762
1700static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) 1763static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
1701{ 1764{
1702 if (!ata_dev_present(dev) || (ap->flags & ATA_FLAG_PORT_DISABLED)) 1765 unsigned int err_mask;
1703 return; 1766 int rc;
1704 1767
1705 if (dev->xfer_shift == ATA_SHIFT_PIO) 1768 if (dev->xfer_shift == ATA_SHIFT_PIO)
1706 dev->flags |= ATA_DFLAG_PIO; 1769 dev->flags |= ATA_DFLAG_PIO;
1707 1770
1708 ata_dev_set_xfermode(ap, dev); 1771 err_mask = ata_dev_set_xfermode(ap, dev);
1772 if (err_mask) {
1773 printk(KERN_ERR
1774 "ata%u: failed to set xfermode (err_mask=0x%x)\n",
1775 ap->id, err_mask);
1776 return -EIO;
1777 }
1709 1778
1710 if (ata_dev_revalidate(ap, dev, 0)) { 1779 rc = ata_dev_revalidate(ap, dev, 0);
1711 printk(KERN_ERR "ata%u: failed to revalidate after set " 1780 if (rc) {
1712 "xfermode, disabled\n", ap->id); 1781 printk(KERN_ERR
1713 ata_port_disable(ap); 1782 "ata%u: failed to revalidate after set xfermode\n",
1783 ap->id);
1784 return rc;
1714 } 1785 }
1715 1786
1716 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", 1787 DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
@@ -1719,6 +1790,7 @@ static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
1719 printk(KERN_INFO "ata%u: dev %u configured for %s\n", 1790 printk(KERN_INFO "ata%u: dev %u configured for %s\n",
1720 ap->id, dev->devno, 1791 ap->id, dev->devno,
1721 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode))); 1792 ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)));
1793 return 0;
1722} 1794}
1723 1795
1724static int ata_host_set_pio(struct ata_port *ap) 1796static int ata_host_set_pio(struct ata_port *ap)
@@ -1778,16 +1850,19 @@ static void ata_set_mode(struct ata_port *ap)
1778 /* step 1: calculate xfer_mask */ 1850 /* step 1: calculate xfer_mask */
1779 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1851 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1780 struct ata_device *dev = &ap->device[i]; 1852 struct ata_device *dev = &ap->device[i];
1781 unsigned int xfer_mask; 1853 unsigned int pio_mask, dma_mask;
1782 1854
1783 if (!ata_dev_present(dev)) 1855 if (!ata_dev_present(dev))
1784 continue; 1856 continue;
1785 1857
1786 xfer_mask = ata_dev_xfermask(ap, dev); 1858 ata_dev_xfermask(ap, dev);
1859
1860 /* TODO: let LLDD filter dev->*_mask here */
1787 1861
1788 dev->pio_mode = ata_xfer_mask2mode(xfer_mask & ATA_MASK_PIO); 1862 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
1789 dev->dma_mode = ata_xfer_mask2mode(xfer_mask & (ATA_MASK_MWDMA | 1863 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
1790 ATA_MASK_UDMA)); 1864 dev->pio_mode = ata_xfer_mask2mode(pio_mask);
1865 dev->dma_mode = ata_xfer_mask2mode(dma_mask);
1791 } 1866 }
1792 1867
1793 /* step 2: always set host PIO timings */ 1868 /* step 2: always set host PIO timings */
@@ -1799,11 +1874,15 @@ static void ata_set_mode(struct ata_port *ap)
1799 ata_host_set_dma(ap); 1874 ata_host_set_dma(ap);
1800 1875
1801 /* step 4: update devices' xfer mode */ 1876 /* step 4: update devices' xfer mode */
1802 for (i = 0; i < ATA_MAX_DEVICES; i++) 1877 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1803 ata_dev_set_mode(ap, &ap->device[i]); 1878 struct ata_device *dev = &ap->device[i];
1804 1879
1805 if (ap->flags & ATA_FLAG_PORT_DISABLED) 1880 if (!ata_dev_present(dev))
1806 return; 1881 continue;
1882
1883 if (ata_dev_set_mode(ap, dev))
1884 goto err_out;
1885 }
1807 1886
1808 if (ap->ops->post_set_mode) 1887 if (ap->ops->post_set_mode)
1809 ap->ops->post_set_mode(ap); 1888 ap->ops->post_set_mode(ap);
@@ -1999,11 +2078,11 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
1999 */ 2078 */
2000 msleep(150); 2079 msleep(150);
2001 2080
2002 2081
2003 /* Before we perform post reset processing we want to see if 2082 /* Before we perform post reset processing we want to see if
2004 the bus shows 0xFF because the odd clown forgets the D7 pulldown 2083 the bus shows 0xFF because the odd clown forgets the D7 pulldown
2005 resistor */ 2084 resistor */
2006 2085
2007 if (ata_check_status(ap) == 0xFF) 2086 if (ata_check_status(ap) == 0xFF)
2008 return 1; /* Positive is failure for some reason */ 2087 return 1; /* Positive is failure for some reason */
2009 2088
@@ -2572,22 +2651,22 @@ static const char * const ata_dma_blacklist [] = {
2572 "SanDisk SDP3B-64", NULL, 2651 "SanDisk SDP3B-64", NULL,
2573 "SANYO CD-ROM CRD", NULL, 2652 "SANYO CD-ROM CRD", NULL,
2574 "HITACHI CDR-8", NULL, 2653 "HITACHI CDR-8", NULL,
2575 "HITACHI CDR-8335", NULL, 2654 "HITACHI CDR-8335", NULL,
2576 "HITACHI CDR-8435", NULL, 2655 "HITACHI CDR-8435", NULL,
2577 "Toshiba CD-ROM XM-6202B", NULL, 2656 "Toshiba CD-ROM XM-6202B", NULL,
2578 "TOSHIBA CD-ROM XM-1702BC", NULL, 2657 "TOSHIBA CD-ROM XM-1702BC", NULL,
2579 "CD-532E-A", NULL, 2658 "CD-532E-A", NULL,
2580 "E-IDE CD-ROM CR-840", NULL, 2659 "E-IDE CD-ROM CR-840", NULL,
2581 "CD-ROM Drive/F5A", NULL, 2660 "CD-ROM Drive/F5A", NULL,
2582 "WPI CDD-820", NULL, 2661 "WPI CDD-820", NULL,
2583 "SAMSUNG CD-ROM SC-148C", NULL, 2662 "SAMSUNG CD-ROM SC-148C", NULL,
2584 "SAMSUNG CD-ROM SC", NULL, 2663 "SAMSUNG CD-ROM SC", NULL,
2585 "SanDisk SDP3B-64", NULL, 2664 "SanDisk SDP3B-64", NULL,
2586 "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL, 2665 "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,
2587 "_NEC DV5800A", NULL, 2666 "_NEC DV5800A", NULL,
2588 "SAMSUNG CD-ROM SN-124", "N001" 2667 "SAMSUNG CD-ROM SN-124", "N001"
2589}; 2668};
2590 2669
2591static int ata_strim(char *s, size_t len) 2670static int ata_strim(char *s, size_t len)
2592{ 2671{
2593 len = strnlen(s, len); 2672 len = strnlen(s, len);
@@ -2630,18 +2709,15 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
2630 * @ap: Port on which the device to compute xfermask for resides 2709 * @ap: Port on which the device to compute xfermask for resides
2631 * @dev: Device to compute xfermask for 2710 * @dev: Device to compute xfermask for
2632 * 2711 *
2633 * Compute supported xfermask of @dev. This function is 2712 * Compute supported xfermask of @dev and store it in
2634 * responsible for applying all known limits including host 2713 * dev->*_mask. This function is responsible for applying all
2635 * controller limits, device blacklist, etc... 2714 * known limits including host controller limits, device
2715 * blacklist, etc...
2636 * 2716 *
2637 * LOCKING: 2717 * LOCKING:
2638 * None. 2718 * None.
2639 *
2640 * RETURNS:
2641 * Computed xfermask.
2642 */ 2719 */
2643static unsigned int ata_dev_xfermask(struct ata_port *ap, 2720static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev)
2644 struct ata_device *dev)
2645{ 2721{
2646 unsigned long xfer_mask; 2722 unsigned long xfer_mask;
2647 int i; 2723 int i;
@@ -2654,6 +2730,8 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap,
2654 struct ata_device *d = &ap->device[i]; 2730 struct ata_device *d = &ap->device[i];
2655 if (!ata_dev_present(d)) 2731 if (!ata_dev_present(d))
2656 continue; 2732 continue;
2733 xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask,
2734 d->udma_mask);
2657 xfer_mask &= ata_id_xfermask(d->id); 2735 xfer_mask &= ata_id_xfermask(d->id);
2658 if (ata_dma_blacklisted(d)) 2736 if (ata_dma_blacklisted(d))
2659 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 2737 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
@@ -2663,7 +2741,8 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap,
2663 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, " 2741 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, "
2664 "disabling DMA\n", ap->id, dev->devno); 2742 "disabling DMA\n", ap->id, dev->devno);
2665 2743
2666 return xfer_mask; 2744 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask,
2745 &dev->udma_mask);
2667} 2746}
2668 2747
2669/** 2748/**
@@ -2676,11 +2755,16 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap,
2676 * 2755 *
2677 * LOCKING: 2756 * LOCKING:
2678 * PCI/etc. bus probe sem. 2757 * PCI/etc. bus probe sem.
2758 *
2759 * RETURNS:
2760 * 0 on success, AC_ERR_* mask otherwise.
2679 */ 2761 */
2680 2762
2681static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) 2763static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
2764 struct ata_device *dev)
2682{ 2765{
2683 struct ata_taskfile tf; 2766 struct ata_taskfile tf;
2767 unsigned int err_mask;
2684 2768
2685 /* set up set-features taskfile */ 2769 /* set up set-features taskfile */
2686 DPRINTK("set features - xfer mode\n"); 2770 DPRINTK("set features - xfer mode\n");
@@ -2692,13 +2776,10 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2692 tf.protocol = ATA_PROT_NODATA; 2776 tf.protocol = ATA_PROT_NODATA;
2693 tf.nsect = dev->xfer_mode; 2777 tf.nsect = dev->xfer_mode;
2694 2778
2695 if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { 2779 err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
2696 printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n",
2697 ap->id);
2698 ata_port_disable(ap);
2699 }
2700 2780
2701 DPRINTK("EXIT\n"); 2781 DPRINTK("EXIT, err_mask=%x\n", err_mask);
2782 return err_mask;
2702} 2783}
2703 2784
2704/** 2785/**
@@ -2775,7 +2856,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2775 2856
2776 if (qc->flags & ATA_QCFLAG_SG) { 2857 if (qc->flags & ATA_QCFLAG_SG) {
2777 if (qc->n_elem) 2858 if (qc->n_elem)
2778 dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir); 2859 dma_unmap_sg(ap->dev, sg, qc->n_elem, dir);
2779 /* restore last sg */ 2860 /* restore last sg */
2780 sg[qc->orig_n_elem - 1].length += qc->pad_len; 2861 sg[qc->orig_n_elem - 1].length += qc->pad_len;
2781 if (pad_buf) { 2862 if (pad_buf) {
@@ -2786,7 +2867,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2786 } 2867 }
2787 } else { 2868 } else {
2788 if (qc->n_elem) 2869 if (qc->n_elem)
2789 dma_unmap_single(ap->host_set->dev, 2870 dma_unmap_single(ap->dev,
2790 sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), 2871 sg_dma_address(&sg[0]), sg_dma_len(&sg[0]),
2791 dir); 2872 dir);
2792 /* restore sg */ 2873 /* restore sg */
@@ -2997,7 +3078,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2997 goto skip_map; 3078 goto skip_map;
2998 } 3079 }
2999 3080
3000 dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, 3081 dma_address = dma_map_single(ap->dev, qc->buf_virt,
3001 sg->length, dir); 3082 sg->length, dir);
3002 if (dma_mapping_error(dma_address)) { 3083 if (dma_mapping_error(dma_address)) {
3003 /* restore sg */ 3084 /* restore sg */
@@ -3085,7 +3166,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
3085 } 3166 }
3086 3167
3087 dir = qc->dma_dir; 3168 dir = qc->dma_dir;
3088 n_elem = dma_map_sg(ap->host_set->dev, sg, pre_n_elem, dir); 3169 n_elem = dma_map_sg(ap->dev, sg, pre_n_elem, dir);
3089 if (n_elem < 1) { 3170 if (n_elem < 1) {
3090 /* restore last sg */ 3171 /* restore last sg */
3091 lsg->length += qc->pad_len; 3172 lsg->length += qc->pad_len;
@@ -3616,7 +3697,7 @@ static void ata_pio_error(struct ata_port *ap)
3616 if (qc->tf.command != ATA_CMD_PACKET) 3697 if (qc->tf.command != ATA_CMD_PACKET)
3617 printk(KERN_WARNING "ata%u: PIO error\n", ap->id); 3698 printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
3618 3699
3619 /* make sure qc->err_mask is available to 3700 /* make sure qc->err_mask is available to
3620 * know what's wrong and recover 3701 * know what's wrong and recover
3621 */ 3702 */
3622 WARN_ON(qc->err_mask == 0); 3703 WARN_ON(qc->err_mask == 0);
@@ -4065,240 +4146,6 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4065} 4146}
4066 4147
4067/** 4148/**
4068 * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction
4069 * @qc: Info associated with this ATA transaction.
4070 *
4071 * LOCKING:
4072 * spin_lock_irqsave(host_set lock)
4073 */
4074
4075static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
4076{
4077 struct ata_port *ap = qc->ap;
4078 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
4079 u8 dmactl;
4080 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
4081
4082 /* load PRD table addr. */
4083 mb(); /* make sure PRD table writes are visible to controller */
4084 writel(ap->prd_dma, mmio + ATA_DMA_TABLE_OFS);
4085
4086 /* specify data direction, triple-check start bit is clear */
4087 dmactl = readb(mmio + ATA_DMA_CMD);
4088 dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
4089 if (!rw)
4090 dmactl |= ATA_DMA_WR;
4091 writeb(dmactl, mmio + ATA_DMA_CMD);
4092
4093 /* issue r/w command */
4094 ap->ops->exec_command(ap, &qc->tf);
4095}
4096
4097/**
4098 * ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction
4099 * @qc: Info associated with this ATA transaction.
4100 *
4101 * LOCKING:
4102 * spin_lock_irqsave(host_set lock)
4103 */
4104
4105static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
4106{
4107 struct ata_port *ap = qc->ap;
4108 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
4109 u8 dmactl;
4110
4111 /* start host DMA transaction */
4112 dmactl = readb(mmio + ATA_DMA_CMD);
4113 writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
4114
4115 /* Strictly, one may wish to issue a readb() here, to
4116 * flush the mmio write. However, control also passes
4117 * to the hardware at this point, and it will interrupt
4118 * us when we are to resume control. So, in effect,
4119 * we don't care when the mmio write flushes.
4120 * Further, a read of the DMA status register _immediately_
4121 * following the write may not be what certain flaky hardware
4122 * is expected, so I think it is best to not add a readb()
4123 * without first all the MMIO ATA cards/mobos.
4124 * Or maybe I'm just being paranoid.
4125 */
4126}
4127
4128/**
4129 * ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO)
4130 * @qc: Info associated with this ATA transaction.
4131 *
4132 * LOCKING:
4133 * spin_lock_irqsave(host_set lock)
4134 */
4135
4136static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
4137{
4138 struct ata_port *ap = qc->ap;
4139 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
4140 u8 dmactl;
4141
4142 /* load PRD table addr. */
4143 outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
4144
4145 /* specify data direction, triple-check start bit is clear */
4146 dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
4147 dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
4148 if (!rw)
4149 dmactl |= ATA_DMA_WR;
4150 outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
4151
4152 /* issue r/w command */
4153 ap->ops->exec_command(ap, &qc->tf);
4154}
4155
4156/**
4157 * ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO)
4158 * @qc: Info associated with this ATA transaction.
4159 *
4160 * LOCKING:
4161 * spin_lock_irqsave(host_set lock)
4162 */
4163
4164static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
4165{
4166 struct ata_port *ap = qc->ap;
4167 u8 dmactl;
4168
4169 /* start host DMA transaction */
4170 dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
4171 outb(dmactl | ATA_DMA_START,
4172 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
4173}
4174
4175
4176/**
4177 * ata_bmdma_start - Start a PCI IDE BMDMA transaction
4178 * @qc: Info associated with this ATA transaction.
4179 *
4180 * Writes the ATA_DMA_START flag to the DMA command register.
4181 *
4182 * May be used as the bmdma_start() entry in ata_port_operations.
4183 *
4184 * LOCKING:
4185 * spin_lock_irqsave(host_set lock)
4186 */
4187void ata_bmdma_start(struct ata_queued_cmd *qc)
4188{
4189 if (qc->ap->flags & ATA_FLAG_MMIO)
4190 ata_bmdma_start_mmio(qc);
4191 else
4192 ata_bmdma_start_pio(qc);
4193}
4194
4195
4196/**
4197 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
4198 * @qc: Info associated with this ATA transaction.
4199 *
4200 * Writes address of PRD table to device's PRD Table Address
4201 * register, sets the DMA control register, and calls
4202 * ops->exec_command() to start the transfer.
4203 *
4204 * May be used as the bmdma_setup() entry in ata_port_operations.
4205 *
4206 * LOCKING:
4207 * spin_lock_irqsave(host_set lock)
4208 */
4209void ata_bmdma_setup(struct ata_queued_cmd *qc)
4210{
4211 if (qc->ap->flags & ATA_FLAG_MMIO)
4212 ata_bmdma_setup_mmio(qc);
4213 else
4214 ata_bmdma_setup_pio(qc);
4215}
4216
4217
4218/**
4219 * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.
4220 * @ap: Port associated with this ATA transaction.
4221 *
4222 * Clear interrupt and error flags in DMA status register.
4223 *
4224 * May be used as the irq_clear() entry in ata_port_operations.
4225 *
4226 * LOCKING:
4227 * spin_lock_irqsave(host_set lock)
4228 */
4229
4230void ata_bmdma_irq_clear(struct ata_port *ap)
4231{
4232 if (!ap->ioaddr.bmdma_addr)
4233 return;
4234
4235 if (ap->flags & ATA_FLAG_MMIO) {
4236 void __iomem *mmio =
4237 ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
4238 writeb(readb(mmio), mmio);
4239 } else {
4240 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4241 outb(inb(addr), addr);
4242 }
4243}
4244
4245
4246/**
4247 * ata_bmdma_status - Read PCI IDE BMDMA status
4248 * @ap: Port associated with this ATA transaction.
4249 *
4250 * Read and return BMDMA status register.
4251 *
4252 * May be used as the bmdma_status() entry in ata_port_operations.
4253 *
4254 * LOCKING:
4255 * spin_lock_irqsave(host_set lock)
4256 */
4257
4258u8 ata_bmdma_status(struct ata_port *ap)
4259{
4260 u8 host_stat;
4261 if (ap->flags & ATA_FLAG_MMIO) {
4262 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
4263 host_stat = readb(mmio + ATA_DMA_STATUS);
4264 } else
4265 host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
4266 return host_stat;
4267}
4268
4269
4270/**
4271 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
4272 * @qc: Command we are ending DMA for
4273 *
4274 * Clears the ATA_DMA_START flag in the dma control register
4275 *
4276 * May be used as the bmdma_stop() entry in ata_port_operations.
4277 *
4278 * LOCKING:
4279 * spin_lock_irqsave(host_set lock)
4280 */
4281
4282void ata_bmdma_stop(struct ata_queued_cmd *qc)
4283{
4284 struct ata_port *ap = qc->ap;
4285 if (ap->flags & ATA_FLAG_MMIO) {
4286 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
4287
4288 /* clear start/stop bit */
4289 writeb(readb(mmio + ATA_DMA_CMD) & ~ATA_DMA_START,
4290 mmio + ATA_DMA_CMD);
4291 } else {
4292 /* clear start/stop bit */
4293 outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
4294 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
4295 }
4296
4297 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
4298 ata_altstatus(ap); /* dummy read */
4299}
4300
4301/**
4302 * ata_host_intr - Handle host interrupt for given (port, task) 4149 * ata_host_intr - Handle host interrupt for given (port, task)
4303 * @ap: Port on which interrupt arrived (possibly...) 4150 * @ap: Port on which interrupt arrived (possibly...)
4304 * @qc: Taskfile currently active in engine 4151 * @qc: Taskfile currently active in engine
@@ -4506,14 +4353,15 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
4506 * Flush the cache on the drive, if appropriate, then issue a 4353 * Flush the cache on the drive, if appropriate, then issue a
4507 * standbynow command. 4354 * standbynow command.
4508 */ 4355 */
4509int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) 4356int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state)
4510{ 4357{
4511 if (!ata_dev_present(dev)) 4358 if (!ata_dev_present(dev))
4512 return 0; 4359 return 0;
4513 if (dev->class == ATA_DEV_ATA) 4360 if (dev->class == ATA_DEV_ATA)
4514 ata_flush_cache(ap, dev); 4361 ata_flush_cache(ap, dev);
4515 4362
4516 ata_standby_drive(ap, dev); 4363 if (state.event != PM_EVENT_FREEZE)
4364 ata_standby_drive(ap, dev);
4517 ap->flags |= ATA_FLAG_SUSPENDED; 4365 ap->flags |= ATA_FLAG_SUSPENDED;
4518 return 0; 4366 return 0;
4519} 4367}
@@ -4533,7 +4381,7 @@ int ata_device_suspend(struct ata_port *ap, struct ata_device *dev)
4533 4381
4534int ata_port_start (struct ata_port *ap) 4382int ata_port_start (struct ata_port *ap)
4535{ 4383{
4536 struct device *dev = ap->host_set->dev; 4384 struct device *dev = ap->dev;
4537 int rc; 4385 int rc;
4538 4386
4539 ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL); 4387 ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL);
@@ -4566,7 +4414,7 @@ int ata_port_start (struct ata_port *ap)
4566 4414
4567void ata_port_stop (struct ata_port *ap) 4415void ata_port_stop (struct ata_port *ap)
4568{ 4416{
4569 struct device *dev = ap->host_set->dev; 4417 struct device *dev = ap->dev;
4570 4418
4571 dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); 4419 dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
4572 ata_pad_free(ap, dev); 4420 ata_pad_free(ap, dev);
@@ -4632,6 +4480,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4632 ap->host = host; 4480 ap->host = host;
4633 ap->ctl = ATA_DEVCTL_OBS; 4481 ap->ctl = ATA_DEVCTL_OBS;
4634 ap->host_set = host_set; 4482 ap->host_set = host_set;
4483 ap->dev = ent->dev;
4635 ap->port_no = port_no; 4484 ap->port_no = port_no;
4636 ap->hard_port_no = 4485 ap->hard_port_no =
4637 ent->legacy_mode ? ent->hard_port_no : port_no; 4486 ent->legacy_mode ? ent->hard_port_no : port_no;
@@ -4647,8 +4496,13 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4647 INIT_WORK(&ap->port_task, NULL, NULL); 4496 INIT_WORK(&ap->port_task, NULL, NULL);
4648 INIT_LIST_HEAD(&ap->eh_done_q); 4497 INIT_LIST_HEAD(&ap->eh_done_q);
4649 4498
4650 for (i = 0; i < ATA_MAX_DEVICES; i++) 4499 for (i = 0; i < ATA_MAX_DEVICES; i++) {
4651 ap->device[i].devno = i; 4500 struct ata_device *dev = &ap->device[i];
4501 dev->devno = i;
4502 dev->pio_mask = UINT_MAX;
4503 dev->mwdma_mask = UINT_MAX;
4504 dev->udma_mask = UINT_MAX;
4505 }
4652 4506
4653#ifdef ATA_IRQ_TRAP 4507#ifdef ATA_IRQ_TRAP
4654 ap->stats.unhandled_irq = 1; 4508 ap->stats.unhandled_irq = 1;
@@ -4842,7 +4696,7 @@ err_free_ret:
4842 * ata_host_set_remove - PCI layer callback for device removal 4696 * ata_host_set_remove - PCI layer callback for device removal
4843 * @host_set: ATA host set that was removed 4697 * @host_set: ATA host set that was removed
4844 * 4698 *
4845 * Unregister all objects associated with this host set. Free those 4699 * Unregister all objects associated with this host set. Free those
4846 * objects. 4700 * objects.
4847 * 4701 *
4848 * LOCKING: 4702 * LOCKING:
@@ -5114,6 +4968,8 @@ EXPORT_SYMBOL_GPL(ata_std_postreset);
5114EXPORT_SYMBOL_GPL(ata_std_probe_reset); 4968EXPORT_SYMBOL_GPL(ata_std_probe_reset);
5115EXPORT_SYMBOL_GPL(ata_drive_probe_reset); 4969EXPORT_SYMBOL_GPL(ata_drive_probe_reset);
5116EXPORT_SYMBOL_GPL(ata_dev_revalidate); 4970EXPORT_SYMBOL_GPL(ata_dev_revalidate);
4971EXPORT_SYMBOL_GPL(ata_dev_classify);
4972EXPORT_SYMBOL_GPL(ata_dev_pair);
5117EXPORT_SYMBOL_GPL(ata_port_disable); 4973EXPORT_SYMBOL_GPL(ata_port_disable);
5118EXPORT_SYMBOL_GPL(ata_ratelimit); 4974EXPORT_SYMBOL_GPL(ata_ratelimit);
5119EXPORT_SYMBOL_GPL(ata_busy_sleep); 4975EXPORT_SYMBOL_GPL(ata_busy_sleep);
@@ -5124,7 +4980,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_error);
5124EXPORT_SYMBOL_GPL(ata_scsi_slave_config); 4980EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
5125EXPORT_SYMBOL_GPL(ata_scsi_release); 4981EXPORT_SYMBOL_GPL(ata_scsi_release);
5126EXPORT_SYMBOL_GPL(ata_host_intr); 4982EXPORT_SYMBOL_GPL(ata_host_intr);
5127EXPORT_SYMBOL_GPL(ata_dev_classify);
5128EXPORT_SYMBOL_GPL(ata_id_string); 4983EXPORT_SYMBOL_GPL(ata_id_string);
5129EXPORT_SYMBOL_GPL(ata_id_c_string); 4984EXPORT_SYMBOL_GPL(ata_id_c_string);
5130EXPORT_SYMBOL_GPL(ata_scsi_simulate); 4985EXPORT_SYMBOL_GPL(ata_scsi_simulate);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index a1259b242b8e..628191bfd990 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)
256 scsi_cmd[14] = args[0]; 256 scsi_cmd[14] = args[0];
257 257
258 /* Good values for timeout and retries? Values below 258 /* Good values for timeout and retries? Values below
259 from scsi_ioctl_send_command() for default case... */ 259 from scsi_ioctl_send_command() for default case... */
260 if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr, 260 if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr,
261 (10*HZ), 5)) 261 (10*HZ), 5))
262 rc = -EIO; 262 rc = -EIO;
@@ -267,20 +267,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
267 267
268int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) 268int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
269{ 269{
270 struct ata_port *ap;
271 struct ata_device *dev;
272 int val = -EINVAL, rc = -EINVAL; 270 int val = -EINVAL, rc = -EINVAL;
273 271
274 ap = (struct ata_port *) &scsidev->host->hostdata[0];
275 if (!ap)
276 goto out;
277
278 dev = ata_scsi_find_dev(ap, scsidev);
279 if (!dev) {
280 rc = -ENODEV;
281 goto out;
282 }
283
284 switch (cmd) { 272 switch (cmd) {
285 case ATA_IOC_GET_IO32: 273 case ATA_IOC_GET_IO32:
286 val = 0; 274 val = 0;
@@ -309,7 +297,6 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
309 break; 297 break;
310 } 298 }
311 299
312out:
313 return rc; 300 return rc;
314} 301}
315 302
@@ -414,12 +401,12 @@ int ata_scsi_device_resume(struct scsi_device *sdev)
414 return ata_device_resume(ap, dev); 401 return ata_device_resume(ap, dev);
415} 402}
416 403
417int ata_scsi_device_suspend(struct scsi_device *sdev) 404int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
418{ 405{
419 struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; 406 struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
420 struct ata_device *dev = &ap->device[sdev->id]; 407 struct ata_device *dev = &ap->device[sdev->id];
421 408
422 return ata_device_suspend(ap, dev); 409 return ata_device_suspend(ap, dev, state);
423} 410}
424 411
425/** 412/**
@@ -438,7 +425,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev)
438 * LOCKING: 425 * LOCKING:
439 * spin_lock_irqsave(host_set lock) 426 * spin_lock_irqsave(host_set lock)
440 */ 427 */
441void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, 428void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
442 u8 *ascq) 429 u8 *ascq)
443{ 430{
444 int i; 431 int i;
@@ -495,7 +482,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
495 /* Look for drv_err */ 482 /* Look for drv_err */
496 for (i = 0; sense_table[i][0] != 0xFF; i++) { 483 for (i = 0; sense_table[i][0] != 0xFF; i++) {
497 /* Look for best matches first */ 484 /* Look for best matches first */
498 if ((sense_table[i][0] & drv_err) == 485 if ((sense_table[i][0] & drv_err) ==
499 sense_table[i][0]) { 486 sense_table[i][0]) {
500 *sk = sense_table[i][1]; 487 *sk = sense_table[i][1];
501 *asc = sense_table[i][2]; 488 *asc = sense_table[i][2];
@@ -518,7 +505,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
518 } 505 }
519 } 506 }
520 /* No error? Undecoded? */ 507 /* No error? Undecoded? */
521 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", 508 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
522 id, drv_stat); 509 id, drv_stat);
523 510
524 /* We need a sensible error return here, which is tricky, and one 511 /* We need a sensible error return here, which is tricky, and one
@@ -1150,14 +1137,14 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
1150 1137
1151 DPRINTK("block %u track %u cyl %u head %u sect %u\n", 1138 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
1152 (u32)block, track, cyl, head, sect); 1139 (u32)block, track, cyl, head, sect);
1153 1140
1154 /* Check whether the converted CHS can fit. 1141 /* Check whether the converted CHS can fit.
1155 Cylinder: 0-65535 1142 Cylinder: 0-65535
1156 Head: 0-15 1143 Head: 0-15
1157 Sector: 1-255*/ 1144 Sector: 1-255*/
1158 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) 1145 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
1159 goto out_of_range; 1146 goto out_of_range;
1160 1147
1161 tf->command = ATA_CMD_VERIFY; 1148 tf->command = ATA_CMD_VERIFY;
1162 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ 1149 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
1163 tf->lbal = sect; 1150 tf->lbal = sect;
@@ -1289,7 +1276,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1289 tf->lbal = block & 0xff; 1276 tf->lbal = block & 0xff;
1290 1277
1291 tf->device |= ATA_LBA; 1278 tf->device |= ATA_LBA;
1292 } else { 1279 } else {
1293 /* CHS */ 1280 /* CHS */
1294 u32 sect, head, cyl, track; 1281 u32 sect, head, cyl, track;
1295 1282
@@ -1309,8 +1296,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1309 DPRINTK("block %u track %u cyl %u head %u sect %u\n", 1296 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
1310 (u32)block, track, cyl, head, sect); 1297 (u32)block, track, cyl, head, sect);
1311 1298
1312 /* Check whether the converted CHS can fit. 1299 /* Check whether the converted CHS can fit.
1313 Cylinder: 0-65535 1300 Cylinder: 0-65535
1314 Head: 0-15 1301 Head: 0-15
1315 Sector: 1-255*/ 1302 Sector: 1-255*/
1316 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) 1303 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
@@ -1697,7 +1684,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1697 1684
1698 if (buflen > (ATA_SERNO_LEN + num + 3)) { 1685 if (buflen > (ATA_SERNO_LEN + num + 3)) {
1699 /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */ 1686 /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
1700 rbuf[num + 0] = 2; 1687 rbuf[num + 0] = 2;
1701 rbuf[num + 3] = ATA_SERNO_LEN; 1688 rbuf[num + 3] = ATA_SERNO_LEN;
1702 num += 4; 1689 num += 4;
1703 ata_id_string(args->id, (unsigned char *) rbuf + num, 1690 ata_id_string(args->id, (unsigned char *) rbuf + num,
@@ -1707,8 +1694,8 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1707 if (buflen > (sat_model_serial_desc_len + num + 3)) { 1694 if (buflen > (sat_model_serial_desc_len + num + 3)) {
1708 /* SAT defined lu model and serial numbers descriptor */ 1695 /* SAT defined lu model and serial numbers descriptor */
1709 /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */ 1696 /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
1710 rbuf[num + 0] = 2; 1697 rbuf[num + 0] = 2;
1711 rbuf[num + 1] = 1; 1698 rbuf[num + 1] = 1;
1712 rbuf[num + 3] = sat_model_serial_desc_len; 1699 rbuf[num + 3] = sat_model_serial_desc_len;
1713 num += 4; 1700 num += 4;
1714 memcpy(rbuf + num, "ATA ", 8); 1701 memcpy(rbuf + num, "ATA ", 8);
@@ -2597,6 +2584,21 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap,
2597#endif 2584#endif
2598} 2585}
2599 2586
2587static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
2588 struct ata_port *ap, struct ata_device *dev)
2589{
2590 if (dev->class == ATA_DEV_ATA) {
2591 ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
2592 cmd->cmnd[0]);
2593
2594 if (xlat_func)
2595 ata_scsi_translate(ap, dev, cmd, done, xlat_func);
2596 else
2597 ata_scsi_simulate(ap, dev, cmd, done);
2598 } else
2599 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
2600}
2601
2600/** 2602/**
2601 * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device 2603 * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
2602 * @cmd: SCSI command to be sent 2604 * @cmd: SCSI command to be sent
@@ -2631,24 +2633,13 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
2631 ata_scsi_dump_cdb(ap, cmd); 2633 ata_scsi_dump_cdb(ap, cmd);
2632 2634
2633 dev = ata_scsi_find_dev(ap, scsidev); 2635 dev = ata_scsi_find_dev(ap, scsidev);
2634 if (unlikely(!dev)) { 2636 if (likely(dev))
2637 __ata_scsi_queuecmd(cmd, done, ap, dev);
2638 else {
2635 cmd->result = (DID_BAD_TARGET << 16); 2639 cmd->result = (DID_BAD_TARGET << 16);
2636 done(cmd); 2640 done(cmd);
2637 goto out_unlock;
2638 } 2641 }
2639 2642
2640 if (dev->class == ATA_DEV_ATA) {
2641 ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
2642 cmd->cmnd[0]);
2643
2644 if (xlat_func)
2645 ata_scsi_translate(ap, dev, cmd, done, xlat_func);
2646 else
2647 ata_scsi_simulate(ap, dev, cmd, done);
2648 } else
2649 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
2650
2651out_unlock:
2652 spin_unlock(&ap->host_set->lock); 2643 spin_unlock(&ap->host_set->lock);
2653 spin_lock(shost->host_lock); 2644 spin_lock(shost->host_lock);
2654 return 0; 2645 return 0;
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index bf9f7f7ba354..c11e5ce6865e 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[])
2797 // available within 1 second, assume FW is initializing and wait 2797 // available within 1 second, assume FW is initializing and wait
2798 // for an extended amount of time 2798 // for an extended amount of time
2799 if (mbox->numstatus == 0xFF) { // status not yet available 2799 if (mbox->numstatus == 0xFF) { // status not yet available
2800 udelay(25);; 2800 udelay(25);
2801 2801
2802 for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) { 2802 for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) {
2803 rmb(); 2803 rmb();
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index e5b20c6afc18..f77bf183dfab 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -29,34 +29,6 @@
29 * NV-specific details such as register offsets, SATA phy location, 29 * NV-specific details such as register offsets, SATA phy location,
30 * hotplug info, etc. 30 * hotplug info, etc.
31 * 31 *
32 * 0.10
33 * - Fixed spurious interrupts issue seen with the Maxtor 6H500F0 500GB
34 * drive. Also made the check_hotplug() callbacks return whether there
35 * was a hotplug interrupt or not. This was not the source of the
36 * spurious interrupts, but is the right thing to do anyway.
37 *
38 * 0.09
39 * - Fixed bug introduced by 0.08's MCP51 and MCP55 support.
40 *
41 * 0.08
42 * - Added support for MCP51 and MCP55.
43 *
44 * 0.07
45 * - Added support for RAID class code.
46 *
47 * 0.06
48 * - Added generic SATA support by using a pci_device_id that filters on
49 * the IDE storage class code.
50 *
51 * 0.03
52 * - Fixed a bug where the hotplug handlers for non-CK804/MCP04 were using
53 * mmio_base, which is only set for the CK804/MCP04 case.
54 *
55 * 0.02
56 * - Added support for CK804 SATA controller.
57 *
58 * 0.01
59 * - Initial revision.
60 */ 32 */
61 33
62#include <linux/config.h> 34#include <linux/config.h>
@@ -74,53 +46,55 @@
74#define DRV_NAME "sata_nv" 46#define DRV_NAME "sata_nv"
75#define DRV_VERSION "0.8" 47#define DRV_VERSION "0.8"
76 48
77#define NV_PORTS 2 49enum {
78#define NV_PIO_MASK 0x1f 50 NV_PORTS = 2,
79#define NV_MWDMA_MASK 0x07 51 NV_PIO_MASK = 0x1f,
80#define NV_UDMA_MASK 0x7f 52 NV_MWDMA_MASK = 0x07,
81#define NV_PORT0_SCR_REG_OFFSET 0x00 53 NV_UDMA_MASK = 0x7f,
82#define NV_PORT1_SCR_REG_OFFSET 0x40 54 NV_PORT0_SCR_REG_OFFSET = 0x00,
83 55 NV_PORT1_SCR_REG_OFFSET = 0x40,
84#define NV_INT_STATUS 0x10 56
85#define NV_INT_STATUS_CK804 0x440 57 NV_INT_STATUS = 0x10,
86#define NV_INT_STATUS_PDEV_INT 0x01 58 NV_INT_STATUS_CK804 = 0x440,
87#define NV_INT_STATUS_PDEV_PM 0x02 59 NV_INT_STATUS_PDEV_INT = 0x01,
88#define NV_INT_STATUS_PDEV_ADDED 0x04 60 NV_INT_STATUS_PDEV_PM = 0x02,
89#define NV_INT_STATUS_PDEV_REMOVED 0x08 61 NV_INT_STATUS_PDEV_ADDED = 0x04,
90#define NV_INT_STATUS_SDEV_INT 0x10 62 NV_INT_STATUS_PDEV_REMOVED = 0x08,
91#define NV_INT_STATUS_SDEV_PM 0x20 63 NV_INT_STATUS_SDEV_INT = 0x10,
92#define NV_INT_STATUS_SDEV_ADDED 0x40 64 NV_INT_STATUS_SDEV_PM = 0x20,
93#define NV_INT_STATUS_SDEV_REMOVED 0x80 65 NV_INT_STATUS_SDEV_ADDED = 0x40,
94#define NV_INT_STATUS_PDEV_HOTPLUG (NV_INT_STATUS_PDEV_ADDED | \ 66 NV_INT_STATUS_SDEV_REMOVED = 0x80,
95 NV_INT_STATUS_PDEV_REMOVED) 67 NV_INT_STATUS_PDEV_HOTPLUG = (NV_INT_STATUS_PDEV_ADDED |
96#define NV_INT_STATUS_SDEV_HOTPLUG (NV_INT_STATUS_SDEV_ADDED | \ 68 NV_INT_STATUS_PDEV_REMOVED),
97 NV_INT_STATUS_SDEV_REMOVED) 69 NV_INT_STATUS_SDEV_HOTPLUG = (NV_INT_STATUS_SDEV_ADDED |
98#define NV_INT_STATUS_HOTPLUG (NV_INT_STATUS_PDEV_HOTPLUG | \ 70 NV_INT_STATUS_SDEV_REMOVED),
99 NV_INT_STATUS_SDEV_HOTPLUG) 71 NV_INT_STATUS_HOTPLUG = (NV_INT_STATUS_PDEV_HOTPLUG |
100 72 NV_INT_STATUS_SDEV_HOTPLUG),
101#define NV_INT_ENABLE 0x11 73
102#define NV_INT_ENABLE_CK804 0x441 74 NV_INT_ENABLE = 0x11,
103#define NV_INT_ENABLE_PDEV_MASK 0x01 75 NV_INT_ENABLE_CK804 = 0x441,
104#define NV_INT_ENABLE_PDEV_PM 0x02 76 NV_INT_ENABLE_PDEV_MASK = 0x01,
105#define NV_INT_ENABLE_PDEV_ADDED 0x04 77 NV_INT_ENABLE_PDEV_PM = 0x02,
106#define NV_INT_ENABLE_PDEV_REMOVED 0x08 78 NV_INT_ENABLE_PDEV_ADDED = 0x04,
107#define NV_INT_ENABLE_SDEV_MASK 0x10 79 NV_INT_ENABLE_PDEV_REMOVED = 0x08,
108#define NV_INT_ENABLE_SDEV_PM 0x20 80 NV_INT_ENABLE_SDEV_MASK = 0x10,
109#define NV_INT_ENABLE_SDEV_ADDED 0x40 81 NV_INT_ENABLE_SDEV_PM = 0x20,
110#define NV_INT_ENABLE_SDEV_REMOVED 0x80 82 NV_INT_ENABLE_SDEV_ADDED = 0x40,
111#define NV_INT_ENABLE_PDEV_HOTPLUG (NV_INT_ENABLE_PDEV_ADDED | \ 83 NV_INT_ENABLE_SDEV_REMOVED = 0x80,
112 NV_INT_ENABLE_PDEV_REMOVED) 84 NV_INT_ENABLE_PDEV_HOTPLUG = (NV_INT_ENABLE_PDEV_ADDED |
113#define NV_INT_ENABLE_SDEV_HOTPLUG (NV_INT_ENABLE_SDEV_ADDED | \ 85 NV_INT_ENABLE_PDEV_REMOVED),
114 NV_INT_ENABLE_SDEV_REMOVED) 86 NV_INT_ENABLE_SDEV_HOTPLUG = (NV_INT_ENABLE_SDEV_ADDED |
115#define NV_INT_ENABLE_HOTPLUG (NV_INT_ENABLE_PDEV_HOTPLUG | \ 87 NV_INT_ENABLE_SDEV_REMOVED),
116 NV_INT_ENABLE_SDEV_HOTPLUG) 88 NV_INT_ENABLE_HOTPLUG = (NV_INT_ENABLE_PDEV_HOTPLUG |
117 89 NV_INT_ENABLE_SDEV_HOTPLUG),
118#define NV_INT_CONFIG 0x12 90
119#define NV_INT_CONFIG_METHD 0x01 // 0 = INT, 1 = SMI 91 NV_INT_CONFIG = 0x12,
120 92 NV_INT_CONFIG_METHD = 0x01, // 0 = INT, 1 = SMI
121// For PCI config register 20 93
122#define NV_MCP_SATA_CFG_20 0x50 94 // For PCI config register 20
123#define NV_MCP_SATA_CFG_20_SATA_SPACE_EN 0x04 95 NV_MCP_SATA_CFG_20 = 0x50,
96 NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 0x04,
97};
124 98
125static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 99static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
126static irqreturn_t nv_interrupt (int irq, void *dev_instance, 100static irqreturn_t nv_interrupt (int irq, void *dev_instance,
@@ -175,8 +149,6 @@ static const struct pci_device_id nv_pci_tbl[] = {
175 { 0, } /* terminate list */ 149 { 0, } /* terminate list */
176}; 150};
177 151
178#define NV_HOST_FLAGS_SCR_MMIO 0x00000001
179
180struct nv_host_desc 152struct nv_host_desc
181{ 153{
182 enum nv_host_type host_type; 154 enum nv_host_type host_type;
@@ -332,36 +304,23 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
332 304
333static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg) 305static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
334{ 306{
335 struct ata_host_set *host_set = ap->host_set;
336 struct nv_host *host = host_set->private_data;
337
338 if (sc_reg > SCR_CONTROL) 307 if (sc_reg > SCR_CONTROL)
339 return 0xffffffffU; 308 return 0xffffffffU;
340 309
341 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 310 return ioread32((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
342 return readl((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
343 else
344 return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
345} 311}
346 312
347static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 313static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
348{ 314{
349 struct ata_host_set *host_set = ap->host_set;
350 struct nv_host *host = host_set->private_data;
351
352 if (sc_reg > SCR_CONTROL) 315 if (sc_reg > SCR_CONTROL)
353 return; 316 return;
354 317
355 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 318 iowrite32(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
356 writel(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
357 else
358 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
359} 319}
360 320
361static void nv_host_stop (struct ata_host_set *host_set) 321static void nv_host_stop (struct ata_host_set *host_set)
362{ 322{
363 struct nv_host *host = host_set->private_data; 323 struct nv_host *host = host_set->private_data;
364 struct pci_dev *pdev = to_pci_dev(host_set->dev);
365 324
366 // Disable hotplug event interrupts. 325 // Disable hotplug event interrupts.
367 if (host->host_desc->disable_hotplug) 326 if (host->host_desc->disable_hotplug)
@@ -369,8 +328,7 @@ static void nv_host_stop (struct ata_host_set *host_set)
369 328
370 kfree(host); 329 kfree(host);
371 330
372 if (host_set->mmio_base) 331 ata_pci_host_stop(host_set);
373 pci_iounmap(pdev, host_set->mmio_base);
374} 332}
375 333
376static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 334static 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)
382 int pci_dev_busy = 0; 340 int pci_dev_busy = 0;
383 int rc; 341 int rc;
384 u32 bar; 342 u32 bar;
343 unsigned long base;
385 344
386 // Make sure this is a SATA controller by counting the number of bars 345 // Make sure this is a SATA controller by counting the number of bars
387 // (NVIDIA SATA controllers will always have six bars). Otherwise, 346 // (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)
426 385
427 probe_ent->private_data = host; 386 probe_ent->private_data = host;
428 387
429 if (pci_resource_flags(pdev, 5) & IORESOURCE_MEM) 388 probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
430 host->host_flags |= NV_HOST_FLAGS_SCR_MMIO; 389 if (!probe_ent->mmio_base) {
431 390 rc = -EIO;
432 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) { 391 goto err_out_free_host;
433 unsigned long base; 392 }
434
435 probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
436 if (probe_ent->mmio_base == NULL) {
437 rc = -EIO;
438 goto err_out_free_host;
439 }
440
441 base = (unsigned long)probe_ent->mmio_base;
442 393
443 probe_ent->port[0].scr_addr = 394 base = (unsigned long)probe_ent->mmio_base;
444 base + NV_PORT0_SCR_REG_OFFSET;
445 probe_ent->port[1].scr_addr =
446 base + NV_PORT1_SCR_REG_OFFSET;
447 } else {
448 395
449 probe_ent->port[0].scr_addr = 396 probe_ent->port[0].scr_addr = base + NV_PORT0_SCR_REG_OFFSET;
450 pci_resource_start(pdev, 5) | NV_PORT0_SCR_REG_OFFSET; 397 probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET;
451 probe_ent->port[1].scr_addr =
452 pci_resource_start(pdev, 5) | NV_PORT1_SCR_REG_OFFSET;
453 }
454 398
455 pci_set_master(pdev); 399 pci_set_master(pdev);
456 400
@@ -467,8 +411,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
467 return 0; 411 return 0;
468 412
469err_out_iounmap: 413err_out_iounmap:
470 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 414 pci_iounmap(pdev, probe_ent->mmio_base);
471 pci_iounmap(pdev, probe_ent->mmio_base);
472err_out_free_host: 415err_out_free_host:
473 kfree(host); 416 kfree(host);
474err_out_free_ent: 417err_out_free_ent:
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 3e75d6733239..18c296c56899 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)
371 if (quirks & SIL_QUIRK_UDMA5MAX) { 371 if (quirks & SIL_QUIRK_UDMA5MAX) {
372 printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n", 372 printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n",
373 ap->id, dev->devno, model_num); 373 ap->id, dev->devno, model_num);
374 ap->udma_mask &= ATA_UDMA5; 374 dev->udma_mask &= ATA_UDMA5;
375 return; 375 return;
376 } 376 }
377} 377}
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 5d01e5ce5ac5..068c98a4111b 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[] = {
342 .udma_mask = 0x3f, /* udma0-5 */ 342 .udma_mask = 0x3f, /* udma0-5 */
343 .port_ops = &sil24_ops, 343 .port_ops = &sil24_ops,
344 }, 344 },
345 /* sil_3132 */ 345 /* sil_3132 */
346 { 346 {
347 .sht = &sil24_sht, 347 .sht = &sil24_sht,
348 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 348 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
@@ -842,9 +842,10 @@ static void sil24_port_stop(struct ata_port *ap)
842static void sil24_host_stop(struct ata_host_set *host_set) 842static void sil24_host_stop(struct ata_host_set *host_set)
843{ 843{
844 struct sil24_host_priv *hpriv = host_set->private_data; 844 struct sil24_host_priv *hpriv = host_set->private_data;
845 struct pci_dev *pdev = to_pci_dev(host_set->dev);
845 846
846 iounmap(hpriv->host_base); 847 pci_iounmap(pdev, hpriv->host_base);
847 iounmap(hpriv->port_base); 848 pci_iounmap(pdev, hpriv->port_base);
848 kfree(hpriv); 849 kfree(hpriv);
849} 850}
850 851
@@ -871,26 +872,23 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
871 goto out_disable; 872 goto out_disable;
872 873
873 rc = -ENOMEM; 874 rc = -ENOMEM;
874 /* ioremap mmio registers */ 875 /* map mmio registers */
875 host_base = ioremap(pci_resource_start(pdev, 0), 876 host_base = pci_iomap(pdev, 0, 0);
876 pci_resource_len(pdev, 0));
877 if (!host_base) 877 if (!host_base)
878 goto out_free; 878 goto out_free;
879 port_base = ioremap(pci_resource_start(pdev, 2), 879 port_base = pci_iomap(pdev, 2, 0);
880 pci_resource_len(pdev, 2));
881 if (!port_base) 880 if (!port_base)
882 goto out_free; 881 goto out_free;
883 882
884 /* allocate & init probe_ent and hpriv */ 883 /* allocate & init probe_ent and hpriv */
885 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); 884 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
886 if (!probe_ent) 885 if (!probe_ent)
887 goto out_free; 886 goto out_free;
888 887
889 hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); 888 hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
890 if (!hpriv) 889 if (!hpriv)
891 goto out_free; 890 goto out_free;
892 891
893 memset(probe_ent, 0, sizeof(*probe_ent));
894 probe_ent->dev = pci_dev_to_dev(pdev); 892 probe_ent->dev = pci_dev_to_dev(pdev);
895 INIT_LIST_HEAD(&probe_ent->node); 893 INIT_LIST_HEAD(&probe_ent->node);
896 894
@@ -907,7 +905,6 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
907 probe_ent->mmio_base = port_base; 905 probe_ent->mmio_base = port_base;
908 probe_ent->private_data = hpriv; 906 probe_ent->private_data = hpriv;
909 907
910 memset(hpriv, 0, sizeof(*hpriv));
911 hpriv->host_base = host_base; 908 hpriv->host_base = host_base;
912 hpriv->port_base = port_base; 909 hpriv->port_base = port_base;
913 910
@@ -1011,9 +1008,9 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1011 1008
1012 out_free: 1009 out_free:
1013 if (host_base) 1010 if (host_base)
1014 iounmap(host_base); 1011 pci_iounmap(pdev, host_base);
1015 if (port_base) 1012 if (port_base)
1016 iounmap(port_base); 1013 pci_iounmap(pdev, port_base);
1017 kfree(probe_ent); 1014 kfree(probe_ent);
1018 kfree(hpriv); 1015 kfree(hpriv);
1019 pci_release_regions(pdev); 1016 pci_release_regions(pdev);
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 8f5025733def..7ac5a5f5a905 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -44,6 +44,8 @@ enum {
44 uli_5287 = 1, 44 uli_5287 = 1,
45 uli_5281 = 2, 45 uli_5281 = 2,
46 46
47 uli_max_ports = 4,
48
47 /* PCI configuration registers */ 49 /* PCI configuration registers */
48 ULI5287_BASE = 0x90, /* sata0 phy SCR registers */ 50 ULI5287_BASE = 0x90, /* sata0 phy SCR registers */
49 ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */ 51 ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */
@@ -51,6 +53,10 @@ enum {
51 ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */ 53 ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */
52}; 54};
53 55
56struct uli_priv {
57 unsigned int scr_cfg_addr[uli_max_ports];
58};
59
54static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 60static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
55static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg); 61static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg);
56static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 62static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
@@ -137,7 +143,8 @@ MODULE_VERSION(DRV_VERSION);
137 143
138static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) 144static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
139{ 145{
140 return ap->ioaddr.scr_addr + (4 * sc_reg); 146 struct uli_priv *hpriv = ap->host_set->private_data;
147 return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg);
141} 148}
142 149
143static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) 150static 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)
182 int rc; 189 int rc;
183 unsigned int board_idx = (unsigned int) ent->driver_data; 190 unsigned int board_idx = (unsigned int) ent->driver_data;
184 int pci_dev_busy = 0; 191 int pci_dev_busy = 0;
192 struct uli_priv *hpriv;
185 193
186 if (!printed_version++) 194 if (!printed_version++)
187 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 195 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)
210 goto err_out_regions; 218 goto err_out_regions;
211 } 219 }
212 220
221 hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
222 if (!hpriv) {
223 rc = -ENOMEM;
224 goto err_out_probe_ent;
225 }
226
227 probe_ent->private_data = hpriv;
228
213 switch (board_idx) { 229 switch (board_idx) {
214 case uli_5287: 230 case uli_5287:
215 probe_ent->port[0].scr_addr = ULI5287_BASE; 231 hpriv->scr_cfg_addr[0] = ULI5287_BASE;
216 probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS; 232 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
217 probe_ent->n_ports = 4; 233 probe_ent->n_ports = 4;
218 234
219 probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8; 235 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)
221 probe_ent->port[2].ctl_addr = 237 probe_ent->port[2].ctl_addr =
222 (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4; 238 (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4;
223 probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16; 239 probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16;
224 probe_ent->port[2].scr_addr = ULI5287_BASE + ULI5287_OFFS*4; 240 hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4;
225 241
226 probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8; 242 probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8;
227 probe_ent->port[3].altstatus_addr = 243 probe_ent->port[3].altstatus_addr =
228 probe_ent->port[3].ctl_addr = 244 probe_ent->port[3].ctl_addr =
229 (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4; 245 (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4;
230 probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24; 246 probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24;
231 probe_ent->port[3].scr_addr = ULI5287_BASE + ULI5287_OFFS*5; 247 hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5;
232 248
233 ata_std_ports(&probe_ent->port[2]); 249 ata_std_ports(&probe_ent->port[2]);
234 ata_std_ports(&probe_ent->port[3]); 250 ata_std_ports(&probe_ent->port[3]);
235 break; 251 break;
236 252
237 case uli_5289: 253 case uli_5289:
238 probe_ent->port[0].scr_addr = ULI5287_BASE; 254 hpriv->scr_cfg_addr[0] = ULI5287_BASE;
239 probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS; 255 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
240 break; 256 break;
241 257
242 case uli_5281: 258 case uli_5281:
243 probe_ent->port[0].scr_addr = ULI5281_BASE; 259 hpriv->scr_cfg_addr[0] = ULI5281_BASE;
244 probe_ent->port[1].scr_addr = ULI5281_BASE + ULI5281_OFFS; 260 hpriv->scr_cfg_addr[1] = ULI5281_BASE + ULI5281_OFFS;
245 break; 261 break;
246 262
247 default: 263 default:
@@ -258,9 +274,10 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
258 274
259 return 0; 275 return 0;
260 276
277err_out_probe_ent:
278 kfree(probe_ent);
261err_out_regions: 279err_out_regions:
262 pci_release_regions(pdev); 280 pci_release_regions(pdev);
263
264err_out: 281err_out:
265 if (!pci_dev_busy) 282 if (!pci_dev_busy)
266 pci_disable_device(pdev); 283 pci_disable_device(pdev);
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 9701a806539d..836bbbb26ff2 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -230,11 +230,11 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
230 handled += ata_host_intr(ap, qc); 230 handled += ata_host_intr(ap, qc);
231 } else if (is_vsc_sata_int_err(i, int_status)) { 231 } else if (is_vsc_sata_int_err(i, int_status)) {
232 /* 232 /*
233 * On some chips (i.e. Intel 31244), an error 233 * On some chips (i.e. Intel 31244), an error
234 * interrupt will sneak in at initialization 234 * interrupt will sneak in at initialization
235 * time (phy state changes). Clearing the SCR 235 * time (phy state changes). Clearing the SCR
236 * error register is not required, but it prevents 236 * error register is not required, but it prevents
237 * the phy state change interrupts from recurring 237 * the phy state change interrupts from recurring
238 * later. 238 * later.
239 */ 239 */
240 u32 err_status; 240 u32 err_status;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 89055494dfee..a6fde52946d6 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)
286 return err; 286 return err;
287 287
288 if (sht->suspend) 288 if (sht->suspend)
289 err = sht->suspend(sdev); 289 err = sht->suspend(sdev, state);
290 290
291 return err; 291 return err;
292} 292}
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 024ef86c5242..c647d85d97d1 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,
190 if (scsi_mode_sense(sdp, 0x08, 8, buffer, sizeof(buffer), SD_TIMEOUT, 190 if (scsi_mode_sense(sdp, 0x08, 8, buffer, sizeof(buffer), SD_TIMEOUT,
191 SD_MAX_RETRIES, &data, NULL)) 191 SD_MAX_RETRIES, &data, NULL))
192 return -EINVAL; 192 return -EINVAL;
193 len = min(sizeof(buffer), data.length - data.header_length - 193 len = min_t(size_t, sizeof(buffer), data.length - data.header_length -
194 data.block_descriptor_length); 194 data.block_descriptor_length);
195 buffer_data = buffer + data.header_length + 195 buffer_data = buffer + data.header_length +
196 data.block_descriptor_length; 196 data.block_descriptor_length;
diff --git a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
index 4315afe9c080..53e81a44c1a3 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/serial/8250_hp300.c
@@ -55,6 +55,8 @@ static struct dio_driver hpdca_driver = {
55 55
56#endif 56#endif
57 57
58static unsigned int num_ports;
59
58extern int hp300_uart_scode; 60extern int hp300_uart_scode;
59 61
60/* Offset to UART registers from base of DCA */ 62/* Offset to UART registers from base of DCA */
@@ -199,6 +201,8 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
199 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff); 201 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff);
200 udelay(100); 202 udelay(100);
201 203
204 num_ports++;
205
202 return 0; 206 return 0;
203} 207}
204#endif 208#endif
@@ -206,7 +210,6 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
206static int __init hp300_8250_init(void) 210static int __init hp300_8250_init(void)
207{ 211{
208 static int called = 0; 212 static int called = 0;
209 int num_ports;
210#ifdef CONFIG_HPAPCI 213#ifdef CONFIG_HPAPCI
211 int line; 214 int line;
212 unsigned long base; 215 unsigned long base;
@@ -221,11 +224,8 @@ static int __init hp300_8250_init(void)
221 if (!MACH_IS_HP300) 224 if (!MACH_IS_HP300)
222 return -ENODEV; 225 return -ENODEV;
223 226
224 num_ports = 0;
225
226#ifdef CONFIG_HPDCA 227#ifdef CONFIG_HPDCA
227 if (dio_module_init(&hpdca_driver) == 0) 228 dio_register_driver(&hpdca_driver);
228 num_ports++;
229#endif 229#endif
230#ifdef CONFIG_HPAPCI 230#ifdef CONFIG_HPAPCI
231 if (hp300_model < HP_400) { 231 if (hp300_model < HP_400) {
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index a37579ce6d76..c620209d7b9a 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2003-2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (C) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9 9
@@ -323,9 +323,12 @@ static unsigned int Num_of_ioc4_cards;
323#define IOC4_FIFO_CHARS 255 323#define IOC4_FIFO_CHARS 255
324 324
325/* Device name we're using */ 325/* Device name we're using */
326#define DEVICE_NAME "ttyIOC" 326#define DEVICE_NAME_RS232 "ttyIOC"
327#define DEVICE_MAJOR 204 327#define DEVICE_NAME_RS422 "ttyAIOC"
328#define DEVICE_MINOR 50 328#define DEVICE_MAJOR 204
329#define DEVICE_MINOR_RS232 50
330#define DEVICE_MINOR_RS422 84
331
329 332
330/* register offsets */ 333/* register offsets */
331#define IOC4_SERIAL_OFFSET 0x300 334#define IOC4_SERIAL_OFFSET 0x300
@@ -341,10 +344,8 @@ static unsigned int Num_of_ioc4_cards;
341#define MAX_BAUD_SUPPORTED 115200 344#define MAX_BAUD_SUPPORTED 115200
342 345
343/* protocol types supported */ 346/* protocol types supported */
344enum sio_proto { 347#define PROTO_RS232 3
345 PROTO_RS232, 348#define PROTO_RS422 7
346 PROTO_RS422
347};
348 349
349/* Notification types */ 350/* Notification types */
350#define N_DATA_READY 0x01 351#define N_DATA_READY 0x01
@@ -395,11 +396,17 @@ enum sio_proto {
395/* 396/*
396 * This is the entry saved by the driver - one per card 397 * This is the entry saved by the driver - one per card
397 */ 398 */
399
400#define UART_PORT_MIN 0
401#define UART_PORT_RS232 UART_PORT_MIN
402#define UART_PORT_RS422 1
403#define UART_PORT_COUNT 2 /* one for each mode */
404
398struct ioc4_control { 405struct ioc4_control {
399 int ic_irq; 406 int ic_irq;
400 struct { 407 struct {
401 /* uart ports are allocated here */ 408 /* uart ports are allocated here - 1 for rs232, 1 for rs422 */
402 struct uart_port icp_uart_port; 409 struct uart_port icp_uart_port[UART_PORT_COUNT];
403 /* Handy reference material */ 410 /* Handy reference material */
404 struct ioc4_port *icp_port; 411 struct ioc4_port *icp_port;
405 } ic_port[IOC4_NUM_SERIAL_PORTS]; 412 } ic_port[IOC4_NUM_SERIAL_PORTS];
@@ -443,7 +450,9 @@ struct ioc4_soft {
443 450
444/* Local port info for each IOC4 serial ports */ 451/* Local port info for each IOC4 serial ports */
445struct ioc4_port { 452struct ioc4_port {
446 struct uart_port *ip_port; 453 struct uart_port *ip_port; /* current active port ptr */
454 /* Ptrs for all ports */
455 struct uart_port *ip_all_ports[UART_PORT_COUNT];
447 /* Back ptrs for this port */ 456 /* Back ptrs for this port */
448 struct ioc4_control *ip_control; 457 struct ioc4_control *ip_control;
449 struct pci_dev *ip_pdev; 458 struct pci_dev *ip_pdev;
@@ -502,6 +511,9 @@ struct ioc4_port {
502#define DCD_ON 0x02 511#define DCD_ON 0x02
503#define LOWAT_WRITTEN 0x04 512#define LOWAT_WRITTEN 0x04
504#define READ_ABORTED 0x08 513#define READ_ABORTED 0x08
514#define PORT_ACTIVE 0x10
515#define PORT_INACTIVE 0 /* This is the value when "off" */
516
505 517
506/* Since each port has different register offsets and bitmasks 518/* Since each port has different register offsets and bitmasks
507 * for everything, we'll store those that we need in tables so we 519 * for everything, we'll store those that we need in tables so we
@@ -623,6 +635,23 @@ struct ring_buffer {
623static void receive_chars(struct uart_port *); 635static void receive_chars(struct uart_port *);
624static void handle_intr(void *arg, uint32_t sio_ir); 636static void handle_intr(void *arg, uint32_t sio_ir);
625 637
638/*
639 * port_is_active - determines if this port is currently active
640 * @port: ptr to soft struct for this port
641 * @uart_port: uart port to test for
642 */
643static inline int port_is_active(struct ioc4_port *port,
644 struct uart_port *uart_port)
645{
646 if (port) {
647 if ((port->ip_flags & PORT_ACTIVE)
648 && (port->ip_port == uart_port))
649 return 1;
650 }
651 return 0;
652}
653
654
626/** 655/**
627 * write_ireg - write the interrupt regs 656 * write_ireg - write the interrupt regs
628 * @ioc4_soft: ptr to soft struct for this port 657 * @ioc4_soft: ptr to soft struct for this port
@@ -708,19 +737,33 @@ static int set_baud(struct ioc4_port *port, int baud)
708/** 737/**
709 * get_ioc4_port - given a uart port, return the control structure 738 * get_ioc4_port - given a uart port, return the control structure
710 * @port: uart port 739 * @port: uart port
740 * @set: set this port as current
711 */ 741 */
712static struct ioc4_port *get_ioc4_port(struct uart_port *the_port) 742static struct ioc4_port *get_ioc4_port(struct uart_port *the_port, int set)
713{ 743{
714 struct ioc4_driver_data *idd = dev_get_drvdata(the_port->dev); 744 struct ioc4_driver_data *idd = dev_get_drvdata(the_port->dev);
715 struct ioc4_control *control = idd->idd_serial_data; 745 struct ioc4_control *control = idd->idd_serial_data;
716 int ii; 746 struct ioc4_port *port;
747 int port_num, port_type;
717 748
718 if (control) { 749 if (control) {
719 for ( ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++ ) { 750 for ( port_num = 0; port_num < IOC4_NUM_SERIAL_PORTS;
720 if (!control->ic_port[ii].icp_port) 751 port_num++ ) {
752 port = control->ic_port[port_num].icp_port;
753 if (!port)
721 continue; 754 continue;
722 if (the_port == control->ic_port[ii].icp_port->ip_port) 755 for (port_type = UART_PORT_MIN;
723 return control->ic_port[ii].icp_port; 756 port_type < UART_PORT_COUNT;
757 port_type++) {
758 if (the_port == port->ip_all_ports
759 [port_type]) {
760 /* set local copy */
761 if (set) {
762 port->ip_port = the_port;
763 }
764 return port;
765 }
766 }
724 } 767 }
725 } 768 }
726 return NULL; 769 return NULL;
@@ -946,6 +989,7 @@ intr_connect(struct ioc4_soft *soft, int type,
946 * @arg: handler arg 989 * @arg: handler arg
947 * @regs: registers 990 * @regs: registers
948 */ 991 */
992
949static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs) 993static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
950{ 994{
951 struct ioc4_soft *soft; 995 struct ioc4_soft *soft;
@@ -953,7 +997,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
953 int xx, num_intrs = 0; 997 int xx, num_intrs = 0;
954 int intr_type; 998 int intr_type;
955 int handled = 0; 999 int handled = 0;
956 struct ioc4_intr_info *ii; 1000 struct ioc4_intr_info *intr_info;
957 1001
958 soft = arg; 1002 soft = arg;
959 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) { 1003 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)
966 * which interrupt bits are set. 1010 * which interrupt bits are set.
967 */ 1011 */
968 for (xx = 0; xx < num_intrs; xx++) { 1012 for (xx = 0; xx < num_intrs; xx++) {
969 ii = &soft->is_intr_type[intr_type].is_intr_info[xx]; 1013 intr_info = &soft->is_intr_type[intr_type].is_intr_info[xx];
970 if ((this_mir = this_ir & ii->sd_bits)) { 1014 if ((this_mir = this_ir & intr_info->sd_bits)) {
971 /* Disable owned interrupts, call handler */ 1015 /* Disable owned interrupts, call handler */
972 handled++; 1016 handled++;
973 write_ireg(soft, ii->sd_bits, IOC4_W_IEC, 1017 write_ireg(soft, intr_info->sd_bits, IOC4_W_IEC,
974 intr_type); 1018 intr_type);
975 ii->sd_intr(ii->sd_info, this_mir); 1019 intr_info->sd_intr(intr_info->sd_info, this_mir);
976 this_ir &= ~this_mir; 1020 this_ir &= ~this_mir;
977 } 1021 }
978 } 1022 }
@@ -980,7 +1024,6 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
980#ifdef DEBUG_INTERRUPTS 1024#ifdef DEBUG_INTERRUPTS
981 { 1025 {
982 struct ioc4_misc_regs __iomem *mem = soft->is_ioc4_misc_addr; 1026 struct ioc4_misc_regs __iomem *mem = soft->is_ioc4_misc_addr;
983 spinlock_t *lp = &soft->is_ir_lock;
984 unsigned long flag; 1027 unsigned long flag;
985 1028
986 spin_lock_irqsave(&soft->is_ir_lock, flag); 1029 spin_lock_irqsave(&soft->is_ir_lock, flag);
@@ -1177,7 +1220,7 @@ static inline int local_open(struct ioc4_port *port)
1177{ 1220{
1178 int spiniter = 0; 1221 int spiniter = 0;
1179 1222
1180 port->ip_flags = 0; 1223 port->ip_flags = PORT_ACTIVE;
1181 1224
1182 /* Pause the DMA interface if necessary */ 1225 /* Pause the DMA interface if necessary */
1183 if (port->ip_sscr & IOC4_SSCR_DMA_EN) { 1226 if (port->ip_sscr & IOC4_SSCR_DMA_EN) {
@@ -1187,6 +1230,7 @@ static inline int local_open(struct ioc4_port *port)
1187 & IOC4_SSCR_PAUSE_STATE) == 0) { 1230 & IOC4_SSCR_PAUSE_STATE) == 0) {
1188 spiniter++; 1231 spiniter++;
1189 if (spiniter > MAXITER) { 1232 if (spiniter > MAXITER) {
1233 port->ip_flags = PORT_INACTIVE;
1190 return -1; 1234 return -1;
1191 } 1235 }
1192 } 1236 }
@@ -1506,14 +1550,13 @@ static int set_notification(struct ioc4_port *port, int mask, int set_on)
1506/** 1550/**
1507 * set_mcr - set the master control reg 1551 * set_mcr - set the master control reg
1508 * @the_port: port to use 1552 * @the_port: port to use
1509 * @set: set ?
1510 * @mask1: mcr mask 1553 * @mask1: mcr mask
1511 * @mask2: shadow mask 1554 * @mask2: shadow mask
1512 */ 1555 */
1513static inline int set_mcr(struct uart_port *the_port, int set, 1556static inline int set_mcr(struct uart_port *the_port,
1514 int mask1, int mask2) 1557 int mask1, int mask2)
1515{ 1558{
1516 struct ioc4_port *port = get_ioc4_port(the_port); 1559 struct ioc4_port *port = get_ioc4_port(the_port, 0);
1517 uint32_t shadow; 1560 uint32_t shadow;
1518 int spiniter = 0; 1561 int spiniter = 0;
1519 char mcr; 1562 char mcr;
@@ -1536,13 +1579,9 @@ static inline int set_mcr(struct uart_port *the_port, int set,
1536 mcr = (shadow & 0xff000000) >> 24; 1579 mcr = (shadow & 0xff000000) >> 24;
1537 1580
1538 /* Set new value */ 1581 /* Set new value */
1539 if (set) { 1582 mcr |= mask1;
1540 mcr |= mask1; 1583 shadow |= mask2;
1541 shadow |= mask2; 1584
1542 } else {
1543 mcr &= ~mask1;
1544 shadow &= ~mask2;
1545 }
1546 writeb(mcr, &port->ip_uart_regs->i4u_mcr); 1585 writeb(mcr, &port->ip_uart_regs->i4u_mcr);
1547 writel(shadow, &port->ip_serial_regs->shadow); 1586 writel(shadow, &port->ip_serial_regs->shadow);
1548 1587
@@ -1558,7 +1597,7 @@ static inline int set_mcr(struct uart_port *the_port, int set,
1558 * @port: port to use 1597 * @port: port to use
1559 * @proto: protocol to use 1598 * @proto: protocol to use
1560 */ 1599 */
1561static int ioc4_set_proto(struct ioc4_port *port, enum sio_proto proto) 1600static int ioc4_set_proto(struct ioc4_port *port, int proto)
1562{ 1601{
1563 struct hooks *hooks = port->ip_hooks; 1602 struct hooks *hooks = port->ip_hooks;
1564 1603
@@ -1589,7 +1628,7 @@ static void transmit_chars(struct uart_port *the_port)
1589 int result; 1628 int result;
1590 char *start; 1629 char *start;
1591 struct tty_struct *tty; 1630 struct tty_struct *tty;
1592 struct ioc4_port *port = get_ioc4_port(the_port); 1631 struct ioc4_port *port = get_ioc4_port(the_port, 0);
1593 struct uart_info *info; 1632 struct uart_info *info;
1594 1633
1595 if (!the_port) 1634 if (!the_port)
@@ -1645,7 +1684,7 @@ static void
1645ioc4_change_speed(struct uart_port *the_port, 1684ioc4_change_speed(struct uart_port *the_port,
1646 struct termios *new_termios, struct termios *old_termios) 1685 struct termios *new_termios, struct termios *old_termios)
1647{ 1686{
1648 struct ioc4_port *port = get_ioc4_port(the_port); 1687 struct ioc4_port *port = get_ioc4_port(the_port, 0);
1649 int baud, bits; 1688 int baud, bits;
1650 unsigned cflag; 1689 unsigned cflag;
1651 int new_parity = 0, new_parity_enable = 0, new_stop = 0, new_data = 8; 1690 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)
1752 if (!the_port) 1791 if (!the_port)
1753 return -1; 1792 return -1;
1754 1793
1755 port = get_ioc4_port(the_port); 1794 port = get_ioc4_port(the_port, 0);
1756 if (!port) 1795 if (!port)
1757 return -1; 1796 return -1;
1758 1797
@@ -1760,6 +1799,9 @@ static inline int ic4_startup_local(struct uart_port *the_port)
1760 1799
1761 local_open(port); 1800 local_open(port);
1762 1801
1802 /* set the protocol - mapbase has the port type */
1803 ioc4_set_proto(port, the_port->mapbase);
1804
1763 /* set the speed of the serial port */ 1805 /* set the speed of the serial port */
1764 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0); 1806 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0);
1765 1807
@@ -1768,17 +1810,17 @@ static inline int ic4_startup_local(struct uart_port *the_port)
1768 1810
1769/* 1811/*
1770 * ioc4_cb_output_lowat - called when the output low water mark is hit 1812 * ioc4_cb_output_lowat - called when the output low water mark is hit
1771 * @port: port to output 1813 * @the_port: port to output
1772 */ 1814 */
1773static void ioc4_cb_output_lowat(struct ioc4_port *port) 1815static void ioc4_cb_output_lowat(struct uart_port *the_port)
1774{ 1816{
1775 unsigned long pflags; 1817 unsigned long pflags;
1776 1818
1777 /* ip_lock is set on the call here */ 1819 /* ip_lock is set on the call here */
1778 if (port->ip_port) { 1820 if (the_port) {
1779 spin_lock_irqsave(&port->ip_port->lock, pflags); 1821 spin_lock_irqsave(&the_port->lock, pflags);
1780 transmit_chars(port->ip_port); 1822 transmit_chars(the_port);
1781 spin_unlock_irqrestore(&port->ip_port->lock, pflags); 1823 spin_unlock_irqrestore(&the_port->lock, pflags);
1782 } 1824 }
1783} 1825}
1784 1826
@@ -1923,7 +1965,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1923 &port->ip_mem->sio_ir.raw); 1965 &port->ip_mem->sio_ir.raw);
1924 1966
1925 if (port->ip_notify & N_OUTPUT_LOWAT) 1967 if (port->ip_notify & N_OUTPUT_LOWAT)
1926 ioc4_cb_output_lowat(port); 1968 ioc4_cb_output_lowat(port->ip_port);
1927 } 1969 }
1928 1970
1929 /* Handle tx_mt. Must come after tx_explicit. */ 1971 /* Handle tx_mt. Must come after tx_explicit. */
@@ -1936,7 +1978,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1936 * So send the notification now. 1978 * So send the notification now.
1937 */ 1979 */
1938 if (port->ip_notify & N_OUTPUT_LOWAT) { 1980 if (port->ip_notify & N_OUTPUT_LOWAT) {
1939 ioc4_cb_output_lowat(port); 1981 ioc4_cb_output_lowat(port->ip_port);
1940 1982
1941 /* We need to reload the sio_ir since the lowat 1983 /* We need to reload the sio_ir since the lowat
1942 * call may have caused another write to occur, 1984 * 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,
2023 int len) 2065 int len)
2024{ 2066{
2025 int prod_ptr, cons_ptr, total; 2067 int prod_ptr, cons_ptr, total;
2026 struct ioc4_port *port = get_ioc4_port(the_port); 2068 struct ioc4_port *port = get_ioc4_port(the_port, 0);
2027 struct ring *inring; 2069 struct ring *inring;
2028 struct ring_entry *entry; 2070 struct ring_entry *entry;
2029 struct hooks *hooks = port->ip_hooks; 2071 struct hooks *hooks = port->ip_hooks;
@@ -2335,17 +2377,27 @@ static void receive_chars(struct uart_port *the_port)
2335 */ 2377 */
2336static const char *ic4_type(struct uart_port *the_port) 2378static const char *ic4_type(struct uart_port *the_port)
2337{ 2379{
2338 return "SGI IOC4 Serial"; 2380 if (the_port->mapbase == PROTO_RS232)
2381 return "SGI IOC4 Serial [rs232]";
2382 else
2383 return "SGI IOC4 Serial [rs422]";
2339} 2384}
2340 2385
2341/** 2386/**
2342 * ic4_tx_empty - Is the transmitter empty? We pretend we're always empty 2387 * ic4_tx_empty - Is the transmitter empty?
2343 * @port: Port to operate on (we ignore since we always return 1) 2388 * @port: Port to operate on
2344 * 2389 *
2345 */ 2390 */
2346static unsigned int ic4_tx_empty(struct uart_port *the_port) 2391static unsigned int ic4_tx_empty(struct uart_port *the_port)
2347{ 2392{
2348 return 1; 2393 struct ioc4_port *port = get_ioc4_port(the_port, 0);
2394 unsigned int ret = 0;
2395
2396 if (port_is_active(port, the_port)) {
2397 if (readl(&port->ip_serial_regs->shadow) & IOC4_SHADOW_TEMT)
2398 ret = TIOCSER_TEMT;
2399 }
2400 return ret;
2349} 2401}
2350 2402
2351/** 2403/**
@@ -2355,6 +2407,10 @@ static unsigned int ic4_tx_empty(struct uart_port *the_port)
2355 */ 2407 */
2356static void ic4_stop_tx(struct uart_port *the_port) 2408static void ic4_stop_tx(struct uart_port *the_port)
2357{ 2409{
2410 struct ioc4_port *port = get_ioc4_port(the_port, 0);
2411
2412 if (port_is_active(port, the_port))
2413 set_notification(port, N_OUTPUT_LOWAT, 0);
2358} 2414}
2359 2415
2360/** 2416/**
@@ -2377,11 +2433,12 @@ static void ic4_shutdown(struct uart_port *the_port)
2377 struct ioc4_port *port; 2433 struct ioc4_port *port;
2378 struct uart_info *info; 2434 struct uart_info *info;
2379 2435
2380 port = get_ioc4_port(the_port); 2436 port = get_ioc4_port(the_port, 0);
2381 if (!port) 2437 if (!port)
2382 return; 2438 return;
2383 2439
2384 info = the_port->info; 2440 info = the_port->info;
2441 port->ip_port = NULL;
2385 2442
2386 wake_up_interruptible(&info->delta_msr_wait); 2443 wake_up_interruptible(&info->delta_msr_wait);
2387 2444
@@ -2390,6 +2447,7 @@ static void ic4_shutdown(struct uart_port *the_port)
2390 2447
2391 spin_lock_irqsave(&the_port->lock, port_flags); 2448 spin_lock_irqsave(&the_port->lock, port_flags);
2392 set_notification(port, N_ALL, 0); 2449 set_notification(port, N_ALL, 0);
2450 port->ip_flags = PORT_INACTIVE;
2393 spin_unlock_irqrestore(&the_port->lock, port_flags); 2451 spin_unlock_irqrestore(&the_port->lock, port_flags);
2394} 2452}
2395 2453
@@ -2402,6 +2460,11 @@ static void ic4_shutdown(struct uart_port *the_port)
2402static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl) 2460static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl)
2403{ 2461{
2404 unsigned char mcr = 0; 2462 unsigned char mcr = 0;
2463 struct ioc4_port *port;
2464
2465 port = get_ioc4_port(the_port, 0);
2466 if (!port_is_active(port, the_port))
2467 return;
2405 2468
2406 if (mctrl & TIOCM_RTS) 2469 if (mctrl & TIOCM_RTS)
2407 mcr |= UART_MCR_RTS; 2470 mcr |= UART_MCR_RTS;
@@ -2414,7 +2477,7 @@ static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl)
2414 if (mctrl & TIOCM_LOOP) 2477 if (mctrl & TIOCM_LOOP)
2415 mcr |= UART_MCR_LOOP; 2478 mcr |= UART_MCR_LOOP;
2416 2479
2417 set_mcr(the_port, 1, mcr, IOC4_SHADOW_DTR); 2480 set_mcr(the_port, mcr, IOC4_SHADOW_DTR);
2418} 2481}
2419 2482
2420/** 2483/**
@@ -2424,11 +2487,11 @@ static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl)
2424 */ 2487 */
2425static unsigned int ic4_get_mctrl(struct uart_port *the_port) 2488static unsigned int ic4_get_mctrl(struct uart_port *the_port)
2426{ 2489{
2427 struct ioc4_port *port = get_ioc4_port(the_port); 2490 struct ioc4_port *port = get_ioc4_port(the_port, 0);
2428 uint32_t shadow; 2491 uint32_t shadow;
2429 unsigned int ret = 0; 2492 unsigned int ret = 0;
2430 2493
2431 if (!port) 2494 if (!port_is_active(port, the_port))
2432 return 0; 2495 return 0;
2433 2496
2434 shadow = readl(&port->ip_serial_regs->shadow); 2497 shadow = readl(&port->ip_serial_regs->shadow);
@@ -2448,9 +2511,9 @@ static unsigned int ic4_get_mctrl(struct uart_port *the_port)
2448 */ 2511 */
2449static void ic4_start_tx(struct uart_port *the_port) 2512static void ic4_start_tx(struct uart_port *the_port)
2450{ 2513{
2451 struct ioc4_port *port = get_ioc4_port(the_port); 2514 struct ioc4_port *port = get_ioc4_port(the_port, 0);
2452 2515
2453 if (port) { 2516 if (port_is_active(port, the_port)) {
2454 set_notification(port, N_OUTPUT_LOWAT, 1); 2517 set_notification(port, N_OUTPUT_LOWAT, 1);
2455 enable_intrs(port, port->ip_hooks->intr_tx_mt); 2518 enable_intrs(port, port->ip_hooks->intr_tx_mt);
2456 } 2519 }
@@ -2467,7 +2530,7 @@ static void ic4_break_ctl(struct uart_port *the_port, int break_state)
2467} 2530}
2468 2531
2469/** 2532/**
2470 * ic4_startup - Start up the serial port - always return 0 (We're always on) 2533 * ic4_startup - Start up the serial port
2471 * @port: Port to operate on 2534 * @port: Port to operate on
2472 * 2535 *
2473 */ 2536 */
@@ -2479,17 +2542,16 @@ static int ic4_startup(struct uart_port *the_port)
2479 struct uart_info *info; 2542 struct uart_info *info;
2480 unsigned long port_flags; 2543 unsigned long port_flags;
2481 2544
2482 if (!the_port) { 2545 if (!the_port)
2483 return -ENODEV; 2546 return -ENODEV;
2484 } 2547 port = get_ioc4_port(the_port, 1);
2485 port = get_ioc4_port(the_port); 2548 if (!port)
2486 if (!port) {
2487 return -ENODEV; 2549 return -ENODEV;
2488 }
2489 info = the_port->info; 2550 info = the_port->info;
2490 2551
2491 control = port->ip_control; 2552 control = port->ip_control;
2492 if (!control) { 2553 if (!control) {
2554 port->ip_port = NULL;
2493 return -ENODEV; 2555 return -ENODEV;
2494 } 2556 }
2495 2557
@@ -2551,28 +2613,104 @@ static struct uart_ops ioc4_ops = {
2551 * Boot-time initialization code 2613 * Boot-time initialization code
2552 */ 2614 */
2553 2615
2554static struct uart_driver ioc4_uart = { 2616static struct uart_driver ioc4_uart_rs232 = {
2555 .owner = THIS_MODULE, 2617 .owner = THIS_MODULE,
2556 .driver_name = "ioc4_serial", 2618 .driver_name = "ioc4_serial_rs232",
2557 .dev_name = DEVICE_NAME, 2619 .dev_name = DEVICE_NAME_RS232,
2558 .major = DEVICE_MAJOR, 2620 .major = DEVICE_MAJOR,
2559 .minor = DEVICE_MINOR, 2621 .minor = DEVICE_MINOR_RS232,
2560 .nr = IOC4_NUM_CARDS * IOC4_NUM_SERIAL_PORTS, 2622 .nr = IOC4_NUM_CARDS * IOC4_NUM_SERIAL_PORTS,
2561}; 2623};
2562 2624
2625static struct uart_driver ioc4_uart_rs422 = {
2626 .owner = THIS_MODULE,
2627 .driver_name = "ioc4_serial_rs422",
2628 .dev_name = DEVICE_NAME_RS422,
2629 .major = DEVICE_MAJOR,
2630 .minor = DEVICE_MINOR_RS422,
2631 .nr = IOC4_NUM_CARDS * IOC4_NUM_SERIAL_PORTS,
2632};
2633
2634
2563/** 2635/**
2564 * ioc4_serial_core_attach - register with serial core 2636 * ioc4_serial_remove_one - detach function
2637 *
2638 * @idd: IOC4 master module data for this IOC4
2639 */
2640
2641static int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
2642{
2643 int port_num, port_type;
2644 struct ioc4_control *control;
2645 struct uart_port *the_port;
2646 struct ioc4_port *port;
2647 struct ioc4_soft *soft;
2648
2649 control = idd->idd_serial_data;
2650
2651 for (port_num = 0; port_num < IOC4_NUM_SERIAL_PORTS; port_num++) {
2652 for (port_type = UART_PORT_MIN;
2653 port_type < UART_PORT_COUNT;
2654 port_type++) {
2655 the_port = &control->ic_port[port_num].icp_uart_port
2656 [port_type];
2657 if (the_port) {
2658 switch (port_type) {
2659 case UART_PORT_RS422:
2660 uart_remove_one_port(&ioc4_uart_rs422,
2661 the_port);
2662 break;
2663 default:
2664 case UART_PORT_RS232:
2665 uart_remove_one_port(&ioc4_uart_rs232,
2666 the_port);
2667 break;
2668 }
2669 }
2670 }
2671 port = control->ic_port[port_num].icp_port;
2672 /* we allocate in pairs */
2673 if (!(port_num & 1) && port) {
2674 pci_free_consistent(port->ip_pdev,
2675 TOTAL_RING_BUF_SIZE,
2676 port->ip_cpu_ringbuf,
2677 port->ip_dma_ringbuf);
2678 kfree(port);
2679 }
2680 }
2681 soft = control->ic_soft;
2682 if (soft) {
2683 free_irq(control->ic_irq, soft);
2684 if (soft->is_ioc4_serial_addr) {
2685 release_region((unsigned long)
2686 soft->is_ioc4_serial_addr,
2687 sizeof(struct ioc4_serial));
2688 }
2689 kfree(soft);
2690 }
2691 kfree(control);
2692 idd->idd_serial_data = NULL;
2693
2694 return 0;
2695}
2696
2697
2698/**
2699 * ioc4_serial_core_attach_rs232 - register with serial core
2565 * This is done during pci probing 2700 * This is done during pci probing
2566 * @pdev: handle for this card 2701 * @pdev: handle for this card
2567 */ 2702 */
2568static inline int 2703static inline int
2569ioc4_serial_core_attach(struct pci_dev *pdev) 2704ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2570{ 2705{
2571 struct ioc4_port *port; 2706 struct ioc4_port *port;
2572 struct uart_port *the_port; 2707 struct uart_port *the_port;
2573 struct ioc4_driver_data *idd = pci_get_drvdata(pdev); 2708 struct ioc4_driver_data *idd = pci_get_drvdata(pdev);
2574 struct ioc4_control *control = idd->idd_serial_data; 2709 struct ioc4_control *control = idd->idd_serial_data;
2575 int ii; 2710 int port_num;
2711 int port_type_idx;
2712 struct uart_driver *u_driver;
2713
2576 2714
2577 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n", 2715 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n",
2578 __FUNCTION__, pdev, (void *)control)); 2716 __FUNCTION__, pdev, (void *)control));
@@ -2580,28 +2718,36 @@ ioc4_serial_core_attach(struct pci_dev *pdev)
2580 if (!control) 2718 if (!control)
2581 return -ENODEV; 2719 return -ENODEV;
2582 2720
2721 port_type_idx = (port_type == PROTO_RS232) ? UART_PORT_RS232
2722 : UART_PORT_RS422;
2723
2724 u_driver = (port_type == PROTO_RS232) ? &ioc4_uart_rs232
2725 : &ioc4_uart_rs422;
2726
2583 /* once around for each port on this card */ 2727 /* once around for each port on this card */
2584 for (ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++) { 2728 for (port_num = 0; port_num < IOC4_NUM_SERIAL_PORTS; port_num++) {
2585 the_port = &control->ic_port[ii].icp_uart_port; 2729 the_port = &control->ic_port[port_num].icp_uart_port
2586 port = control->ic_port[ii].icp_port; 2730 [port_type_idx];
2587 port->ip_port = the_port; 2731 port = control->ic_port[port_num].icp_port;
2732 port->ip_all_ports[port_type_idx] = the_port;
2588 2733
2589 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p\n", 2734 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p : type %s\n",
2590 __FUNCTION__, (void *)the_port, 2735 __FUNCTION__, (void *)the_port,
2591 (void *)port)); 2736 (void *)port,
2737 port_type == PROTO_RS232 ? "rs232" : "rs422"));
2592 2738
2593 /* membase, iobase and mapbase just need to be non-0 */ 2739 /* membase, iobase and mapbase just need to be non-0 */
2594 the_port->membase = (unsigned char __iomem *)1; 2740 the_port->membase = (unsigned char __iomem *)1;
2595 the_port->iobase = (pdev->bus->number << 16) | ii; 2741 the_port->iobase = (pdev->bus->number << 16) | port_num;
2596 the_port->line = (Num_of_ioc4_cards << 2) | ii; 2742 the_port->line = (Num_of_ioc4_cards << 2) | port_num;
2597 the_port->mapbase = 1; 2743 the_port->mapbase = port_type;
2598 the_port->type = PORT_16550A; 2744 the_port->type = PORT_16550A;
2599 the_port->fifosize = IOC4_FIFO_CHARS; 2745 the_port->fifosize = IOC4_FIFO_CHARS;
2600 the_port->ops = &ioc4_ops; 2746 the_port->ops = &ioc4_ops;
2601 the_port->irq = control->ic_irq; 2747 the_port->irq = control->ic_irq;
2602 the_port->dev = &pdev->dev; 2748 the_port->dev = &pdev->dev;
2603 spin_lock_init(&the_port->lock); 2749 spin_lock_init(&the_port->lock);
2604 if (uart_add_one_port(&ioc4_uart, the_port) < 0) { 2750 if (uart_add_one_port(u_driver, the_port) < 0) {
2605 printk(KERN_WARNING 2751 printk(KERN_WARNING
2606 "%s: unable to add port %d bus %d\n", 2752 "%s: unable to add port %d bus %d\n",
2607 __FUNCTION__, the_port->line, pdev->bus->number); 2753 __FUNCTION__, the_port->line, pdev->bus->number);
@@ -2610,8 +2756,6 @@ ioc4_serial_core_attach(struct pci_dev *pdev)
2610 ("IOC4 serial port %d irq = %d, bus %d\n", 2756 ("IOC4 serial port %d irq = %d, bus %d\n",
2611 the_port->line, the_port->irq, pdev->bus->number)); 2757 the_port->line, the_port->irq, pdev->bus->number));
2612 } 2758 }
2613 /* all ports are rs232 for now */
2614 ioc4_set_proto(port, PROTO_RS232);
2615 } 2759 }
2616 return 0; 2760 return 0;
2617} 2761}
@@ -2631,7 +2775,8 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2631 int ret = 0; 2775 int ret = 0;
2632 2776
2633 2777
2634 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev, idd->idd_pci_id)); 2778 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev,
2779 idd->idd_pci_id));
2635 2780
2636 /* request serial registers */ 2781 /* request serial registers */
2637 tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET; 2782 tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET;
@@ -2653,11 +2798,11 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2653 goto out2; 2798 goto out2;
2654 } 2799 }
2655 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n", 2800 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n",
2656 __FUNCTION__, (void *)idd->idd_misc_regs, (void *)serial)); 2801 __FUNCTION__, (void *)idd->idd_misc_regs,
2802 (void *)serial));
2657 2803
2658 /* Get memory for the new card */ 2804 /* Get memory for the new card */
2659 control = kmalloc(sizeof(struct ioc4_control) * IOC4_NUM_SERIAL_PORTS, 2805 control = kmalloc(sizeof(struct ioc4_control), GFP_KERNEL);
2660 GFP_KERNEL);
2661 2806
2662 if (!control) { 2807 if (!control) {
2663 printk(KERN_WARNING "ioc4_attach_one" 2808 printk(KERN_WARNING "ioc4_attach_one"
@@ -2702,7 +2847,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2702 2847
2703 /* Hook up interrupt handler */ 2848 /* Hook up interrupt handler */
2704 if (!request_irq(idd->idd_pdev->irq, ioc4_intr, SA_SHIRQ, 2849 if (!request_irq(idd->idd_pdev->irq, ioc4_intr, SA_SHIRQ,
2705 "sgi-ioc4serial", (void *)soft)) { 2850 "sgi-ioc4serial", soft)) {
2706 control->ic_irq = idd->idd_pdev->irq; 2851 control->ic_irq = idd->idd_pdev->irq;
2707 } else { 2852 } else {
2708 printk(KERN_WARNING 2853 printk(KERN_WARNING
@@ -2713,16 +2858,21 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2713 if (ret) 2858 if (ret)
2714 goto out4; 2859 goto out4;
2715 2860
2716 /* register port with the serial core */ 2861 /* register port with the serial core - 1 rs232, 1 rs422 */
2717 2862
2718 if ((ret = ioc4_serial_core_attach(idd->idd_pdev))) 2863 if ((ret = ioc4_serial_core_attach(idd->idd_pdev, PROTO_RS232)))
2719 goto out4; 2864 goto out4;
2720 2865
2866 if ((ret = ioc4_serial_core_attach(idd->idd_pdev, PROTO_RS422)))
2867 goto out5;
2868
2721 Num_of_ioc4_cards++; 2869 Num_of_ioc4_cards++;
2722 2870
2723 return ret; 2871 return ret;
2724 2872
2725 /* error exits that give back resources */ 2873 /* error exits that give back resources */
2874out5:
2875 ioc4_serial_remove_one(idd);
2726out4: 2876out4:
2727 kfree(soft); 2877 kfree(soft);
2728out3: 2878out3:
@@ -2735,52 +2885,6 @@ out1:
2735} 2885}
2736 2886
2737 2887
2738/**
2739 * ioc4_serial_remove_one - detach function
2740 *
2741 * @idd: IOC4 master module data for this IOC4
2742 */
2743
2744int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
2745{
2746 int ii;
2747 struct ioc4_control *control;
2748 struct uart_port *the_port;
2749 struct ioc4_port *port;
2750 struct ioc4_soft *soft;
2751
2752 control = idd->idd_serial_data;
2753
2754 for (ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++) {
2755 the_port = &control->ic_port[ii].icp_uart_port;
2756 if (the_port) {
2757 uart_remove_one_port(&ioc4_uart, the_port);
2758 }
2759 port = control->ic_port[ii].icp_port;
2760 if (!(ii & 1) && port) {
2761 pci_free_consistent(port->ip_pdev,
2762 TOTAL_RING_BUF_SIZE,
2763 (void *)port->ip_cpu_ringbuf,
2764 port->ip_dma_ringbuf);
2765 kfree(port);
2766 }
2767 }
2768 soft = control->ic_soft;
2769 if (soft) {
2770 free_irq(control->ic_irq, (void *)soft);
2771 if (soft->is_ioc4_serial_addr) {
2772 release_region((unsigned long)
2773 soft->is_ioc4_serial_addr,
2774 sizeof(struct ioc4_serial));
2775 }
2776 kfree(soft);
2777 }
2778 kfree(control);
2779 idd->idd_serial_data = NULL;
2780
2781 return 0;
2782}
2783
2784static struct ioc4_submodule ioc4_serial_submodule = { 2888static struct ioc4_submodule ioc4_serial_submodule = {
2785 .is_name = "IOC4_serial", 2889 .is_name = "IOC4_serial",
2786 .is_owner = THIS_MODULE, 2890 .is_owner = THIS_MODULE,
@@ -2796,9 +2900,15 @@ int ioc4_serial_init(void)
2796 int ret; 2900 int ret;
2797 2901
2798 /* register with serial core */ 2902 /* register with serial core */
2799 if ((ret = uart_register_driver(&ioc4_uart)) < 0) { 2903 if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) {
2904 printk(KERN_WARNING
2905 "%s: Couldn't register rs232 IOC4 serial driver\n",
2906 __FUNCTION__);
2907 return ret;
2908 }
2909 if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
2800 printk(KERN_WARNING 2910 printk(KERN_WARNING
2801 "%s: Couldn't register IOC4 serial driver\n", 2911 "%s: Couldn't register rs422 IOC4 serial driver\n",
2802 __FUNCTION__); 2912 __FUNCTION__);
2803 return ret; 2913 return ret;
2804 } 2914 }
@@ -2810,7 +2920,8 @@ int ioc4_serial_init(void)
2810static void __devexit ioc4_serial_exit(void) 2920static void __devexit ioc4_serial_exit(void)
2811{ 2921{
2812 ioc4_unregister_submodule(&ioc4_serial_submodule); 2922 ioc4_unregister_submodule(&ioc4_serial_submodule);
2813 uart_unregister_driver(&ioc4_uart); 2923 uart_unregister_driver(&ioc4_uart_rs232);
2924 uart_unregister_driver(&ioc4_uart_rs422);
2814} 2925}
2815 2926
2816module_init(ioc4_serial_init); 2927module_init(ioc4_serial_init);
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 928e6cf12dca..6459edc7f5c5 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -40,7 +40,7 @@
40 * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and 40 * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and
41 * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly 41 * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly
42 * fpr the console code : without this 1:1 mapping, at early boot time, when we 42 * fpr the console code : without this 1:1 mapping, at early boot time, when we
43 * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it 43 * are parsing the kernel args console=ttyPSC?, we wouldn't know which PSC it
44 * will be mapped to. 44 * will be mapped to.
45 */ 45 */
46 46
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 0ca83ac31d07..94681922ea0a 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/serial/mpsc.c
3 *
4 * Generic driver for the MPSC (UART mode) on Marvell parts (e.g., GT64240, 2 * Generic driver for the MPSC (UART mode) on Marvell parts (e.g., GT64240,
5 * GT64260, MV64340, MV64360, GT96100, ... ). 3 * GT64260, MV64340, MV64360, GT96100, ... ).
6 * 4 *
@@ -52,9 +50,263 @@
52 * 4) AFAICT, hardware flow control isn't supported by the controller --MAG. 50 * 4) AFAICT, hardware flow control isn't supported by the controller --MAG.
53 */ 51 */
54 52
53#include <linux/config.h>
54
55#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
56#define SUPPORT_SYSRQ
57#endif
58
59#include <linux/module.h>
60#include <linux/moduleparam.h>
61#include <linux/tty.h>
62#include <linux/tty_flip.h>
63#include <linux/ioport.h>
64#include <linux/init.h>
65#include <linux/console.h>
66#include <linux/sysrq.h>
67#include <linux/serial.h>
68#include <linux/serial_core.h>
69#include <linux/delay.h>
70#include <linux/device.h>
71#include <linux/dma-mapping.h>
72#include <linux/mv643xx.h>
55#include <linux/platform_device.h> 73#include <linux/platform_device.h>
56 74
57#include "mpsc.h" 75#include <asm/io.h>
76#include <asm/irq.h>
77
78#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
79#define SUPPORT_SYSRQ
80#endif
81
82#define MPSC_NUM_CTLRS 2
83
84/*
85 * Descriptors and buffers must be cache line aligned.
86 * Buffers lengths must be multiple of cache line size.
87 * Number of Tx & Rx descriptors must be powers of 2.
88 */
89#define MPSC_RXR_ENTRIES 32
90#define MPSC_RXRE_SIZE dma_get_cache_alignment()
91#define MPSC_RXR_SIZE (MPSC_RXR_ENTRIES * MPSC_RXRE_SIZE)
92#define MPSC_RXBE_SIZE dma_get_cache_alignment()
93#define MPSC_RXB_SIZE (MPSC_RXR_ENTRIES * MPSC_RXBE_SIZE)
94
95#define MPSC_TXR_ENTRIES 32
96#define MPSC_TXRE_SIZE dma_get_cache_alignment()
97#define MPSC_TXR_SIZE (MPSC_TXR_ENTRIES * MPSC_TXRE_SIZE)
98#define MPSC_TXBE_SIZE dma_get_cache_alignment()
99#define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE)
100
101#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \
102 MPSC_TXR_SIZE + MPSC_TXB_SIZE + \
103 dma_get_cache_alignment() /* for alignment */)
104
105/* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */
106struct mpsc_rx_desc {
107 u16 bufsize;
108 u16 bytecnt;
109 u32 cmdstat;
110 u32 link;
111 u32 buf_ptr;
112} __attribute((packed));
113
114struct mpsc_tx_desc {
115 u16 bytecnt;
116 u16 shadow;
117 u32 cmdstat;
118 u32 link;
119 u32 buf_ptr;
120} __attribute((packed));
121
122/*
123 * Some regs that have the erratum that you can't read them are are shared
124 * between the two MPSC controllers. This struct contains those shared regs.
125 */
126struct mpsc_shared_regs {
127 phys_addr_t mpsc_routing_base_p;
128 phys_addr_t sdma_intr_base_p;
129
130 void __iomem *mpsc_routing_base;
131 void __iomem *sdma_intr_base;
132
133 u32 MPSC_MRR_m;
134 u32 MPSC_RCRR_m;
135 u32 MPSC_TCRR_m;
136 u32 SDMA_INTR_CAUSE_m;
137 u32 SDMA_INTR_MASK_m;
138};
139
140/* The main driver data structure */
141struct mpsc_port_info {
142 struct uart_port port; /* Overlay uart_port structure */
143
144 /* Internal driver state for this ctlr */
145 u8 ready;
146 u8 rcv_data;
147 tcflag_t c_iflag; /* save termios->c_iflag */
148 tcflag_t c_cflag; /* save termios->c_cflag */
149
150 /* Info passed in from platform */
151 u8 mirror_regs; /* Need to mirror regs? */
152 u8 cache_mgmt; /* Need manual cache mgmt? */
153 u8 brg_can_tune; /* BRG has baud tuning? */
154 u32 brg_clk_src;
155 u16 mpsc_max_idle;
156 int default_baud;
157 int default_bits;
158 int default_parity;
159 int default_flow;
160
161 /* Physical addresses of various blocks of registers (from platform) */
162 phys_addr_t mpsc_base_p;
163 phys_addr_t sdma_base_p;
164 phys_addr_t brg_base_p;
165
166 /* Virtual addresses of various blocks of registers (from platform) */
167 void __iomem *mpsc_base;
168 void __iomem *sdma_base;
169 void __iomem *brg_base;
170
171 /* Descriptor ring and buffer allocations */
172 void *dma_region;
173 dma_addr_t dma_region_p;
174
175 dma_addr_t rxr; /* Rx descriptor ring */
176 dma_addr_t rxr_p; /* Phys addr of rxr */
177 u8 *rxb; /* Rx Ring I/O buf */
178 u8 *rxb_p; /* Phys addr of rxb */
179 u32 rxr_posn; /* First desc w/ Rx data */
180
181 dma_addr_t txr; /* Tx descriptor ring */
182 dma_addr_t txr_p; /* Phys addr of txr */
183 u8 *txb; /* Tx Ring I/O buf */
184 u8 *txb_p; /* Phys addr of txb */
185 int txr_head; /* Where new data goes */
186 int txr_tail; /* Where sent data comes off */
187
188 /* Mirrored values of regs we can't read (if 'mirror_regs' set) */
189 u32 MPSC_MPCR_m;
190 u32 MPSC_CHR_1_m;
191 u32 MPSC_CHR_2_m;
192 u32 MPSC_CHR_10_m;
193 u32 BRG_BCR_m;
194 struct mpsc_shared_regs *shared_regs;
195};
196
197/* Hooks to platform-specific code */
198int mpsc_platform_register_driver(void);
199void mpsc_platform_unregister_driver(void);
200
201/* Hooks back in to mpsc common to be called by platform-specific code */
202struct mpsc_port_info *mpsc_device_probe(int index);
203struct mpsc_port_info *mpsc_device_remove(int index);
204
205/* Main MPSC Configuration Register Offsets */
206#define MPSC_MMCRL 0x0000
207#define MPSC_MMCRH 0x0004
208#define MPSC_MPCR 0x0008
209#define MPSC_CHR_1 0x000c
210#define MPSC_CHR_2 0x0010
211#define MPSC_CHR_3 0x0014
212#define MPSC_CHR_4 0x0018
213#define MPSC_CHR_5 0x001c
214#define MPSC_CHR_6 0x0020
215#define MPSC_CHR_7 0x0024
216#define MPSC_CHR_8 0x0028
217#define MPSC_CHR_9 0x002c
218#define MPSC_CHR_10 0x0030
219#define MPSC_CHR_11 0x0034
220
221#define MPSC_MPCR_FRZ (1 << 9)
222#define MPSC_MPCR_CL_5 0
223#define MPSC_MPCR_CL_6 1
224#define MPSC_MPCR_CL_7 2
225#define MPSC_MPCR_CL_8 3
226#define MPSC_MPCR_SBL_1 0
227#define MPSC_MPCR_SBL_2 1
228
229#define MPSC_CHR_2_TEV (1<<1)
230#define MPSC_CHR_2_TA (1<<7)
231#define MPSC_CHR_2_TTCS (1<<9)
232#define MPSC_CHR_2_REV (1<<17)
233#define MPSC_CHR_2_RA (1<<23)
234#define MPSC_CHR_2_CRD (1<<25)
235#define MPSC_CHR_2_EH (1<<31)
236#define MPSC_CHR_2_PAR_ODD 0
237#define MPSC_CHR_2_PAR_SPACE 1
238#define MPSC_CHR_2_PAR_EVEN 2
239#define MPSC_CHR_2_PAR_MARK 3
240
241/* MPSC Signal Routing */
242#define MPSC_MRR 0x0000
243#define MPSC_RCRR 0x0004
244#define MPSC_TCRR 0x0008
245
246/* Serial DMA Controller Interface Registers */
247#define SDMA_SDC 0x0000
248#define SDMA_SDCM 0x0008
249#define SDMA_RX_DESC 0x0800
250#define SDMA_RX_BUF_PTR 0x0808
251#define SDMA_SCRDP 0x0810
252#define SDMA_TX_DESC 0x0c00
253#define SDMA_SCTDP 0x0c10
254#define SDMA_SFTDP 0x0c14
255
256#define SDMA_DESC_CMDSTAT_PE (1<<0)
257#define SDMA_DESC_CMDSTAT_CDL (1<<1)
258#define SDMA_DESC_CMDSTAT_FR (1<<3)
259#define SDMA_DESC_CMDSTAT_OR (1<<6)
260#define SDMA_DESC_CMDSTAT_BR (1<<9)
261#define SDMA_DESC_CMDSTAT_MI (1<<10)
262#define SDMA_DESC_CMDSTAT_A (1<<11)
263#define SDMA_DESC_CMDSTAT_AM (1<<12)
264#define SDMA_DESC_CMDSTAT_CT (1<<13)
265#define SDMA_DESC_CMDSTAT_C (1<<14)
266#define SDMA_DESC_CMDSTAT_ES (1<<15)
267#define SDMA_DESC_CMDSTAT_L (1<<16)
268#define SDMA_DESC_CMDSTAT_F (1<<17)
269#define SDMA_DESC_CMDSTAT_P (1<<18)
270#define SDMA_DESC_CMDSTAT_EI (1<<23)
271#define SDMA_DESC_CMDSTAT_O (1<<31)
272
273#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \
274 SDMA_DESC_CMDSTAT_EI)
275
276#define SDMA_SDC_RFT (1<<0)
277#define SDMA_SDC_SFM (1<<1)
278#define SDMA_SDC_BLMR (1<<6)
279#define SDMA_SDC_BLMT (1<<7)
280#define SDMA_SDC_POVR (1<<8)
281#define SDMA_SDC_RIFB (1<<9)
282
283#define SDMA_SDCM_ERD (1<<7)
284#define SDMA_SDCM_AR (1<<15)
285#define SDMA_SDCM_STD (1<<16)
286#define SDMA_SDCM_TXD (1<<23)
287#define SDMA_SDCM_AT (1<<31)
288
289#define SDMA_0_CAUSE_RXBUF (1<<0)
290#define SDMA_0_CAUSE_RXERR (1<<1)
291#define SDMA_0_CAUSE_TXBUF (1<<2)
292#define SDMA_0_CAUSE_TXEND (1<<3)
293#define SDMA_1_CAUSE_RXBUF (1<<8)
294#define SDMA_1_CAUSE_RXERR (1<<9)
295#define SDMA_1_CAUSE_TXBUF (1<<10)
296#define SDMA_1_CAUSE_TXEND (1<<11)
297
298#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \
299 SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR)
300#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \
301 SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND)
302
303/* SDMA Interrupt registers */
304#define SDMA_INTR_CAUSE 0x0000
305#define SDMA_INTR_MASK 0x0080
306
307/* Baud Rate Generator Interface Registers */
308#define BRG_BCR 0x0000
309#define BRG_BTR 0x0004
58 310
59/* 311/*
60 * Define how this driver is known to the outside (we've been assigned a 312 * Define how this driver is known to the outside (we've been assigned a
@@ -1165,7 +1417,7 @@ mpsc_startup(struct uart_port *port)
1165 flag = SA_SHIRQ; 1417 flag = SA_SHIRQ;
1166 1418
1167 if (request_irq(pi->port.irq, mpsc_sdma_intr, flag, 1419 if (request_irq(pi->port.irq, mpsc_sdma_intr, flag,
1168 "mpsc/sdma", pi)) 1420 "mpsc-sdma", pi))
1169 printk(KERN_ERR "MPSC: Can't get SDMA IRQ %d\n", 1421 printk(KERN_ERR "MPSC: Can't get SDMA IRQ %d\n",
1170 pi->port.irq); 1422 pi->port.irq);
1171 1423
diff --git a/drivers/serial/mpsc.h b/drivers/serial/mpsc.h
deleted file mode 100644
index 678dbcf06c8f..000000000000
--- a/drivers/serial/mpsc.h
+++ /dev/null
@@ -1,289 +0,0 @@
1/*
2 * drivers/serial/mpsc.h
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2004 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#ifndef __MPSC_H__
13#define __MPSC_H__
14
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/moduleparam.h>
18#include <linux/tty.h>
19#include <linux/tty_flip.h>
20#include <linux/ioport.h>
21#include <linux/init.h>
22#include <linux/console.h>
23#include <linux/sysrq.h>
24#include <linux/serial.h>
25#include <linux/serial_core.h>
26#include <linux/delay.h>
27#include <linux/device.h>
28#include <linux/dma-mapping.h>
29#include <linux/mv643xx.h>
30
31#include <asm/io.h>
32#include <asm/irq.h>
33
34#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
35#define SUPPORT_SYSRQ
36#endif
37
38#define MPSC_NUM_CTLRS 2
39
40/*
41 * Descriptors and buffers must be cache line aligned.
42 * Buffers lengths must be multiple of cache line size.
43 * Number of Tx & Rx descriptors must be powers of 2.
44 */
45#define MPSC_RXR_ENTRIES 32
46#define MPSC_RXRE_SIZE dma_get_cache_alignment()
47#define MPSC_RXR_SIZE (MPSC_RXR_ENTRIES * MPSC_RXRE_SIZE)
48#define MPSC_RXBE_SIZE dma_get_cache_alignment()
49#define MPSC_RXB_SIZE (MPSC_RXR_ENTRIES * MPSC_RXBE_SIZE)
50
51#define MPSC_TXR_ENTRIES 32
52#define MPSC_TXRE_SIZE dma_get_cache_alignment()
53#define MPSC_TXR_SIZE (MPSC_TXR_ENTRIES * MPSC_TXRE_SIZE)
54#define MPSC_TXBE_SIZE dma_get_cache_alignment()
55#define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE)
56
57#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \
58 MPSC_TXR_SIZE + MPSC_TXB_SIZE + \
59 dma_get_cache_alignment() /* for alignment */)
60
61/* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */
62struct mpsc_rx_desc {
63 u16 bufsize;
64 u16 bytecnt;
65 u32 cmdstat;
66 u32 link;
67 u32 buf_ptr;
68} __attribute((packed));
69
70struct mpsc_tx_desc {
71 u16 bytecnt;
72 u16 shadow;
73 u32 cmdstat;
74 u32 link;
75 u32 buf_ptr;
76} __attribute((packed));
77
78/*
79 * Some regs that have the erratum that you can't read them are are shared
80 * between the two MPSC controllers. This struct contains those shared regs.
81 */
82struct mpsc_shared_regs {
83 phys_addr_t mpsc_routing_base_p;
84 phys_addr_t sdma_intr_base_p;
85
86 void __iomem *mpsc_routing_base;
87 void __iomem *sdma_intr_base;
88
89 u32 MPSC_MRR_m;
90 u32 MPSC_RCRR_m;
91 u32 MPSC_TCRR_m;
92 u32 SDMA_INTR_CAUSE_m;
93 u32 SDMA_INTR_MASK_m;
94};
95
96/* The main driver data structure */
97struct mpsc_port_info {
98 struct uart_port port; /* Overlay uart_port structure */
99
100 /* Internal driver state for this ctlr */
101 u8 ready;
102 u8 rcv_data;
103 tcflag_t c_iflag; /* save termios->c_iflag */
104 tcflag_t c_cflag; /* save termios->c_cflag */
105
106 /* Info passed in from platform */
107 u8 mirror_regs; /* Need to mirror regs? */
108 u8 cache_mgmt; /* Need manual cache mgmt? */
109 u8 brg_can_tune; /* BRG has baud tuning? */
110 u32 brg_clk_src;
111 u16 mpsc_max_idle;
112 int default_baud;
113 int default_bits;
114 int default_parity;
115 int default_flow;
116
117 /* Physical addresses of various blocks of registers (from platform) */
118 phys_addr_t mpsc_base_p;
119 phys_addr_t sdma_base_p;
120 phys_addr_t brg_base_p;
121
122 /* Virtual addresses of various blocks of registers (from platform) */
123 void __iomem *mpsc_base;
124 void __iomem *sdma_base;
125 void __iomem *brg_base;
126
127 /* Descriptor ring and buffer allocations */
128 void *dma_region;
129 dma_addr_t dma_region_p;
130
131 dma_addr_t rxr; /* Rx descriptor ring */
132 dma_addr_t rxr_p; /* Phys addr of rxr */
133 u8 *rxb; /* Rx Ring I/O buf */
134 u8 *rxb_p; /* Phys addr of rxb */
135 u32 rxr_posn; /* First desc w/ Rx data */
136
137 dma_addr_t txr; /* Tx descriptor ring */
138 dma_addr_t txr_p; /* Phys addr of txr */
139 u8 *txb; /* Tx Ring I/O buf */
140 u8 *txb_p; /* Phys addr of txb */
141 int txr_head; /* Where new data goes */
142 int txr_tail; /* Where sent data comes off */
143
144 /* Mirrored values of regs we can't read (if 'mirror_regs' set) */
145 u32 MPSC_MPCR_m;
146 u32 MPSC_CHR_1_m;
147 u32 MPSC_CHR_2_m;
148 u32 MPSC_CHR_10_m;
149 u32 BRG_BCR_m;
150 struct mpsc_shared_regs *shared_regs;
151};
152
153/* Hooks to platform-specific code */
154int mpsc_platform_register_driver(void);
155void mpsc_platform_unregister_driver(void);
156
157/* Hooks back in to mpsc common to be called by platform-specific code */
158struct mpsc_port_info *mpsc_device_probe(int index);
159struct mpsc_port_info *mpsc_device_remove(int index);
160
161/*
162 *****************************************************************************
163 *
164 * Multi-Protocol Serial Controller Interface Registers
165 *
166 *****************************************************************************
167 */
168
169/* Main Configuratino Register Offsets */
170#define MPSC_MMCRL 0x0000
171#define MPSC_MMCRH 0x0004
172#define MPSC_MPCR 0x0008
173#define MPSC_CHR_1 0x000c
174#define MPSC_CHR_2 0x0010
175#define MPSC_CHR_3 0x0014
176#define MPSC_CHR_4 0x0018
177#define MPSC_CHR_5 0x001c
178#define MPSC_CHR_6 0x0020
179#define MPSC_CHR_7 0x0024
180#define MPSC_CHR_8 0x0028
181#define MPSC_CHR_9 0x002c
182#define MPSC_CHR_10 0x0030
183#define MPSC_CHR_11 0x0034
184
185#define MPSC_MPCR_FRZ (1 << 9)
186#define MPSC_MPCR_CL_5 0
187#define MPSC_MPCR_CL_6 1
188#define MPSC_MPCR_CL_7 2
189#define MPSC_MPCR_CL_8 3
190#define MPSC_MPCR_SBL_1 0
191#define MPSC_MPCR_SBL_2 1
192
193#define MPSC_CHR_2_TEV (1<<1)
194#define MPSC_CHR_2_TA (1<<7)
195#define MPSC_CHR_2_TTCS (1<<9)
196#define MPSC_CHR_2_REV (1<<17)
197#define MPSC_CHR_2_RA (1<<23)
198#define MPSC_CHR_2_CRD (1<<25)
199#define MPSC_CHR_2_EH (1<<31)
200#define MPSC_CHR_2_PAR_ODD 0
201#define MPSC_CHR_2_PAR_SPACE 1
202#define MPSC_CHR_2_PAR_EVEN 2
203#define MPSC_CHR_2_PAR_MARK 3
204
205/* MPSC Signal Routing */
206#define MPSC_MRR 0x0000
207#define MPSC_RCRR 0x0004
208#define MPSC_TCRR 0x0008
209
210/*
211 *****************************************************************************
212 *
213 * Serial DMA Controller Interface Registers
214 *
215 *****************************************************************************
216 */
217
218#define SDMA_SDC 0x0000
219#define SDMA_SDCM 0x0008
220#define SDMA_RX_DESC 0x0800
221#define SDMA_RX_BUF_PTR 0x0808
222#define SDMA_SCRDP 0x0810
223#define SDMA_TX_DESC 0x0c00
224#define SDMA_SCTDP 0x0c10
225#define SDMA_SFTDP 0x0c14
226
227#define SDMA_DESC_CMDSTAT_PE (1<<0)
228#define SDMA_DESC_CMDSTAT_CDL (1<<1)
229#define SDMA_DESC_CMDSTAT_FR (1<<3)
230#define SDMA_DESC_CMDSTAT_OR (1<<6)
231#define SDMA_DESC_CMDSTAT_BR (1<<9)
232#define SDMA_DESC_CMDSTAT_MI (1<<10)
233#define SDMA_DESC_CMDSTAT_A (1<<11)
234#define SDMA_DESC_CMDSTAT_AM (1<<12)
235#define SDMA_DESC_CMDSTAT_CT (1<<13)
236#define SDMA_DESC_CMDSTAT_C (1<<14)
237#define SDMA_DESC_CMDSTAT_ES (1<<15)
238#define SDMA_DESC_CMDSTAT_L (1<<16)
239#define SDMA_DESC_CMDSTAT_F (1<<17)
240#define SDMA_DESC_CMDSTAT_P (1<<18)
241#define SDMA_DESC_CMDSTAT_EI (1<<23)
242#define SDMA_DESC_CMDSTAT_O (1<<31)
243
244#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \
245 SDMA_DESC_CMDSTAT_EI)
246
247#define SDMA_SDC_RFT (1<<0)
248#define SDMA_SDC_SFM (1<<1)
249#define SDMA_SDC_BLMR (1<<6)
250#define SDMA_SDC_BLMT (1<<7)
251#define SDMA_SDC_POVR (1<<8)
252#define SDMA_SDC_RIFB (1<<9)
253
254#define SDMA_SDCM_ERD (1<<7)
255#define SDMA_SDCM_AR (1<<15)
256#define SDMA_SDCM_STD (1<<16)
257#define SDMA_SDCM_TXD (1<<23)
258#define SDMA_SDCM_AT (1<<31)
259
260#define SDMA_0_CAUSE_RXBUF (1<<0)
261#define SDMA_0_CAUSE_RXERR (1<<1)
262#define SDMA_0_CAUSE_TXBUF (1<<2)
263#define SDMA_0_CAUSE_TXEND (1<<3)
264#define SDMA_1_CAUSE_RXBUF (1<<8)
265#define SDMA_1_CAUSE_RXERR (1<<9)
266#define SDMA_1_CAUSE_TXBUF (1<<10)
267#define SDMA_1_CAUSE_TXEND (1<<11)
268
269#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \
270 SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR)
271#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \
272 SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND)
273
274/* SDMA Interrupt registers */
275#define SDMA_INTR_CAUSE 0x0000
276#define SDMA_INTR_MASK 0x0080
277
278/*
279 *****************************************************************************
280 *
281 * Baud Rate Generator Interface Registers
282 *
283 *****************************************************************************
284 */
285
286#define BRG_BCR 0x0000
287#define BRG_BTR 0x0004
288
289#endif /* __MPSC_H__ */
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index b1222cd4aa46..7fdbc5dad5fd 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -87,8 +87,6 @@ source "drivers/usb/input/Kconfig"
87 87
88source "drivers/usb/image/Kconfig" 88source "drivers/usb/image/Kconfig"
89 89
90source "drivers/usb/media/Kconfig"
91
92source "drivers/usb/net/Kconfig" 90source "drivers/usb/net/Kconfig"
93 91
94source "drivers/usb/mon/Kconfig" 92source "drivers/usb/mon/Kconfig"
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index bb36a1c1dbb3..9b7d9769fdcc 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -35,20 +35,6 @@ obj-$(CONFIG_USB_WACOM) += input/
35obj-$(CONFIG_USB_ACECAD) += input/ 35obj-$(CONFIG_USB_ACECAD) += input/
36obj-$(CONFIG_USB_XPAD) += input/ 36obj-$(CONFIG_USB_XPAD) += input/
37 37
38obj-$(CONFIG_USB_DABUSB) += media/
39obj-$(CONFIG_USB_DSBR) += media/
40obj-$(CONFIG_USB_ET61X251) += media/
41obj-$(CONFIG_USB_IBMCAM) += media/
42obj-$(CONFIG_USB_KONICAWC) += media/
43obj-$(CONFIG_USB_OV511) += media/
44obj-$(CONFIG_USB_PWC) += media/
45obj-$(CONFIG_USB_SE401) += media/
46obj-$(CONFIG_USB_SN9C102) += media/
47obj-$(CONFIG_USB_STV680) += media/
48obj-$(CONFIG_USB_VICAM) += media/
49obj-$(CONFIG_USB_W9968CF) += media/
50obj-$(CONFIG_USB_ZC0301) += media/
51
52obj-$(CONFIG_USB_CATC) += net/ 38obj-$(CONFIG_USB_CATC) += net/
53obj-$(CONFIG_USB_KAWETH) += net/ 39obj-$(CONFIG_USB_KAWETH) += net/
54obj-$(CONFIG_USB_PEGASUS) += net/ 40obj-$(CONFIG_USB_PEGASUS) += net/
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 28538db9eaf3..2a0e18a48748 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)
360 rc = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf); 360 rc = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf);
361 if (rc < 0) 361 if (rc < 0)
362 return FAILED; 362 return FAILED;
363 result = usb_reset_device(desc->usb_dev);; 363 result = usb_reset_device(desc->usb_dev);
364 if (rc) 364 if (rc)
365 usb_unlock_device(desc->usb_dev); 365 usb_unlock_device(desc->usb_dev);
366 return result ? FAILED : SUCCESS; 366 return result ? FAILED : SUCCESS;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 58b59f6e9881..d4bf1701046b 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)
1215 1215
1216 if (hid->outhead != hid->outtail) { 1216 if (hid->outhead != hid->outtail) {
1217 if (hid_submit_out(hid)) { 1217 if (hid_submit_out(hid)) {
1218 clear_bit(HID_OUT_RUNNING, &hid->iofl);; 1218 clear_bit(HID_OUT_RUNNING, &hid->iofl);
1219 wake_up(&hid->wait); 1219 wake_up(&hid->wait);
1220 } 1220 }
1221 spin_unlock_irqrestore(&hid->outlock, flags); 1221 spin_unlock_irqrestore(&hid->outlock, flags);
diff --git a/drivers/usb/media/Kconfig b/drivers/usb/media/Kconfig
deleted file mode 100644
index 189d40f96be5..000000000000
--- a/drivers/usb/media/Kconfig
+++ /dev/null
@@ -1,241 +0,0 @@
1#
2# USB Multimedia device configuration
3#
4comment "USB Multimedia devices"
5 depends on USB
6
7config USB_DABUSB
8 tristate "DABUSB driver"
9 depends on USB
10 ---help---
11 A Digital Audio Broadcasting (DAB) Receiver for USB and Linux
12 brought to you by the DAB-Team
13 <http://wwwbode.cs.tum.edu/Par/arch/dab/>. This driver can be taken
14 as an example for URB-based bulk, control, and isochronous
15 transactions. URB's are explained in
16 <file:Documentation/usb/URB.txt>.
17
18 To compile this driver as a module, choose M here: the
19 module will be called dabusb.
20
21comment "Video4Linux support is needed for USB Multimedia device support"
22 depends on USB && VIDEO_DEV=n
23
24config USB_VICAM
25 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
26 depends on USB && VIDEO_DEV && EXPERIMENTAL
27 ---help---
28 Say Y here if you have 3com homeconnect camera (vicam).
29
30 This driver uses the Video For Linux API. You must say Y or M to
31 "Video For Linux" (under Multimedia Devices) to use this driver.
32 Information on this API and pointers to "v4l" programs may be found
33 at <file:Documentation/video4linux/API.html>.
34
35 To compile this driver as a module, choose M here: the
36 module will be called vicam.
37
38config USB_DSBR
39 tristate "D-Link USB FM radio support (EXPERIMENTAL)"
40 depends on USB && VIDEO_DEV && EXPERIMENTAL
41 ---help---
42 Say Y here if you want to connect this type of radio to your
43 computer's USB port. Note that the audio is not digital, and
44 you must connect the line out connector to a sound card or a
45 set of speakers.
46
47 This driver uses the Video For Linux API. You must enable
48 (Y or M in config) Video For Linux (under Character Devices)
49 to use this driver. Information on this API and pointers to
50 "v4l" programs may be found at
51 <file:Documentation/video4linux/API.html>.
52
53 To compile this driver as a module, choose M here: the
54 module will be called dsbr100.
55
56config USB_ET61X251
57 tristate "USB ET61X[12]51 PC Camera Controller support"
58 depends on USB && VIDEO_DEV
59 ---help---
60 Say Y here if you want support for cameras based on Etoms ET61X151
61 or ET61X251 PC Camera Controllers.
62
63 See <file:Documentation/usb/et61x251.txt> for more informations.
64
65 This driver uses the Video For Linux API. You must say Y or M to
66 "Video For Linux" to use this driver.
67
68 To compile this driver as a module, choose M here: the
69 module will be called et61x251.
70
71config USB_IBMCAM
72 tristate "USB IBM (Xirlink) C-it Camera support"
73 depends on USB && VIDEO_DEV
74 ---help---
75 Say Y here if you want to connect a IBM "C-It" camera, also known as
76 "Xirlink PC Camera" to your computer's USB port. For more
77 information, read <file:Documentation/usb/ibmcam.txt>.
78
79 This driver uses the Video For Linux API. You must enable
80 (Y or M in config) Video For Linux (under Character Devices)
81 to use this driver. Information on this API and pointers to
82 "v4l" programs may be found at
83 <file:Documentation/video4linux/API.html>.
84
85 To compile this driver as a module, choose M here: the
86 module will be called ibmcam.
87
88 This camera has several configuration options which
89 can be specified when you load the module. Read
90 <file:Documentation/usb/ibmcam.txt> to learn more.
91
92config USB_KONICAWC
93 tristate "USB Konica Webcam support"
94 depends on USB && VIDEO_DEV
95 ---help---
96 Say Y here if you want support for webcams based on a Konica
97 chipset. This is known to work with the Intel YC76 webcam.
98
99 This driver uses the Video For Linux API. You must enable
100 (Y or M in config) Video For Linux (under Character Devices)
101 to use this driver. Information on this API and pointers to
102 "v4l" programs may be found at
103 <file:Documentation/video4linux/API.html>.
104
105 To compile this driver as a module, choose M here: the
106 module will be called konicawc.
107
108config USB_OV511
109 tristate "USB OV511 Camera support"
110 depends on USB && VIDEO_DEV
111 ---help---
112 Say Y here if you want to connect this type of camera to your
113 computer's USB port. See <file:Documentation/usb/ov511.txt> for more
114 information and for a list of supported cameras.
115
116 This driver uses the Video For Linux API. You must say Y or M to
117 "Video For Linux" (under Character Devices) to use this driver.
118 Information on this API and pointers to "v4l" programs may be found
119 at <file:Documentation/video4linux/API.html>.
120
121 To compile this driver as a module, choose M here: the
122 module will be called ov511.
123
124config USB_SE401
125 tristate "USB SE401 Camera support"
126 depends on USB && VIDEO_DEV
127 ---help---
128 Say Y here if you want to connect this type of camera to your
129 computer's USB port. See <file:Documentation/usb/se401.txt> for more
130 information and for a list of supported cameras.
131
132 This driver uses the Video For Linux API. You must say Y or M to
133 "Video For Linux" (under Multimedia Devices) to use this driver.
134 Information on this API and pointers to "v4l" programs may be found
135 at <file:Documentation/video4linux/API.html>.
136
137 To compile this driver as a module, choose M here: the
138 module will be called se401.
139
140config USB_SN9C102
141 tristate "USB SN9C10x PC Camera Controller support"
142 depends on USB && VIDEO_DEV
143 ---help---
144 Say Y here if you want support for cameras based on SONiX SN9C101,
145 SN9C102 or SN9C103 PC Camera Controllers.
146
147 See <file:Documentation/usb/sn9c102.txt> for more informations.
148
149 This driver uses the Video For Linux API. You must say Y or M to
150 "Video For Linux" to use this driver.
151
152 To compile this driver as a module, choose M here: the
153 module will be called sn9c102.
154
155config USB_STV680
156 tristate "USB STV680 (Pencam) Camera support"
157 depends on USB && VIDEO_DEV
158 ---help---
159 Say Y here if you want to connect this type of camera to your
160 computer's USB port. This includes the Pencam line of cameras.
161 See <file:Documentation/usb/stv680.txt> for more information and for
162 a list of supported cameras.
163
164 This driver uses the Video For Linux API. You must say Y or M to
165 "Video For Linux" (under Multimedia Devices) to use this driver.
166 Information on this API and pointers to "v4l" programs may be found
167 at <file:Documentation/video4linux/API.html>.
168
169 To compile this driver as a module, choose M here: the
170 module will be called stv680.
171
172config USB_W9968CF
173 tristate "USB W996[87]CF JPEG Dual Mode Camera support"
174 depends on USB && VIDEO_DEV && I2C && VIDEO_OVCAMCHIP
175 ---help---
176 Say Y here if you want support for cameras based on OV681 or
177 Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips.
178
179 This driver has an optional plugin, which is distributed as a
180 separate module only (released under GPL). It allows to use higher
181 resolutions and framerates, but cannot be included in the official
182 Linux kernel for performance purposes.
183
184 See <file:Documentation/usb/w9968cf.txt> for more informations.
185
186 This driver uses the Video For Linux and the I2C APIs. It needs the
187 OmniVision Camera Chip support as well. You must say Y or M to
188 "Video For Linux", "I2C Support" and "OmniVision Camera Chip
189 support" to use this driver.
190
191 To compile this driver as a module, choose M here: the
192 module will be called w9968cf.
193
194config USB_ZC0301
195 tristate "USB ZC0301 Image Processor and Control Chip support"
196 depends on USB && VIDEO_DEV
197 ---help---
198 Say Y here if you want support for cameras based on the ZC0301
199 Image Processor and Control Chip.
200
201 See <file:Documentation/usb/zc0301.txt> for more informations.
202
203 This driver uses the Video For Linux API. You must say Y or M to
204 "Video For Linux" to use this driver.
205
206 To compile this driver as a module, choose M here: the
207 module will be called zc0301.
208
209config USB_PWC
210 tristate "USB Philips Cameras"
211 depends on USB && VIDEO_DEV
212 ---help---
213 Say Y or M here if you want to use one of these Philips & OEM
214 webcams:
215 * Philips PCA645, PCA646
216 * Philips PCVC675, PCVC680, PCVC690
217 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
218 * Askey VC010
219 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
220 and 'Orbit'/'Sphere'
221 * Samsung MPC-C10, MPC-C30
222 * Creative Webcam 5, Pro Ex
223 * SOTEC Afina Eye
224 * Visionite VCS-UC300, VCS-UM100
225
226 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
227 and never will be, but the 665 and 720/20 are supported by other
228 drivers.
229
230 See <file:Documentation/usb/philips.txt> for more information and
231 installation instructions.
232
233 The built-in microphone is enabled by selecting USB Audio support.
234
235 This driver uses the Video For Linux API. You must say Y or M to
236 "Video For Linux" (under Character Devices) to use this driver.
237 Information on this API and pointers to "v4l" programs may be found
238 at <file:Documentation/video4linux/API.html>.
239
240 To compile this driver as a module, choose M here: the
241 module will be called pwc.
diff --git a/drivers/usb/media/Makefile b/drivers/usb/media/Makefile
deleted file mode 100644
index 50e89a33b85e..000000000000
--- a/drivers/usb/media/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
1#
2# Makefile for USB Media drivers
3#
4
5sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \
6 sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \
7 sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \
8 sn9c102_tas5130d1b.o
9et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
10zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
11
12obj-$(CONFIG_USB_DABUSB) += dabusb.o
13obj-$(CONFIG_USB_DSBR) += dsbr100.o
14obj-$(CONFIG_USB_ET61X251) += et61x251.o
15obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o
16obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o
17obj-$(CONFIG_USB_OV511) += ov511.o
18obj-$(CONFIG_USB_SE401) += se401.o
19obj-$(CONFIG_USB_SN9C102) += sn9c102.o
20obj-$(CONFIG_USB_STV680) += stv680.o
21obj-$(CONFIG_USB_VICAM) += vicam.o usbvideo.o
22obj-$(CONFIG_USB_W9968CF) += w9968cf.o
23obj-$(CONFIG_USB_ZC0301) += zc0301.o
24obj-$(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 c498c68bace1..000000000000
--- a/drivers/usb/media/pwc/pwc-kiara.c
+++ /dev/null
@@ -1,318 +0,0 @@
1/* Linux driver for Philips webcam
2 (C) 2004 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26/* This tables contains entries for the 730/740/750 (Kiara) camera, with
27 4 different qualities (no compression, low, medium, high).
28 It lists the bandwidth requirements for said mode by its alternate interface
29 number. An alternate of 0 means that the mode is unavailable.
30
31 There are 6 * 4 * 4 entries:
32 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
33 6 framerates: 5, 10, 15, 20, 25, 30
34 4 compression modi: none, low, medium, high
35
36 When an uncompressed mode is not available, the next available compressed mode
37 will be chosen (unless the decompressor is absent). Sometimes there are only
38 1 or 2 compressed modes available; in that case entries are duplicated.
39*/
40
41
42#include "pwc-kiara.h"
43#include "pwc-uncompress.h"
44
45const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
46{
47 /* SQCIF */
48 {
49 /* 5 fps */
50 {
51 {0, },
52 {0, },
53 {0, },
54 {0, },
55 },
56 /* 10 fps */
57 {
58 {0, },
59 {0, },
60 {0, },
61 {0, },
62 },
63 /* 15 fps */
64 {
65 {0, },
66 {0, },
67 {0, },
68 {0, },
69 },
70 /* 20 fps */
71 {
72 {0, },
73 {0, },
74 {0, },
75 {0, },
76 },
77 /* 25 fps */
78 {
79 {0, },
80 {0, },
81 {0, },
82 {0, },
83 },
84 /* 30 fps */
85 {
86 {0, },
87 {0, },
88 {0, },
89 {0, },
90 },
91 },
92 /* QSIF */
93 {
94 /* 5 fps */
95 {
96 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
97 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
98 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
99 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
100 },
101 /* 10 fps */
102 {
103 {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
104 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
105 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
106 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
107 },
108 /* 15 fps */
109 {
110 {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
111 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
112 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
113 {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
114 },
115 /* 20 fps */
116 {
117 {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
118 {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
119 {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
120 {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
121 },
122 /* 25 fps */
123 {
124 {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
125 {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
126 {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
127 {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
128 },
129 /* 30 fps */
130 {
131 {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
132 {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
133 {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
134 {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
135 },
136 },
137 /* QCIF */
138 {
139 /* 5 fps */
140 {
141 {0, },
142 {0, },
143 {0, },
144 {0, },
145 },
146 /* 10 fps */
147 {
148 {0, },
149 {0, },
150 {0, },
151 {0, },
152 },
153 /* 15 fps */
154 {
155 {0, },
156 {0, },
157 {0, },
158 {0, },
159 },
160 /* 20 fps */
161 {
162 {0, },
163 {0, },
164 {0, },
165 {0, },
166 },
167 /* 25 fps */
168 {
169 {0, },
170 {0, },
171 {0, },
172 {0, },
173 },
174 /* 30 fps */
175 {
176 {0, },
177 {0, },
178 {0, },
179 {0, },
180 },
181 },
182 /* SIF */
183 {
184 /* 5 fps */
185 {
186 {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
187 {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
188 {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
189 {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
190 },
191 /* 10 fps */
192 {
193 {0, },
194 {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
195 {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
196 {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
197 },
198 /* 15 fps */
199 {
200 {0, },
201 {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
202 {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
203 {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
204 },
205 /* 20 fps */
206 {
207 {0, },
208 {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
209 {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
210 {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
211 },
212 /* 25 fps */
213 {
214 {0, },
215 {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
216 {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
217 {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
218 },
219 /* 30 fps */
220 {
221 {0, },
222 {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
223 {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
224 {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
225 },
226 },
227 /* CIF */
228 {
229 /* 5 fps */
230 {
231 {0, },
232 {0, },
233 {0, },
234 {0, },
235 },
236 /* 10 fps */
237 {
238 {0, },
239 {0, },
240 {0, },
241 {0, },
242 },
243 /* 15 fps */
244 {
245 {0, },
246 {0, },
247 {0, },
248 {0, },
249 },
250 /* 20 fps */
251 {
252 {0, },
253 {0, },
254 {0, },
255 {0, },
256 },
257 /* 25 fps */
258 {
259 {0, },
260 {0, },
261 {0, },
262 {0, },
263 },
264 /* 30 fps */
265 {
266 {0, },
267 {0, },
268 {0, },
269 {0, },
270 },
271 },
272 /* VGA */
273 {
274 /* 5 fps */
275 {
276 {0, },
277 {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
278 {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
279 {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
280 },
281 /* 10 fps */
282 {
283 {0, },
284 {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
285 {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
286 {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
287 },
288 /* 15 fps */
289 {
290 {0, },
291 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
292 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
293 {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
294 },
295 /* 20 fps */
296 {
297 {0, },
298 {0, },
299 {0, },
300 {0, },
301 },
302 /* 25 fps */
303 {
304 {0, },
305 {0, },
306 {0, },
307 {0, },
308 },
309 /* 30 fps */
310 {
311 {0, },
312 {0, },
313 {0, },
314 {0, },
315 },
316 },
317};
318
diff --git a/drivers/usb/media/pwc/pwc-timon.c b/drivers/usb/media/pwc/pwc-timon.c
deleted file mode 100644
index dee967173d6c..000000000000
--- a/drivers/usb/media/pwc/pwc-timon.c
+++ /dev/null
@@ -1,316 +0,0 @@
1/* Linux driver for Philips webcam
2 (C) 2004 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26/* This tables contains entries for the 675/680/690 (Timon) camera, with
27 4 different qualities (no compression, low, medium, high).
28 It lists the bandwidth requirements for said mode by its alternate interface
29 number. An alternate of 0 means that the mode is unavailable.
30
31 There are 6 * 4 * 4 entries:
32 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
33 6 framerates: 5, 10, 15, 20, 25, 30
34 4 compression modi: none, low, medium, high
35
36 When an uncompressed mode is not available, the next available compressed mode
37 will be chosen (unless the decompressor is absent). Sometimes there are only
38 1 or 2 compressed modes available; in that case entries are duplicated.
39*/
40
41#include "pwc-timon.h"
42
43const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
44{
45 /* SQCIF */
46 {
47 /* 5 fps */
48 {
49 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
50 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
51 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
52 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
53 },
54 /* 10 fps */
55 {
56 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
57 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
58 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
59 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
60 },
61 /* 15 fps */
62 {
63 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
64 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
65 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
66 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
67 },
68 /* 20 fps */
69 {
70 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
71 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
72 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
73 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
74 },
75 /* 25 fps */
76 {
77 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
78 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
79 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
80 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
81 },
82 /* 30 fps */
83 {
84 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
85 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
86 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
87 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
88 },
89 },
90 /* QSIF */
91 {
92 /* 5 fps */
93 {
94 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
95 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
96 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
97 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
98 },
99 /* 10 fps */
100 {
101 {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
102 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
103 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
104 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
105 },
106 /* 15 fps */
107 {
108 {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
109 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
110 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
111 {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
112 },
113 /* 20 fps */
114 {
115 {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
116 {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
117 {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
118 {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
119 },
120 /* 25 fps */
121 {
122 {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
123 {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
124 {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
125 {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
126 },
127 /* 30 fps */
128 {
129 {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
130 {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
131 {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
132 {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
133 },
134 },
135 /* QCIF */
136 {
137 /* 5 fps */
138 {
139 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
140 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
141 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
142 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
143 },
144 /* 10 fps */
145 {
146 {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
147 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
148 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
149 {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
150 },
151 /* 15 fps */
152 {
153 {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
154 {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
155 {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
156 {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
157 },
158 /* 20 fps */
159 {
160 {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
161 {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
162 {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
163 {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
164 },
165 /* 25 fps */
166 {
167 {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
168 {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
169 {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
170 {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
171 },
172 /* 30 fps */
173 {
174 {0, },
175 {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
176 {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
177 {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
178 },
179 },
180 /* SIF */
181 {
182 /* 5 fps */
183 {
184 {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
185 {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
186 {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
187 {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
188 },
189 /* 10 fps */
190 {
191 {0, },
192 {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
193 {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
194 {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
195 },
196 /* 15 fps */
197 {
198 {0, },
199 {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
200 {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
201 {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
202 },
203 /* 20 fps */
204 {
205 {0, },
206 {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
207 {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
208 {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
209 },
210 /* 25 fps */
211 {
212 {0, },
213 {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
214 {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
215 {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
216 },
217 /* 30 fps */
218 {
219 {0, },
220 {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
221 {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
222 {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
223 },
224 },
225 /* CIF */
226 {
227 /* 5 fps */
228 {
229 {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
230 {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
231 {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
232 {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
233 },
234 /* 10 fps */
235 {
236 {0, },
237 {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
238 {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
239 {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
240 },
241 /* 15 fps */
242 {
243 {0, },
244 {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
245 {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
246 {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
247 },
248 /* 20 fps */
249 {
250 {0, },
251 {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
252 {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
253 {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
254 },
255 /* 25 fps */
256 {
257 {0, },
258 {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
259 {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
260 {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
261 },
262 /* 30 fps */
263 {
264 {0, },
265 {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
266 {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
267 {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
268 },
269 },
270 /* VGA */
271 {
272 /* 5 fps */
273 {
274 {0, },
275 {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
276 {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
277 {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
278 },
279 /* 10 fps */
280 {
281 {0, },
282 {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
283 {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
284 {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
285 },
286 /* 15 fps */
287 {
288 {0, },
289 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
290 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
291 {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
292 },
293 /* 20 fps */
294 {
295 {0, },
296 {0, },
297 {0, },
298 {0, },
299 },
300 /* 25 fps */
301 {
302 {0, },
303 {0, },
304 {0, },
305 {0, },
306 },
307 /* 30 fps */
308 {
309 {0, },
310 {0, },
311 {0, },
312 {0, },
313 },
314 },
315};
316
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index a8455c9e79dd..495db5755df9 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -102,7 +102,7 @@ static struct usb_driver option_driver = {
102 .no_dynamic_id = 1, 102 .no_dynamic_id = 1,
103}; 103};
104 104
105/* The card has three separate interfaces, wich the serial driver 105/* The card has three separate interfaces, which the serial driver
106 * recognizes separately, thus num_port=1. 106 * recognizes separately, thus num_port=1.
107 */ 107 */
108static struct usb_serial_driver option_3port_device = { 108static struct usb_serial_driver option_3port_device = {
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 1f8d805c61e5..5886a2f1323e 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)
2080 OUTREG(0x2ec, 0x6332a3f0); 2080 OUTREG(0x2ec, 0x6332a3f0);
2081 mdelay(17); 2081 mdelay(17);
2082 2082
2083 OUTPLL(pllPPLL_REF_DIV, rinfo->pll.ref_div);; 2083 OUTPLL(pllPPLL_REF_DIV, rinfo->pll.ref_div);
2084 OUTPLL(pllPPLL_DIV_0, rinfo->save_regs[92]); 2084 OUTPLL(pllPPLL_DIV_0, rinfo->save_regs[92]);
2085 2085
2086 mdelay(40); 2086 mdelay(40);
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
index ada6e75eb048..60831bb23685 100644
--- a/drivers/video/backlight/locomolcd.c
+++ b/drivers/video/backlight/locomolcd.c
@@ -20,14 +20,10 @@
20 20
21#include <asm/hardware/locomo.h> 21#include <asm/hardware/locomo.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
23#include <asm/mach/sharpsl_param.h>
24#include <asm/mach-types.h>
23 25
24#ifdef CONFIG_SA1100_COLLIE 26#include "../../../arch/arm/mach-sa1100/generic.h"
25#include <asm/arch/collie.h>
26#else
27#include <asm/arch/poodle.h>
28#endif
29
30extern void (*sa1100fb_lcd_power)(int on);
31 27
32static struct locomo_dev *locomolcd_dev; 28static struct locomo_dev *locomolcd_dev;
33 29
@@ -82,7 +78,7 @@ static void locomolcd_off(int comadj)
82 78
83void locomolcd_power(int on) 79void locomolcd_power(int on)
84{ 80{
85 int comadj = 118; 81 int comadj = sharpsl_param.comadj;
86 unsigned long flags; 82 unsigned long flags;
87 83
88 local_irq_save(flags); 84 local_irq_save(flags);
@@ -93,11 +89,12 @@ void locomolcd_power(int on)
93 } 89 }
94 90
95 /* read comadj */ 91 /* read comadj */
96#ifdef CONFIG_MACH_POODLE 92 if (comadj == -1) {
97 comadj = 118; 93 if (machine_is_poodle())
98#else 94 comadj = 118;
99 comadj = 128; 95 if (machine_is_collie())
100#endif 96 comadj = 128;
97 }
101 98
102 if (on) 99 if (on)
103 locomolcd_on(comadj); 100 locomolcd_on(comadj);
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index c029db4646f6..6577fdfdfc16 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -327,8 +327,7 @@ static void bw2_init_one(struct sbus_dev *sdev)
327 } else 327 } else
328#else 328#else
329 { 329 {
330 if (!sdev) 330 BUG_ON(!sdev);
331 BUG();
332 all->par.physbase = sdev->reg_addrs[0].phys_addr; 331 all->par.physbase = sdev->reg_addrs[0].phys_addr;
333 resp = &sdev->resource[0]; 332 resp = &sdev->resource[0];
334 sbusfb_fill_var(&all->info.var, (sdev ? sdev->prom_node : 0), 1); 333 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 e0dbdfc0c8b4..66d6f2f0a219 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -2622,7 +2622,7 @@ static int __init cirrusfb_init(void)
2622#endif 2622#endif
2623 2623
2624#ifdef CONFIG_ZORRO 2624#ifdef CONFIG_ZORRO
2625 error |= zorro_module_init(&cirrusfb_zorro_driver); 2625 error |= zorro_register_driver(&cirrusfb_zorro_driver);
2626#endif 2626#endif
2627#ifdef CONFIG_PCI 2627#ifdef CONFIG_PCI
2628 error |= pci_register_driver(&cirrusfb_pci_driver); 2628 error |= pci_register_driver(&cirrusfb_pci_driver);
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 9c9b21d469a1..7633e41adda1 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)
466 unsigned long flags; 466 unsigned long flags;
467 u32 fg; 467 u32 fg;
468 468
469 if (rect->rop != ROP_COPY && rect->rop != ROP_XOR) 469 BUG_ON(rect->rop != ROP_COPY && rect->rop != ROP_XOR);
470 BUG();
471 470
472 fg = ((u32 *)info->pseudo_palette)[rect->color]; 471 fg = ((u32 *)info->pseudo_palette)[rect->color];
473 472
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c
index bebdac59d231..abd920a663a0 100644
--- a/drivers/video/hpfb.c
+++ b/drivers/video/hpfb.c
@@ -386,7 +386,9 @@ int __init hpfb_init(void)
386 if (fb_get_options("hpfb", NULL)) 386 if (fb_get_options("hpfb", NULL))
387 return -ENODEV; 387 return -ENODEV;
388 388
389 dio_module_init(&hpfb_driver); 389 err = dio_register_driver(&hpfb_driver);
390 if (err)
391 return err;
390 392
391 fs = get_fs(); 393 fs = get_fs();
392 set_fs(KERNEL_DS); 394 set_fs(KERNEL_DS);
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index 0fbd9b5149f1..a456e67a5b00 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -12,7 +12,6 @@
12 * 12 *
13 */ 13 */
14 14
15/* make checkconfig does not walk through include tree :-( */
16#include <linux/config.h> 15#include <linux/config.h>
17 16
18#include "matroxfb_DAC1064.h" 17#include "matroxfb_DAC1064.h"
diff --git a/drivers/video/matrox/matroxfb_DAC1064.h b/drivers/video/matrox/matroxfb_DAC1064.h
index a6a470127289..2e7238aa2432 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.h
+++ b/drivers/video/matrox/matroxfb_DAC1064.h
@@ -1,7 +1,6 @@
1#ifndef __MATROXFB_DAC1064_H__ 1#ifndef __MATROXFB_DAC1064_H__
2#define __MATROXFB_DAC1064_H__ 2#define __MATROXFB_DAC1064_H__
3 3
4/* make checkconfig does not walk through include tree */
5#include <linux/config.h> 4#include <linux/config.h>
6 5
7#include "matroxfb_base.h" 6#include "matroxfb_base.h"
diff --git a/drivers/video/matrox/matroxfb_Ti3026.c b/drivers/video/matrox/matroxfb_Ti3026.c
index 537ade5d8b21..23ebad0a12d8 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.c
+++ b/drivers/video/matrox/matroxfb_Ti3026.c
@@ -78,7 +78,6 @@
78 * 78 *
79 */ 79 */
80 80
81/* make checkconfig does not verify included files... */
82#include <linux/config.h> 81#include <linux/config.h>
83 82
84#include "matroxfb_Ti3026.h" 83#include "matroxfb_Ti3026.h"
diff --git a/drivers/video/matrox/matroxfb_Ti3026.h b/drivers/video/matrox/matroxfb_Ti3026.h
index 541933d7e4ea..536e5f69de9f 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.h
+++ b/drivers/video/matrox/matroxfb_Ti3026.h
@@ -1,7 +1,6 @@
1#ifndef __MATROXFB_TI3026_H__ 1#ifndef __MATROXFB_TI3026_H__
2#define __MATROXFB_TI3026_H__ 2#define __MATROXFB_TI3026_H__
3 3
4/* make checkconfig does not walk through whole include tree */
5#include <linux/config.h> 4#include <linux/config.h>
6 5
7#include "matroxfb_base.h" 6#include "matroxfb_base.h"
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 4055ff6f5a81..951c9974a1d3 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -99,7 +99,6 @@
99 * 99 *
100 */ 100 */
101 101
102/* make checkconfig does not check included files... */
103#include <linux/config.h> 102#include <linux/config.h>
104#include <linux/version.h> 103#include <linux/version.h>
105 104
diff --git a/drivers/video/matrox/matroxfb_misc.c b/drivers/video/matrox/matroxfb_misc.c
index 455a46ce840c..263d801ef78f 100644
--- a/drivers/video/matrox/matroxfb_misc.c
+++ b/drivers/video/matrox/matroxfb_misc.c
@@ -84,7 +84,6 @@
84 * 84 *
85 */ 85 */
86 86
87/* make checkconfig does not check includes for this... */
88#include <linux/config.h> 87#include <linux/config.h>
89 88
90#include "matroxfb_misc.h" 89#include "matroxfb_misc.h"
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 0e78ddc81583..52c18a35fb41 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -3532,26 +3532,26 @@ int __init pm3fb_init(void)
3532MODULE_AUTHOR("Romain Dolbeau"); 3532MODULE_AUTHOR("Romain Dolbeau");
3533MODULE_DESCRIPTION("Permedia3 framebuffer device driver"); 3533MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
3534static char *mode[PM3_MAX_BOARD]; 3534static char *mode[PM3_MAX_BOARD];
3535MODULE_PARM(mode,PM3_MAX_BOARD_MODULE_ARRAY_STRING); 3535module_param_array(mode, charp, NULL, 0);
3536MODULE_PARM_DESC(mode,"video mode"); 3536MODULE_PARM_DESC(mode,"video mode");
3537MODULE_PARM(disable,PM3_MAX_BOARD_MODULE_ARRAY_SHORT); 3537module_param_array(disable, short, NULL, 0);
3538MODULE_PARM_DESC(disable,"disable board"); 3538MODULE_PARM_DESC(disable,"disable board");
3539static short off[PM3_MAX_BOARD]; 3539static short off[PM3_MAX_BOARD];
3540MODULE_PARM(off,PM3_MAX_BOARD_MODULE_ARRAY_SHORT); 3540module_param_array(off, short, NULL, 0);
3541MODULE_PARM_DESC(off,"disable board"); 3541MODULE_PARM_DESC(off,"disable board");
3542static char *pciid[PM3_MAX_BOARD]; 3542static char *pciid[PM3_MAX_BOARD];
3543MODULE_PARM(pciid,PM3_MAX_BOARD_MODULE_ARRAY_STRING); 3543module_param_array(pciid, charp, NULL, 0);
3544MODULE_PARM_DESC(pciid,"board PCI Id"); 3544MODULE_PARM_DESC(pciid,"board PCI Id");
3545MODULE_PARM(noaccel,PM3_MAX_BOARD_MODULE_ARRAY_SHORT); 3545module_param_array(noaccel, short, NULL, 0);
3546MODULE_PARM_DESC(noaccel,"disable accel"); 3546MODULE_PARM_DESC(noaccel,"disable accel");
3547static char *font[PM3_MAX_BOARD]; 3547static char *font[PM3_MAX_BOARD];
3548MODULE_PARM(font,PM3_MAX_BOARD_MODULE_ARRAY_STRING); 3548module_param_array(font, charp, NULL, 0);
3549MODULE_PARM_DESC(font,"choose font"); 3549MODULE_PARM_DESC(font,"choose font");
3550MODULE_PARM(depth,PM3_MAX_BOARD_MODULE_ARRAY_SHORT); 3550module_param(depth, short, NULL, 0);
3551MODULE_PARM_DESC(depth,"boot-time depth"); 3551MODULE_PARM_DESC(depth,"boot-time depth");
3552MODULE_PARM(printtimings, "h"); 3552module_param(printtimings, short, NULL, 0);
3553MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)"); 3553MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)");
3554MODULE_PARM(forcesize, PM3_MAX_BOARD_MODULE_ARRAY_SHORT); 3554module_param(forcesize, short, NULL, 0);
3555MODULE_PARM_DESC(forcesize, "force specified memory size"); 3555MODULE_PARM_DESC(forcesize, "force specified memory size");
3556/* 3556/*
3557MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards") 3557MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c
index 99921df35474..8c1a8b5135c6 100644
--- a/drivers/video/sstfb.c
+++ b/drivers/video/sstfb.c
@@ -32,7 +32,7 @@
32 32
33-TODO: at one time or another test that the mode is acceptable by the monitor 33-TODO: at one time or another test that the mode is acceptable by the monitor
34-ASK: Can I choose different ordering for the color bitfields (rgba argb ...) 34-ASK: Can I choose different ordering for the color bitfields (rgba argb ...)
35 wich one should i use ? is there any preferred one ? It seems ARGB is 35 which one should i use ? is there any preferred one ? It seems ARGB is
36 the one ... 36 the one ...
37-TODO: in set_var check the validity of timings (hsync vsync)... 37-TODO: in set_var check the validity of timings (hsync vsync)...
38-TODO: check and recheck the use of sst_wait_idle : we don't flush the fifo via 38-TODO: check and recheck the use of sst_wait_idle : we don't flush the fifo via
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index 591809cbbb97..2788b8ca9bb1 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -98,7 +98,7 @@ static void matrox_w1_write_ddc_bit(void *, u8);
98 * 98 *
99 * Using tristate pins, since i can't find any open-drain pin in whole motherboard. 99 * Using tristate pins, since i can't find any open-drain pin in whole motherboard.
100 * Unfortunately we can't connect to Intel's 82801xx IO controller 100 * Unfortunately we can't connect to Intel's 82801xx IO controller
101 * since we don't know motherboard schema, wich has pretty unused(may be not) GPIO. 101 * since we don't know motherboard schema, which has pretty unused(may be not) GPIO.
102 * 102 *
103 * I've heard that PIIX also has open drain pin. 103 * I've heard that PIIX also has open drain pin.
104 * 104 *
diff --git a/drivers/zorro/zorro-driver.c b/drivers/zorro/zorro-driver.c
index fcbee748c592..067c07be928c 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)
65 * @drv: the driver structure to register 65 * @drv: the driver structure to register
66 * 66 *
67 * Adds the driver structure to the list of registered drivers 67 * Adds the driver structure to the list of registered drivers
68 * Returns the number of Zorro devices which were claimed by the driver 68 * Returns zero or a negative error value.
69 * during registration. The driver remains registered even if the
70 * return value is zero.
71 */ 69 */
72 70
73int zorro_register_driver(struct zorro_driver *drv) 71int zorro_register_driver(struct zorro_driver *drv)
74{ 72{
75 int count = 0;
76
77 /* initialize common driver fields */ 73 /* initialize common driver fields */
78 drv->driver.name = drv->name; 74 drv->driver.name = drv->name;
79 drv->driver.bus = &zorro_bus_type; 75 drv->driver.bus = &zorro_bus_type;
80 76
81 /* register with core */ 77 /* register with core */
82 count = driver_register(&drv->driver); 78 return driver_register(&drv->driver);
83 return count ? count : 1;
84} 79}
85 80
86 81
diff --git a/fs/9p/9p.h b/fs/9p/9p.h
index 0cd374d94717..94e2f92ab2e8 100644
--- a/fs/9p/9p.h
+++ b/fs/9p/9p.h
@@ -8,9 +8,8 @@
8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License version 2
12 * the Free Software Foundation; either version 2 of the License, or 12 * as published by the Free Software Foundation.
13 * (at your option) any later version.
14 * 13 *
15 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -235,6 +234,7 @@ struct Tcreate {
235 struct v9fs_str name; 234 struct v9fs_str name;
236 u32 perm; 235 u32 perm;
237 u8 mode; 236 u8 mode;
237 struct v9fs_str extension;
238}; 238};
239 239
240struct Rcreate { 240struct Rcreate {
@@ -348,8 +348,6 @@ int v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname,
348 348
349int v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid); 349int v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid);
350 350
351int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag);
352
353int v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid, 351int v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid,
354 struct v9fs_fcall **rcall); 352 struct v9fs_fcall **rcall);
355 353
@@ -366,7 +364,7 @@ int v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid,
366 struct v9fs_fcall **rcall); 364 struct v9fs_fcall **rcall);
367 365
368int v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, 366int v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name,
369 u32 perm, u8 mode, struct v9fs_fcall **rcall); 367 u32 perm, u8 mode, char *extension, struct v9fs_fcall **rcall);
370 368
371int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, 369int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid,
372 u64 offset, u32 count, struct v9fs_fcall **rcall); 370 u64 offset, u32 count, struct v9fs_fcall **rcall);
@@ -374,3 +372,4 @@ int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid,
374int v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset, 372int v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset,
375 u32 count, const char __user * data, 373 u32 count, const char __user * data,
376 struct v9fs_fcall **rcall); 374 struct v9fs_fcall **rcall);
375int v9fs_printfcall(char *, int, struct v9fs_fcall *, int);
diff --git a/fs/9p/Makefile b/fs/9p/Makefile
index 2f4ce43f7b6c..87897f84dfb6 100644
--- a/fs/9p/Makefile
+++ b/fs/9p/Makefile
@@ -1,10 +1,9 @@
1obj-$(CONFIG_9P_FS) := 9p2000.o 1obj-$(CONFIG_9P_FS) := 9p.o
2 2
39p2000-objs := \ 39p-objs := \
4 trans_fd.o \ 4 trans_fd.o \
5 trans_sock.o \
6 mux.o \ 5 mux.o \
7 9p.o \ 6 fcall.o \
8 conv.o \ 7 conv.o \
9 vfs_super.o \ 8 vfs_super.o \
10 vfs_inode.o \ 9 vfs_inode.o \
@@ -14,5 +13,6 @@ obj-$(CONFIG_9P_FS) := 9p2000.o
14 vfs_dentry.o \ 13 vfs_dentry.o \
15 error.o \ 14 error.o \
16 v9fs.o \ 15 v9fs.o \
17 fid.o 16 fid.o \
17 fcprint.o
18 18
diff --git a/fs/9p/conv.c b/fs/9p/conv.c
index bf1f10067960..a767e05b60bf 100644
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -8,9 +8,8 @@
8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License version 2
12 * the Free Software Foundation; either version 2 of the License, or 12 * as published by the Free Software Foundation.
13 * (at your option) any later version.
14 * 13 *
15 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -536,6 +535,7 @@ struct v9fs_fcall *v9fs_create_tversion(u32 msize, char *version)
536 return fc; 535 return fc;
537} 536}
538 537
538#if 0
539struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname) 539struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname)
540{ 540{
541 int size; 541 int size;
@@ -559,6 +559,7 @@ struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname)
559 error: 559 error:
560 return fc; 560 return fc;
561} 561}
562#endif /* 0 */
562 563
563struct v9fs_fcall * 564struct v9fs_fcall *
564v9fs_create_tattach(u32 fid, u32 afid, char *uname, char *aname) 565v9fs_create_tattach(u32 fid, u32 afid, char *uname, char *aname)
@@ -664,7 +665,8 @@ struct v9fs_fcall *v9fs_create_topen(u32 fid, u8 mode)
664 return fc; 665 return fc;
665} 666}
666 667
667struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode) 668struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
669 char *extension, int extended)
668{ 670{
669 int size; 671 int size;
670 struct v9fs_fcall *fc; 672 struct v9fs_fcall *fc;
@@ -672,6 +674,9 @@ struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
672 struct cbuf *bufp = &buffer; 674 struct cbuf *bufp = &buffer;
673 675
674 size = 4 + 2 + strlen(name) + 4 + 1; /* fid[4] name[s] perm[4] mode[1] */ 676 size = 4 + 2 + strlen(name) + 4 + 1; /* fid[4] name[s] perm[4] mode[1] */
677 if (extended && extension!=NULL)
678 size += 2 + strlen(extension); /* extension[s] */
679
675 fc = v9fs_create_common(bufp, size, TCREATE); 680 fc = v9fs_create_common(bufp, size, TCREATE);
676 if (IS_ERR(fc)) 681 if (IS_ERR(fc))
677 goto error; 682 goto error;
@@ -680,6 +685,8 @@ struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
680 v9fs_put_str(bufp, name, &fc->params.tcreate.name); 685 v9fs_put_str(bufp, name, &fc->params.tcreate.name);
681 v9fs_put_int32(bufp, perm, &fc->params.tcreate.perm); 686 v9fs_put_int32(bufp, perm, &fc->params.tcreate.perm);
682 v9fs_put_int8(bufp, mode, &fc->params.tcreate.mode); 687 v9fs_put_int8(bufp, mode, &fc->params.tcreate.mode);
688 if (extended)
689 v9fs_put_str(bufp, extension, &fc->params.tcreate.extension);
683 690
684 if (buf_check_overflow(bufp)) { 691 if (buf_check_overflow(bufp)) {
685 kfree(fc); 692 kfree(fc);
diff --git a/fs/9p/conv.h b/fs/9p/conv.h
index 26a736e4a2e7..dd5b6b1b610f 100644
--- a/fs/9p/conv.h
+++ b/fs/9p/conv.h
@@ -8,9 +8,8 @@
8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License version 2
12 * the Free Software Foundation; either version 2 of the License, or 12 * as published by the Free Software Foundation.
13 * (at your option) any later version.
14 * 13 *
15 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * 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,
33void v9fs_set_tag(struct v9fs_fcall *fc, u16 tag); 32void v9fs_set_tag(struct v9fs_fcall *fc, u16 tag);
34 33
35struct v9fs_fcall *v9fs_create_tversion(u32 msize, char *version); 34struct v9fs_fcall *v9fs_create_tversion(u32 msize, char *version);
36struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname);
37struct v9fs_fcall *v9fs_create_tattach(u32 fid, u32 afid, char *uname, 35struct v9fs_fcall *v9fs_create_tattach(u32 fid, u32 afid, char *uname,
38 char *aname); 36 char *aname);
39struct v9fs_fcall *v9fs_create_tflush(u16 oldtag); 37struct v9fs_fcall *v9fs_create_tflush(u16 oldtag);
40struct v9fs_fcall *v9fs_create_twalk(u32 fid, u32 newfid, u16 nwname, 38struct v9fs_fcall *v9fs_create_twalk(u32 fid, u32 newfid, u16 nwname,
41 char **wnames); 39 char **wnames);
42struct v9fs_fcall *v9fs_create_topen(u32 fid, u8 mode); 40struct v9fs_fcall *v9fs_create_topen(u32 fid, u8 mode);
43struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode); 41struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
42 char *extension, int extended);
44struct v9fs_fcall *v9fs_create_tread(u32 fid, u64 offset, u32 count); 43struct v9fs_fcall *v9fs_create_tread(u32 fid, u64 offset, u32 count);
45struct v9fs_fcall *v9fs_create_twrite(u32 fid, u64 offset, u32 count, 44struct v9fs_fcall *v9fs_create_twrite(u32 fid, u64 offset, u32 count,
46 const char __user *data); 45 const char __user *data);
diff --git a/fs/9p/debug.h b/fs/9p/debug.h
index fe551032788b..4228c0bb3c32 100644
--- a/fs/9p/debug.h
+++ b/fs/9p/debug.h
@@ -5,9 +5,8 @@
5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License version 2
9 * the Free Software Foundation; either version 2 of the License, or 9 * as published by the Free Software Foundation.
10 * (at your option) any later version.
11 * 10 *
12 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -30,6 +29,7 @@
30#define DEBUG_MUX (1<<5) 29#define DEBUG_MUX (1<<5)
31#define DEBUG_TRANS (1<<6) 30#define DEBUG_TRANS (1<<6)
32#define DEBUG_SLABS (1<<7) 31#define DEBUG_SLABS (1<<7)
32#define DEBUG_FCALL (1<<8)
33 33
34#define DEBUG_DUMP_PKT 0 34#define DEBUG_DUMP_PKT 0
35 35
diff --git a/fs/9p/error.c b/fs/9p/error.c
index e4b6f8f38b6f..981fe8ecd780 100644
--- a/fs/9p/error.c
+++ b/fs/9p/error.c
@@ -11,9 +11,8 @@
11 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 11 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License version 2
15 * the Free Software Foundation; either version 2 of the License, or 15 * as published by the Free Software Foundation.
16 * (at your option) any later version.
17 * 16 *
18 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/error.h b/fs/9p/error.h
index a9794e85fe51..5f3ca522b316 100644
--- a/fs/9p/error.h
+++ b/fs/9p/error.h
@@ -12,9 +12,8 @@
12 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 12 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License version 2
16 * the Free Software Foundation; either version 2 of the License, or 16 * as published by the Free Software Foundation.
17 * (at your option) any later version.
18 * 17 *
19 * This program is distributed in the hope that it will be useful, 18 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/9p.c b/fs/9p/fcall.c
index f86a28d1d6a6..71742ba150c4 100644
--- a/fs/9p/9p.c
+++ b/fs/9p/fcall.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/fs/9p/9p.c 2 * linux/fs/9p/fcall.c
3 * 3 *
4 * This file contains functions to perform synchronous 9P calls 4 * This file contains functions to perform synchronous 9P calls
5 * 5 *
@@ -8,9 +8,8 @@
8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License version 2
12 * the Free Software Foundation; either version 2 of the License, or 12 * as published by the Free Software Foundation.
13 * (at your option) any later version.
14 * 13 *
15 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -148,13 +147,13 @@ v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid)
148 return ret; 147 return ret;
149} 148}
150 149
150#if 0
151/** 151/**
152 * v9fs_v9fs_t_flush - flush a pending transaction 152 * v9fs_v9fs_t_flush - flush a pending transaction
153 * @v9ses: 9P2000 session information 153 * @v9ses: 9P2000 session information
154 * @tag: tid to release 154 * @tag: tag to release
155 * 155 *
156 */ 156 */
157
158int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag) 157int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag)
159{ 158{
160 int ret; 159 int ret;
@@ -171,6 +170,7 @@ int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag)
171 170
172 return ret; 171 return ret;
173} 172}
173#endif
174 174
175/** 175/**
176 * v9fs_t_stat - read a file's meta-data 176 * v9fs_t_stat - read a file's meta-data
@@ -332,8 +332,8 @@ v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid,
332 */ 332 */
333 333
334int 334int
335v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, 335v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, u32 perm,
336 u32 perm, u8 mode, struct v9fs_fcall **rcp) 336 u8 mode, char *extension, struct v9fs_fcall **rcp)
337{ 337{
338 int ret; 338 int ret;
339 struct v9fs_fcall *tc; 339 struct v9fs_fcall *tc;
@@ -341,7 +341,9 @@ v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name,
341 dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n", 341 dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n",
342 fid, name, perm, mode); 342 fid, name, perm, mode);
343 343
344 tc = v9fs_create_tcreate(fid, name, perm, mode); 344 tc = v9fs_create_tcreate(fid, name, perm, mode, extension,
345 v9ses->extended);
346
345 if (!IS_ERR(tc)) { 347 if (!IS_ERR(tc)) {
346 ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); 348 ret = v9fs_mux_rpc(v9ses->mux, tc, rcp);
347 kfree(tc); 349 kfree(tc);
diff --git a/fs/9p/fcprint.c b/fs/9p/fcprint.c
new file mode 100644
index 000000000000..583e827baebd
--- /dev/null
+++ b/fs/9p/fcprint.c
@@ -0,0 +1,346 @@
1/*
2 * linux/fs/9p/fcprint.c
3 *
4 * Print 9P call.
5 *
6 * Copyright (C) 2005 by Latchesar Ionkov <lucho@ionkov.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to:
19 * Free Software Foundation
20 * 51 Franklin Street, Fifth Floor
21 * Boston, MA 02111-1301 USA
22 *
23 */
24#include <linux/config.h>
25#include <linux/module.h>
26#include <linux/errno.h>
27#include <linux/fs.h>
28#include <linux/idr.h>
29
30#include "debug.h"
31#include "v9fs.h"
32#include "9p.h"
33#include "mux.h"
34
35static int
36v9fs_printqid(char *buf, int buflen, struct v9fs_qid *q)
37{
38 int n;
39 char b[10];
40
41 n = 0;
42 if (q->type & V9FS_QTDIR)
43 b[n++] = 'd';
44 if (q->type & V9FS_QTAPPEND)
45 b[n++] = 'a';
46 if (q->type & V9FS_QTAUTH)
47 b[n++] = 'A';
48 if (q->type & V9FS_QTEXCL)
49 b[n++] = 'l';
50 if (q->type & V9FS_QTTMP)
51 b[n++] = 't';
52 if (q->type & V9FS_QTSYMLINK)
53 b[n++] = 'L';
54 b[n] = '\0';
55
56 return scnprintf(buf, buflen, "(%.16llx %x %s)", (long long int) q->path,
57 q->version, b);
58}
59
60static int
61v9fs_printperm(char *buf, int buflen, int perm)
62{
63 int n;
64 char b[15];
65
66 n = 0;
67 if (perm & V9FS_DMDIR)
68 b[n++] = 'd';
69 if (perm & V9FS_DMAPPEND)
70 b[n++] = 'a';
71 if (perm & V9FS_DMAUTH)
72 b[n++] = 'A';
73 if (perm & V9FS_DMEXCL)
74 b[n++] = 'l';
75 if (perm & V9FS_DMTMP)
76 b[n++] = 't';
77 if (perm & V9FS_DMDEVICE)
78 b[n++] = 'D';
79 if (perm & V9FS_DMSOCKET)
80 b[n++] = 'S';
81 if (perm & V9FS_DMNAMEDPIPE)
82 b[n++] = 'P';
83 if (perm & V9FS_DMSYMLINK)
84 b[n++] = 'L';
85 b[n] = '\0';
86
87 return scnprintf(buf, buflen, "%s%03o", b, perm&077);
88}
89
90static int
91v9fs_printstat(char *buf, int buflen, struct v9fs_stat *st, int extended)
92{
93 int n;
94
95 n = scnprintf(buf, buflen, "'%.*s' '%.*s'", st->name.len,
96 st->name.str, st->uid.len, st->uid.str);
97 if (extended)
98 n += scnprintf(buf+n, buflen-n, "(%d)", st->n_uid);
99
100 n += scnprintf(buf+n, buflen-n, " '%.*s'", st->gid.len, st->gid.str);
101 if (extended)
102 n += scnprintf(buf+n, buflen-n, "(%d)", st->n_gid);
103
104 n += scnprintf(buf+n, buflen-n, " '%.*s'", st->muid.len, st->muid.str);
105 if (extended)
106 n += scnprintf(buf+n, buflen-n, "(%d)", st->n_muid);
107
108 n += scnprintf(buf+n, buflen-n, " q ");
109 n += v9fs_printqid(buf+n, buflen-n, &st->qid);
110 n += scnprintf(buf+n, buflen-n, " m ");
111 n += v9fs_printperm(buf+n, buflen-n, st->mode);
112 n += scnprintf(buf+n, buflen-n, " at %d mt %d l %lld",
113 st->atime, st->mtime, (long long int) st->length);
114
115 if (extended)
116 n += scnprintf(buf+n, buflen-n, " ext '%.*s'",
117 st->extension.len, st->extension.str);
118
119 return n;
120}
121
122static int
123v9fs_dumpdata(char *buf, int buflen, u8 *data, int datalen)
124{
125 int i, n;
126
127 i = n = 0;
128 while (i < datalen) {
129 n += scnprintf(buf + n, buflen - n, "%02x", data[i]);
130 if (i%4 == 3)
131 n += scnprintf(buf + n, buflen - n, " ");
132 if (i%32 == 31)
133 n += scnprintf(buf + n, buflen - n, "\n");
134
135 i++;
136 }
137 n += scnprintf(buf + n, buflen - n, "\n");
138
139 return n;
140}
141
142static int
143v9fs_printdata(char *buf, int buflen, u8 *data, int datalen)
144{
145 return v9fs_dumpdata(buf, buflen, data, datalen<16?datalen:16);
146}
147
148int
149v9fs_printfcall(char *buf, int buflen, struct v9fs_fcall *fc, int extended)
150{
151 int i, ret, type, tag;
152
153 if (!fc)
154 return scnprintf(buf, buflen, "<NULL>");
155
156 type = fc->id;
157 tag = fc->tag;
158
159 ret = 0;
160 switch (type) {
161 case TVERSION:
162 ret += scnprintf(buf+ret, buflen-ret,
163 "Tversion tag %u msize %u version '%.*s'", tag,
164 fc->params.tversion.msize, fc->params.tversion.version.len,
165 fc->params.tversion.version.str);
166 break;
167
168 case RVERSION:
169 ret += scnprintf(buf+ret, buflen-ret,
170 "Rversion tag %u msize %u version '%.*s'", tag,
171 fc->params.rversion.msize, fc->params.rversion.version.len,
172 fc->params.rversion.version.str);
173 break;
174
175 case TAUTH:
176 ret += scnprintf(buf+ret, buflen-ret,
177 "Tauth tag %u afid %d uname '%.*s' aname '%.*s'", tag,
178 fc->params.tauth.afid, fc->params.tauth.uname.len,
179 fc->params.tauth.uname.str, fc->params.tauth.aname.len,
180 fc->params.tauth.aname.str);
181 break;
182
183 case RAUTH:
184 ret += scnprintf(buf+ret, buflen-ret, "Rauth tag %u qid ", tag);
185 v9fs_printqid(buf+ret, buflen-ret, &fc->params.rauth.qid);
186 break;
187
188 case TATTACH:
189 ret += scnprintf(buf+ret, buflen-ret,
190 "Tattach tag %u fid %d afid %d uname '%.*s' aname '%.*s'",
191 tag, fc->params.tattach.fid, fc->params.tattach.afid,
192 fc->params.tattach.uname.len, fc->params.tattach.uname.str,
193 fc->params.tattach.aname.len, fc->params.tattach.aname.str);
194 break;
195
196 case RATTACH:
197 ret += scnprintf(buf+ret, buflen-ret, "Rattach tag %u qid ", tag);
198 v9fs_printqid(buf+ret, buflen-ret, &fc->params.rattach.qid);
199 break;
200
201 case RERROR:
202 ret += scnprintf(buf+ret, buflen-ret, "Rerror tag %u ename '%.*s'",
203 tag, fc->params.rerror.error.len,
204 fc->params.rerror.error.str);
205 if (extended)
206 ret += scnprintf(buf+ret, buflen-ret, " ecode %d\n",
207 fc->params.rerror.errno);
208 break;
209
210 case TFLUSH:
211 ret += scnprintf(buf+ret, buflen-ret, "Tflush tag %u oldtag %u",
212 tag, fc->params.tflush.oldtag);
213 break;
214
215 case RFLUSH:
216 ret += scnprintf(buf+ret, buflen-ret, "Rflush tag %u", tag);
217 break;
218
219 case TWALK:
220 ret += scnprintf(buf+ret, buflen-ret,
221 "Twalk tag %u fid %d newfid %d nwname %d", tag,
222 fc->params.twalk.fid, fc->params.twalk.newfid,
223 fc->params.twalk.nwname);
224 for(i = 0; i < fc->params.twalk.nwname; i++)
225 ret += scnprintf(buf+ret, buflen-ret," '%.*s'",
226 fc->params.twalk.wnames[i].len,
227 fc->params.twalk.wnames[i].str);
228 break;
229
230 case RWALK:
231 ret += scnprintf(buf+ret, buflen-ret, "Rwalk tag %u nwqid %d",
232 tag, fc->params.rwalk.nwqid);
233 for(i = 0; i < fc->params.rwalk.nwqid; i++)
234 ret += v9fs_printqid(buf+ret, buflen-ret,
235 &fc->params.rwalk.wqids[i]);
236 break;
237
238 case TOPEN:
239 ret += scnprintf(buf+ret, buflen-ret,
240 "Topen tag %u fid %d mode %d", tag,
241 fc->params.topen.fid, fc->params.topen.mode);
242 break;
243
244 case ROPEN:
245 ret += scnprintf(buf+ret, buflen-ret, "Ropen tag %u", tag);
246 ret += v9fs_printqid(buf+ret, buflen-ret, &fc->params.ropen.qid);
247 ret += scnprintf(buf+ret, buflen-ret," iounit %d",
248 fc->params.ropen.iounit);
249 break;
250
251 case TCREATE:
252 ret += scnprintf(buf+ret, buflen-ret,
253 "Tcreate tag %u fid %d name '%.*s' perm ", tag,
254 fc->params.tcreate.fid, fc->params.tcreate.name.len,
255 fc->params.tcreate.name.str);
256
257 ret += v9fs_printperm(buf+ret, buflen-ret, fc->params.tcreate.perm);
258 ret += scnprintf(buf+ret, buflen-ret, " mode %d",
259 fc->params.tcreate.mode);
260 break;
261
262 case RCREATE:
263 ret += scnprintf(buf+ret, buflen-ret, "Rcreate tag %u", tag);
264 ret += v9fs_printqid(buf+ret, buflen-ret, &fc->params.rcreate.qid);
265 ret += scnprintf(buf+ret, buflen-ret, " iounit %d",
266 fc->params.rcreate.iounit);
267 break;
268
269 case TREAD:
270 ret += scnprintf(buf+ret, buflen-ret,
271 "Tread tag %u fid %d offset %lld count %u", tag,
272 fc->params.tread.fid,
273 (long long int) fc->params.tread.offset,
274 fc->params.tread.count);
275 break;
276
277 case RREAD:
278 ret += scnprintf(buf+ret, buflen-ret,
279 "Rread tag %u count %u data ", tag,
280 fc->params.rread.count);
281 ret += v9fs_printdata(buf+ret, buflen-ret, fc->params.rread.data,
282 fc->params.rread.count);
283 break;
284
285 case TWRITE:
286 ret += scnprintf(buf+ret, buflen-ret,
287 "Twrite tag %u fid %d offset %lld count %u data ",
288 tag, fc->params.twrite.fid,
289 (long long int) fc->params.twrite.offset,
290 fc->params.twrite.count);
291 ret += v9fs_printdata(buf+ret, buflen-ret, fc->params.twrite.data,
292 fc->params.twrite.count);
293 break;
294
295 case RWRITE:
296 ret += scnprintf(buf+ret, buflen-ret, "Rwrite tag %u count %u",
297 tag, fc->params.rwrite.count);
298 break;
299
300 case TCLUNK:
301 ret += scnprintf(buf+ret, buflen-ret, "Tclunk tag %u fid %d",
302 tag, fc->params.tclunk.fid);
303 break;
304
305 case RCLUNK:
306 ret += scnprintf(buf+ret, buflen-ret, "Rclunk tag %u", tag);
307 break;
308
309 case TREMOVE:
310 ret += scnprintf(buf+ret, buflen-ret, "Tremove tag %u fid %d",
311 tag, fc->params.tremove.fid);
312 break;
313
314 case RREMOVE:
315 ret += scnprintf(buf+ret, buflen-ret, "Rremove tag %u", tag);
316 break;
317
318 case TSTAT:
319 ret += scnprintf(buf+ret, buflen-ret, "Tstat tag %u fid %d",
320 tag, fc->params.tstat.fid);
321 break;
322
323 case RSTAT:
324 ret += scnprintf(buf+ret, buflen-ret, "Rstat tag %u ", tag);
325 ret += v9fs_printstat(buf+ret, buflen-ret, &fc->params.rstat.stat,
326 extended);
327 break;
328
329 case TWSTAT:
330 ret += scnprintf(buf+ret, buflen-ret, "Twstat tag %u fid %d ",
331 tag, fc->params.twstat.fid);
332 ret += v9fs_printstat(buf+ret, buflen-ret, &fc->params.twstat.stat,
333 extended);
334 break;
335
336 case RWSTAT:
337 ret += scnprintf(buf+ret, buflen-ret, "Rwstat tag %u", tag);
338 break;
339
340 default:
341 ret += scnprintf(buf+ret, buflen-ret, "unknown type %d", type);
342 break;
343 }
344
345 return ret;
346}
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index c4d13bf904d2..b7608af07ce8 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -4,9 +4,8 @@
4 * Copyright (C) 2005, 2006 by Eric Van Hensbergen <ericvh@gmail.com> 4 * Copyright (C) 2005, 2006 by Eric Van Hensbergen <ericvh@gmail.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License version 2
8 * the Free Software Foundation; either version 2 of the License, or 8 * as published by the Free Software Foundation.
9 * (at your option) any later version.
10 * 9 *
11 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 1fc2dd08d75a..aa974d6875c3 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -4,9 +4,8 @@
4 * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com> 4 * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License version 2
8 * the Free Software Foundation; either version 2 of the License, or 8 * as published by the Free Software Foundation.
9 * (at your option) any later version.
10 * 9 *
11 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index 8e8356c1c229..3e5b124a7212 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> 7 * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -70,7 +69,7 @@ struct v9fs_mux_data {
70 int msize; 69 int msize;
71 unsigned char *extended; 70 unsigned char *extended;
72 struct v9fs_transport *trans; 71 struct v9fs_transport *trans;
73 struct v9fs_idpool tidpool; 72 struct v9fs_idpool tagpool;
74 int err; 73 int err;
75 wait_queue_head_t equeue; 74 wait_queue_head_t equeue;
76 struct list_head req_list; 75 struct list_head req_list;
@@ -143,7 +142,7 @@ void v9fs_mux_global_exit(void)
143 * 142 *
144 * The current implementation returns sqrt of the number of mounts. 143 * The current implementation returns sqrt of the number of mounts.
145 */ 144 */
146inline int v9fs_mux_calc_poll_procs(int muxnum) 145static int v9fs_mux_calc_poll_procs(int muxnum)
147{ 146{
148 int n; 147 int n;
149 148
@@ -280,8 +279,8 @@ struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
280 m->msize = msize; 279 m->msize = msize;
281 m->extended = extended; 280 m->extended = extended;
282 m->trans = trans; 281 m->trans = trans;
283 idr_init(&m->tidpool.pool); 282 idr_init(&m->tagpool.pool);
284 init_MUTEX(&m->tidpool.lock); 283 init_MUTEX(&m->tagpool.lock);
285 m->err = 0; 284 m->err = 0;
286 init_waitqueue_head(&m->equeue); 285 init_waitqueue_head(&m->equeue);
287 INIT_LIST_HEAD(&m->req_list); 286 INIT_LIST_HEAD(&m->req_list);
@@ -384,7 +383,7 @@ v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
384/** 383/**
385 * v9fs_poll_mux - polls a mux and schedules read or write works if necessary 384 * v9fs_poll_mux - polls a mux and schedules read or write works if necessary
386 */ 385 */
387static inline void v9fs_poll_mux(struct v9fs_mux_data *m) 386static void v9fs_poll_mux(struct v9fs_mux_data *m)
388{ 387{
389 int n; 388 int n;
390 389
@@ -635,6 +634,14 @@ static void v9fs_read_work(void *a)
635 goto error; 634 goto error;
636 } 635 }
637 636
637 if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
638 char buf[150];
639
640 v9fs_printfcall(buf, sizeof(buf), m->rcall,
641 *m->extended);
642 printk(KERN_NOTICE ">>> %p %s\n", m, buf);
643 }
644
638 rcall = m->rcall; 645 rcall = m->rcall;
639 rbuf = m->rbuf; 646 rbuf = m->rbuf;
640 if (m->rpos > n) { 647 if (m->rpos > n) {
@@ -740,6 +747,13 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
740 747
741 v9fs_set_tag(tc, n); 748 v9fs_set_tag(tc, n);
742 749
750 if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
751 char buf[150];
752
753 v9fs_printfcall(buf, sizeof(buf), tc, *m->extended);
754 printk(KERN_NOTICE "<<< %p %s\n", m, buf);
755 }
756
743 req->tag = n; 757 req->tag = n;
744 req->tcall = tc; 758 req->tcall = tc;
745 req->rcall = NULL; 759 req->rcall = NULL;
@@ -762,9 +776,8 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
762 return req; 776 return req;
763} 777}
764 778
765static inline void 779static void v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc,
766v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc, struct v9fs_fcall *rc, 780 struct v9fs_fcall *rc, int err)
767 int err)
768{ 781{
769 v9fs_mux_req_callback cb; 782 v9fs_mux_req_callback cb;
770 int tag; 783 int tag;
@@ -902,6 +915,7 @@ v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
902 return err; 915 return err;
903} 916}
904 917
918#if 0
905/** 919/**
906 * v9fs_mux_rpcnb - sends 9P request without waiting for response. 920 * v9fs_mux_rpcnb - sends 9P request without waiting for response.
907 * @m: mux data 921 * @m: mux data
@@ -925,6 +939,7 @@ int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
925 dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag); 939 dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag);
926 return 0; 940 return 0;
927} 941}
942#endif /* 0 */
928 943
929/** 944/**
930 * v9fs_mux_cancel - cancel all pending requests with error 945 * v9fs_mux_cancel - cancel all pending requests with error
@@ -964,7 +979,7 @@ static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m)
964{ 979{
965 int tag; 980 int tag;
966 981
967 tag = v9fs_get_idpool(&m->tidpool); 982 tag = v9fs_get_idpool(&m->tagpool);
968 if (tag < 0) 983 if (tag < 0)
969 return V9FS_NOTAG; 984 return V9FS_NOTAG;
970 else 985 else
@@ -973,6 +988,6 @@ static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m)
973 988
974static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag) 989static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag)
975{ 990{
976 if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tidpool)) 991 if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tagpool))
977 v9fs_put_idpool(tag, &m->tidpool); 992 v9fs_put_idpool(tag, &m->tagpool);
978} 993}
diff --git a/fs/9p/mux.h b/fs/9p/mux.h
index 9473b84f24b2..e90bfd32ea42 100644
--- a/fs/9p/mux.h
+++ b/fs/9p/mux.h
@@ -7,9 +7,8 @@
7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,8 +49,6 @@ void v9fs_mux_destroy(struct v9fs_mux_data *);
50int v9fs_mux_send(struct v9fs_mux_data *m, struct v9fs_fcall *tc); 49int v9fs_mux_send(struct v9fs_mux_data *m, struct v9fs_fcall *tc);
51struct v9fs_fcall *v9fs_mux_recv(struct v9fs_mux_data *m); 50struct v9fs_fcall *v9fs_mux_recv(struct v9fs_mux_data *m);
52int v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc, struct v9fs_fcall **rc); 51int v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc, struct v9fs_fcall **rc);
53int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
54 v9fs_mux_req_callback cb, void *a);
55 52
56void v9fs_mux_flush(struct v9fs_mux_data *m, int sendflush); 53void v9fs_mux_flush(struct v9fs_mux_data *m, int sendflush);
57void v9fs_mux_cancel(struct v9fs_mux_data *m, int err); 54void 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 5b2ce21b10fa..94e0a7fd9fc2 100644
--- a/fs/9p/trans_fd.c
+++ b/fs/9p/trans_fd.c
@@ -1,15 +1,16 @@
1/* 1/*
2 * linux/fs/9p/trans_fd.c 2 * linux/fs/9p/trans_fd.c
3 * 3 *
4 * File Descriptor Transport Layer 4 * Fd transport layer. Includes deprecated socket layer.
5 * 5 *
6 * Copyright (C) 2005 by Latchesar Ionkov <lucho@ionkov.net> 6 * Copyright (C) 2006 by Russ Cox <rsc@swtch.com>
7 * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com> 7 * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
8 * Copyright (C) 2004-2005 by Eric Van Hensbergen <ericvh@gmail.com>
9 * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com>
8 * 10 *
9 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 13 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 14 *
14 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,6 +26,7 @@
25 */ 26 */
26 27
27#include <linux/config.h> 28#include <linux/config.h>
29#include <linux/in.h>
28#include <linux/module.h> 30#include <linux/module.h>
29#include <linux/net.h> 31#include <linux/net.h>
30#include <linux/ipv6.h> 32#include <linux/ipv6.h>
@@ -40,89 +42,119 @@
40#include "v9fs.h" 42#include "v9fs.h"
41#include "transport.h" 43#include "transport.h"
42 44
45#define V9FS_PORT 564
46
43struct v9fs_trans_fd { 47struct v9fs_trans_fd {
44 struct file *in_file; 48 struct file *rd;
45 struct file *out_file; 49 struct file *wr;
46}; 50};
47 51
48/** 52/**
49 * v9fs_fd_recv - receive from a socket 53 * v9fs_fd_read- read from a fd
50 * @v9ses: session information 54 * @v9ses: session information
51 * @v: buffer to receive data into 55 * @v: buffer to receive data into
52 * @len: size of receive buffer 56 * @len: size of receive buffer
53 * 57 *
54 */ 58 */
55 59static int v9fs_fd_read(struct v9fs_transport *trans, void *v, int len)
56static int v9fs_fd_recv(struct v9fs_transport *trans, void *v, int len)
57{ 60{
58 struct v9fs_trans_fd *ts = trans ? trans->priv : NULL; 61 int ret;
62 struct v9fs_trans_fd *ts;
59 63
60 if (!trans || trans->status != Connected || !ts) 64 if (!trans || trans->status == Disconnected || !(ts = trans->priv))
61 return -EIO; 65 return -EREMOTEIO;
62 66
63 return kernel_read(ts->in_file, ts->in_file->f_pos, v, len); 67 if (!(ts->rd->f_flags & O_NONBLOCK))
68 dprintk(DEBUG_ERROR, "blocking read ...\n");
69
70 ret = kernel_read(ts->rd, ts->rd->f_pos, v, len);
71 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
72 trans->status = Disconnected;
73 return ret;
64} 74}
65 75
66/** 76/**
67 * v9fs_fd_send - send to a socket 77 * v9fs_fd_write - write to a socket
68 * @v9ses: session information 78 * @v9ses: session information
69 * @v: buffer to send data from 79 * @v: buffer to send data from
70 * @len: size of send buffer 80 * @len: size of send buffer
71 * 81 *
72 */ 82 */
73 83static int v9fs_fd_write(struct v9fs_transport *trans, void *v, int len)
74static int v9fs_fd_send(struct v9fs_transport *trans, void *v, int len)
75{ 84{
76 struct v9fs_trans_fd *ts = trans ? trans->priv : NULL; 85 int ret;
77 mm_segment_t oldfs = get_fs(); 86 mm_segment_t oldfs;
78 int ret = 0; 87 struct v9fs_trans_fd *ts;
79 88
80 if (!trans || trans->status != Connected || !ts) 89 if (!trans || trans->status == Disconnected || !(ts = trans->priv))
81 return -EIO; 90 return -EREMOTEIO;
91
92 if (!(ts->wr->f_flags & O_NONBLOCK))
93 dprintk(DEBUG_ERROR, "blocking write ...\n");
82 94
83 oldfs = get_fs(); 95 oldfs = get_fs();
84 set_fs(get_ds()); 96 set_fs(get_ds());
85 /* The cast to a user pointer is valid due to the set_fs() */ 97 /* The cast to a user pointer is valid due to the set_fs() */
86 ret = vfs_write(ts->out_file, (void __user *)v, len, &ts->out_file->f_pos); 98 ret = vfs_write(ts->wr, (void __user *)v, len, &ts->wr->f_pos);
87 set_fs(oldfs); 99 set_fs(oldfs);
88 100
101 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
102 trans->status = Disconnected;
89 return ret; 103 return ret;
90} 104}
91 105
92/** 106static unsigned int
93 * v9fs_fd_init - initialize file descriptor transport 107v9fs_fd_poll(struct v9fs_transport *trans, struct poll_table_struct *pt)
94 * @v9ses: session information
95 * @addr: address of server to mount
96 * @data: mount options
97 *
98 */
99
100static int
101v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
102{ 108{
103 struct v9fs_trans_fd *ts = NULL; 109 int ret, n;
104 struct v9fs_transport *trans = v9ses->transport; 110 struct v9fs_trans_fd *ts;
111 mm_segment_t oldfs;
105 112
106 if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) { 113 if (!trans || trans->status != Connected || !(ts = trans->priv))
107 printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n"); 114 return -EREMOTEIO;
108 return -ENOPROTOOPT;
109 }
110 115
111 ts = kmalloc(sizeof(struct v9fs_trans_fd), GFP_KERNEL); 116 if (!ts->rd->f_op || !ts->rd->f_op->poll)
117 return -EIO;
112 118
113 if (!ts) 119 if (!ts->wr->f_op || !ts->wr->f_op->poll)
114 return -ENOMEM; 120 return -EIO;
115 121
116 ts->in_file = fget( v9ses->rfdno ); 122 oldfs = get_fs();
117 ts->out_file = fget( v9ses->wfdno ); 123 set_fs(get_ds());
118 124
119 if (!ts->in_file || !ts->out_file) { 125 ret = ts->rd->f_op->poll(ts->rd, pt);
120 if (ts->in_file) 126 if (ret < 0)
121 fput(ts->in_file); 127 goto end;
122 128
123 if (ts->out_file) 129 if (ts->rd != ts->wr) {
124 fput(ts->out_file); 130 n = ts->wr->f_op->poll(ts->wr, pt);
131 if (n < 0) {
132 ret = n;
133 goto end;
134 }
135 ret = (ret & ~POLLOUT) | (n & ~POLLIN);
136 }
125 137
138 end:
139 set_fs(oldfs);
140 return ret;
141}
142
143static int v9fs_fd_open(struct v9fs_session_info *v9ses, int rfd, int wfd)
144{
145 struct v9fs_transport *trans = v9ses->transport;
146 struct v9fs_trans_fd *ts = kmalloc(sizeof(struct v9fs_trans_fd),
147 GFP_KERNEL);
148 if (!ts)
149 return -ENOMEM;
150
151 ts->rd = fget(rfd);
152 ts->wr = fget(wfd);
153 if (!ts->rd || !ts->wr) {
154 if (ts->rd)
155 fput(ts->rd);
156 if (ts->wr)
157 fput(ts->wr);
126 kfree(ts); 158 kfree(ts);
127 return -EIO; 159 return -EIO;
128 } 160 }
@@ -133,84 +165,145 @@ v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
133 return 0; 165 return 0;
134} 166}
135 167
136 168static int v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr,
137/** 169 char *data)
138 * v9fs_fd_close - shutdown file descriptor
139 * @trans: private socket structure
140 *
141 */
142
143static void v9fs_fd_close(struct v9fs_transport *trans)
144{ 170{
145 struct v9fs_trans_fd *ts; 171 if (v9ses->rfdno == ~0 || v9ses->wfdno == ~0) {
146 172 printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n");
147 if (!trans) 173 return -ENOPROTOOPT;
148 return; 174 }
149
150 ts = xchg(&trans->priv, NULL);
151 175
152 if (!ts) 176 return v9fs_fd_open(v9ses, v9ses->rfdno, v9ses->wfdno);
153 return; 177}
154 178
155 trans->status = Disconnected; 179static int v9fs_socket_open(struct v9fs_session_info *v9ses,
156 if (ts->in_file) 180 struct socket *csocket)
157 fput(ts->in_file); 181{
182 int fd, ret;
183
184 csocket->sk->sk_allocation = GFP_NOIO;
185 if ((fd = sock_map_fd(csocket)) < 0) {
186 eprintk(KERN_ERR, "v9fs_socket_open: failed to map fd\n");
187 ret = fd;
188 release_csocket:
189 sock_release(csocket);
190 return ret;
191 }
158 192
159 if (ts->out_file) 193 if ((ret = v9fs_fd_open(v9ses, fd, fd)) < 0) {
160 fput(ts->out_file); 194 sockfd_put(csocket);
195 eprintk(KERN_ERR, "v9fs_socket_open: failed to open fd\n");
196 goto release_csocket;
197 }
161 198
162 kfree(ts); 199 ((struct v9fs_trans_fd *)v9ses->transport->priv)->rd->f_flags |=
200 O_NONBLOCK;
201 return 0;
163} 202}
164 203
165static unsigned int 204static int v9fs_tcp_init(struct v9fs_session_info *v9ses, const char *addr,
166v9fs_fd_poll(struct v9fs_transport *trans, struct poll_table_struct *pt) 205 char *data)
167{ 206{
168 int ret, n; 207 int ret;
169 struct v9fs_trans_fd *ts; 208 struct socket *csocket = NULL;
170 mm_segment_t oldfs; 209 struct sockaddr_in sin_server;
210
211 sin_server.sin_family = AF_INET;
212 sin_server.sin_addr.s_addr = in_aton(addr);
213 sin_server.sin_port = htons(v9ses->port);
214 sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket);
215
216 if (!csocket) {
217 eprintk(KERN_ERR, "v9fs_trans_tcp: problem creating socket\n");
218 return -1;
219 }
171 220
172 if (!trans) 221 ret = csocket->ops->connect(csocket,
173 return -EIO; 222 (struct sockaddr *)&sin_server,
223 sizeof(struct sockaddr_in), 0);
224 if (ret < 0) {
225 eprintk(KERN_ERR,
226 "v9fs_trans_tcp: problem connecting socket to %s\n",
227 addr);
228 return ret;
229 }
174 230
175 ts = trans->priv; 231 return v9fs_socket_open(v9ses, csocket);
176 if (trans->status != Connected || !ts) 232}
177 return -EIO;
178 233
179 oldfs = get_fs(); 234static int
180 set_fs(get_ds()); 235v9fs_unix_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
236{
237 int ret;
238 struct socket *csocket;
239 struct sockaddr_un sun_server;
240
241 if (strlen(addr) > UNIX_PATH_MAX) {
242 eprintk(KERN_ERR, "v9fs_trans_unix: address too long: %s\n",
243 addr);
244 return -ENAMETOOLONG;
245 }
181 246
182 if (!ts->in_file->f_op || !ts->in_file->f_op->poll) { 247 sun_server.sun_family = PF_UNIX;
183 ret = -EIO; 248 strcpy(sun_server.sun_path, addr);
184 goto end; 249 sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket);
250 ret = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server,
251 sizeof(struct sockaddr_un) - 1, 0);
252 if (ret < 0) {
253 eprintk(KERN_ERR,
254 "v9fs_trans_unix: problem connecting socket: %s: %d\n",
255 addr, ret);
256 return ret;
185 } 257 }
186 258
187 ret = ts->in_file->f_op->poll(ts->in_file, pt); 259 return v9fs_socket_open(v9ses, csocket);
260}
188 261
189 if (ts->out_file != ts->in_file) { 262/**
190 if (!ts->out_file->f_op || !ts->out_file->f_op->poll) { 263 * v9fs_sock_close - shutdown socket
191 ret = -EIO; 264 * @trans: private socket structure
192 goto end; 265 *
193 } 266 */
267static void v9fs_fd_close(struct v9fs_transport *trans)
268{
269 struct v9fs_trans_fd *ts;
194 270
195 n = ts->out_file->f_op->poll(ts->out_file, pt); 271 if (!trans)
272 return;
196 273
197 ret &= ~POLLOUT; 274 ts = xchg(&trans->priv, NULL);
198 n &= ~POLLIN;
199 275
200 ret |= n; 276 if (!ts)
201 } 277 return;
202 278
203end: 279 trans->status = Disconnected;
204 set_fs(oldfs); 280 if (ts->rd)
205 return ret; 281 fput(ts->rd);
282 if (ts->wr)
283 fput(ts->wr);
284 kfree(ts);
206} 285}
207 286
208
209struct v9fs_transport v9fs_trans_fd = { 287struct v9fs_transport v9fs_trans_fd = {
210 .init = v9fs_fd_init, 288 .init = v9fs_fd_init,
211 .write = v9fs_fd_send, 289 .write = v9fs_fd_write,
212 .read = v9fs_fd_recv, 290 .read = v9fs_fd_read,
213 .close = v9fs_fd_close, 291 .close = v9fs_fd_close,
214 .poll = v9fs_fd_poll, 292 .poll = v9fs_fd_poll,
215}; 293};
216 294
295struct v9fs_transport v9fs_trans_tcp = {
296 .init = v9fs_tcp_init,
297 .write = v9fs_fd_write,
298 .read = v9fs_fd_read,
299 .close = v9fs_fd_close,
300 .poll = v9fs_fd_poll,
301};
302
303struct v9fs_transport v9fs_trans_unix = {
304 .init = v9fs_unix_init,
305 .write = v9fs_fd_write,
306 .read = v9fs_fd_read,
307 .close = v9fs_fd_close,
308 .poll = v9fs_fd_poll,
309};
diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c
deleted file mode 100644
index 44e830697acb..000000000000
--- a/fs/9p/trans_sock.c
+++ /dev/null
@@ -1,334 +0,0 @@
1/*
2 * linux/fs/9p/trans_socket.c
3 *
4 * Socket Transport Layer
5 *
6 * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
8 * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com>
9 * Copyright (C) 1995, 1996 by Olaf Kirch <okir@monad.swb.de>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to:
23 * Free Software Foundation
24 * 51 Franklin Street, Fifth Floor
25 * Boston, MA 02111-1301 USA
26 *
27 */
28
29#include <linux/config.h>
30#include <linux/in.h>
31#include <linux/module.h>
32#include <linux/net.h>
33#include <linux/ipv6.h>
34#include <linux/errno.h>
35#include <linux/kernel.h>
36#include <linux/un.h>
37#include <asm/uaccess.h>
38#include <linux/inet.h>
39#include <linux/idr.h>
40#include <linux/file.h>
41
42#include "debug.h"
43#include "v9fs.h"
44#include "transport.h"
45
46#define V9FS_PORT 564
47
48struct v9fs_trans_sock {
49 struct socket *s;
50 struct file *filp;
51};
52
53/**
54 * v9fs_sock_recv - receive from a socket
55 * @v9ses: session information
56 * @v: buffer to receive data into
57 * @len: size of receive buffer
58 *
59 */
60
61static int v9fs_sock_recv(struct v9fs_transport *trans, void *v, int len)
62{
63 int ret;
64 struct v9fs_trans_sock *ts;
65
66 if (!trans || trans->status == Disconnected) {
67 dprintk(DEBUG_ERROR, "disconnected ...\n");
68 return -EREMOTEIO;
69 }
70
71 ts = trans->priv;
72
73 if (!(ts->filp->f_flags & O_NONBLOCK))
74 dprintk(DEBUG_ERROR, "blocking read ...\n");
75
76 ret = kernel_read(ts->filp, ts->filp->f_pos, v, len);
77 if (ret <= 0) {
78 if (ret != -ERESTARTSYS && ret != -EAGAIN)
79 trans->status = Disconnected;
80 }
81
82 return ret;
83}
84
85/**
86 * v9fs_sock_send - send to a socket
87 * @v9ses: session information
88 * @v: buffer to send data from
89 * @len: size of send buffer
90 *
91 */
92
93static int v9fs_sock_send(struct v9fs_transport *trans, void *v, int len)
94{
95 int ret;
96 mm_segment_t oldfs;
97 struct v9fs_trans_sock *ts;
98
99 if (!trans || trans->status == Disconnected) {
100 dprintk(DEBUG_ERROR, "disconnected ...\n");
101 return -EREMOTEIO;
102 }
103
104 ts = trans->priv;
105 if (!ts) {
106 dprintk(DEBUG_ERROR, "no transport ...\n");
107 return -EREMOTEIO;
108 }
109
110 if (!(ts->filp->f_flags & O_NONBLOCK))
111 dprintk(DEBUG_ERROR, "blocking write ...\n");
112
113 oldfs = get_fs();
114 set_fs(get_ds());
115 ret = vfs_write(ts->filp, (void __user *)v, len, &ts->filp->f_pos);
116 set_fs(oldfs);
117
118 if (ret < 0) {
119 if (ret != -ERESTARTSYS)
120 trans->status = Disconnected;
121 }
122
123 return ret;
124}
125
126static unsigned int v9fs_sock_poll(struct v9fs_transport *trans,
127 struct poll_table_struct *pt) {
128
129 int ret;
130 struct v9fs_trans_sock *ts;
131 mm_segment_t oldfs;
132
133 if (!trans) {
134 dprintk(DEBUG_ERROR, "no transport\n");
135 return -EIO;
136 }
137
138 ts = trans->priv;
139 if (trans->status != Connected || !ts) {
140 dprintk(DEBUG_ERROR, "transport disconnected: %d\n", trans->status);
141 return -EIO;
142 }
143
144 oldfs = get_fs();
145 set_fs(get_ds());
146
147 if (!ts->filp->f_op || !ts->filp->f_op->poll) {
148 dprintk(DEBUG_ERROR, "no poll operation\n");
149 ret = -EIO;
150 goto end;
151 }
152
153 ret = ts->filp->f_op->poll(ts->filp, pt);
154
155end:
156 set_fs(oldfs);
157 return ret;
158}
159
160
161/**
162 * v9fs_tcp_init - initialize TCP socket
163 * @v9ses: session information
164 * @addr: address of server to mount
165 * @data: mount options
166 *
167 */
168
169static int
170v9fs_tcp_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
171{
172 struct socket *csocket = NULL;
173 struct sockaddr_in sin_server;
174 int rc = 0;
175 struct v9fs_trans_sock *ts = NULL;
176 struct v9fs_transport *trans = v9ses->transport;
177 int fd;
178
179 trans->status = Disconnected;
180
181 ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL);
182
183 if (!ts)
184 return -ENOMEM;
185
186 trans->priv = ts;
187 ts->s = NULL;
188 ts->filp = NULL;
189
190 if (!addr)
191 return -EINVAL;
192
193 dprintk(DEBUG_TRANS, "Connecting to %s\n", addr);
194
195 sin_server.sin_family = AF_INET;
196 sin_server.sin_addr.s_addr = in_aton(addr);
197 sin_server.sin_port = htons(v9ses->port);
198 sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket);
199 rc = csocket->ops->connect(csocket,
200 (struct sockaddr *)&sin_server,
201 sizeof(struct sockaddr_in), 0);
202 if (rc < 0) {
203 eprintk(KERN_ERR,
204 "v9fs_trans_tcp: problem connecting socket to %s\n",
205 addr);
206 return rc;
207 }
208 csocket->sk->sk_allocation = GFP_NOIO;
209
210 fd = sock_map_fd(csocket);
211 if (fd < 0) {
212 sock_release(csocket);
213 kfree(ts);
214 trans->priv = NULL;
215 return fd;
216 }
217
218 ts->s = csocket;
219 ts->filp = fget(fd);
220 ts->filp->f_flags |= O_NONBLOCK;
221 trans->status = Connected;
222
223 return 0;
224}
225
226/**
227 * v9fs_unix_init - initialize UNIX domain socket
228 * @v9ses: session information
229 * @dev_name: path to named pipe
230 * @data: mount options
231 *
232 */
233
234static int
235v9fs_unix_init(struct v9fs_session_info *v9ses, const char *dev_name,
236 char *data)
237{
238 int rc, fd;
239 struct socket *csocket;
240 struct sockaddr_un sun_server;
241 struct v9fs_transport *trans;
242 struct v9fs_trans_sock *ts;
243
244 rc = 0;
245 csocket = NULL;
246 trans = v9ses->transport;
247
248 trans->status = Disconnected;
249
250 if (strlen(dev_name) > UNIX_PATH_MAX) {
251 eprintk(KERN_ERR, "v9fs_trans_unix: address too long: %s\n",
252 dev_name);
253 return -ENOMEM;
254 }
255
256 ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL);
257 if (!ts)
258 return -ENOMEM;
259
260 trans->priv = ts;
261 ts->s = NULL;
262 ts->filp = NULL;
263
264 sun_server.sun_family = PF_UNIX;
265 strcpy(sun_server.sun_path, dev_name);
266 sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket);
267 rc = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server,
268 sizeof(struct sockaddr_un) - 1, 0); /* -1 *is* important */
269 if (rc < 0) {
270 eprintk(KERN_ERR,
271 "v9fs_trans_unix: problem connecting socket: %s: %d\n",
272 dev_name, rc);
273 return rc;
274 }
275 csocket->sk->sk_allocation = GFP_NOIO;
276
277 fd = sock_map_fd(csocket);
278 if (fd < 0) {
279 sock_release(csocket);
280 kfree(ts);
281 trans->priv = NULL;
282 return fd;
283 }
284
285 ts->s = csocket;
286 ts->filp = fget(fd);
287 ts->filp->f_flags |= O_NONBLOCK;
288 trans->status = Connected;
289
290 return 0;
291}
292
293/**
294 * v9fs_sock_close - shutdown socket
295 * @trans: private socket structure
296 *
297 */
298
299static void v9fs_sock_close(struct v9fs_transport *trans)
300{
301 struct v9fs_trans_sock *ts;
302
303 if (!trans)
304 return;
305
306 ts = trans->priv;
307
308 if ((ts) && (ts->filp)) {
309 fput(ts->filp);
310 ts->filp = NULL;
311 ts->s = NULL;
312 trans->status = Disconnected;
313 }
314
315 kfree(ts);
316
317 trans->priv = NULL;
318}
319
320struct v9fs_transport v9fs_trans_tcp = {
321 .init = v9fs_tcp_init,
322 .write = v9fs_sock_send,
323 .read = v9fs_sock_recv,
324 .close = v9fs_sock_close,
325 .poll = v9fs_sock_poll,
326};
327
328struct v9fs_transport v9fs_trans_unix = {
329 .init = v9fs_unix_init,
330 .write = v9fs_sock_send,
331 .read = v9fs_sock_recv,
332 .close = v9fs_sock_close,
333 .poll = v9fs_sock_poll,
334};
diff --git a/fs/9p/transport.h b/fs/9p/transport.h
index 91fcdb94b361..b38a4b8a41ce 100644
--- a/fs/9p/transport.h
+++ b/fs/9p/transport.h
@@ -7,9 +7,8 @@
7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 61352491ba36..d37416eb5791 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,7 +50,7 @@ enum {
51 Opt_port, Opt_msize, Opt_uid, Opt_gid, Opt_afid, Opt_debug, 50 Opt_port, Opt_msize, Opt_uid, Opt_gid, Opt_afid, Opt_debug,
52 Opt_rfdno, Opt_wfdno, 51 Opt_rfdno, Opt_wfdno,
53 /* String options */ 52 /* String options */
54 Opt_name, Opt_remotename, 53 Opt_uname, Opt_remotename,
55 /* Options that take no arguments */ 54 /* Options that take no arguments */
56 Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp, Opt_fd, 55 Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp, Opt_fd,
57 /* Error token */ 56 /* Error token */
@@ -67,7 +66,7 @@ static match_table_t tokens = {
67 {Opt_rfdno, "rfdno=%u"}, 66 {Opt_rfdno, "rfdno=%u"},
68 {Opt_wfdno, "wfdno=%u"}, 67 {Opt_wfdno, "wfdno=%u"},
69 {Opt_debug, "debug=%x"}, 68 {Opt_debug, "debug=%x"},
70 {Opt_name, "name=%s"}, 69 {Opt_uname, "uname=%s"},
71 {Opt_remotename, "aname=%s"}, 70 {Opt_remotename, "aname=%s"},
72 {Opt_unix, "proto=unix"}, 71 {Opt_unix, "proto=unix"},
73 {Opt_tcp, "proto=tcp"}, 72 {Opt_tcp, "proto=tcp"},
@@ -116,7 +115,7 @@ static void v9fs_parse_options(char *options, struct v9fs_session_info *v9ses)
116 if (!*p) 115 if (!*p)
117 continue; 116 continue;
118 token = match_token(p, tokens, args); 117 token = match_token(p, tokens, args);
119 if (token < Opt_name) { 118 if (token < Opt_uname) {
120 if ((ret = match_int(&args[0], &option)) < 0) { 119 if ((ret = match_int(&args[0], &option)) < 0) {
121 dprintk(DEBUG_ERROR, 120 dprintk(DEBUG_ERROR,
122 "integer field, but no integer?\n"); 121 "integer field, but no integer?\n");
@@ -158,7 +157,7 @@ static void v9fs_parse_options(char *options, struct v9fs_session_info *v9ses)
158 case Opt_fd: 157 case Opt_fd:
159 v9ses->proto = PROTO_FD; 158 v9ses->proto = PROTO_FD;
160 break; 159 break;
161 case Opt_name: 160 case Opt_uname:
162 match_strcpy(v9ses->name, &args[0]); 161 match_strcpy(v9ses->name, &args[0]);
163 break; 162 break;
164 case Opt_remotename: 163 case Opt_remotename:
@@ -289,7 +288,7 @@ v9fs_session_init(struct v9fs_session_info *v9ses,
289 /* set global debug level */ 288 /* set global debug level */
290 v9fs_debug_level = v9ses->debug; 289 v9fs_debug_level = v9ses->debug;
291 290
292 /* id pools that are session-dependent: FIDs and TIDs */ 291 /* id pools that are session-dependent: fids and tags */
293 idr_init(&v9ses->fidpool.pool); 292 idr_init(&v9ses->fidpool.pool);
294 init_MUTEX(&v9ses->fidpool.lock); 293 init_MUTEX(&v9ses->fidpool.lock);
295 294
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index f337da7a0eec..c134d104cb28 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -5,9 +5,8 @@
5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License version 2
9 * the Free Software Foundation; either version 2 of the License, or 9 * as published by the Free Software Foundation.
10 * (at your option) any later version.
11 * 10 *
12 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -91,6 +90,3 @@ void v9fs_session_cancel(struct v9fs_session_info *v9ses);
91#define V9FS_DEFUSER "nobody" 90#define V9FS_DEFUSER "nobody"
92#define V9FS_DEFANAME "" 91#define V9FS_DEFANAME ""
93 92
94/* inital pool sizes for fids and tags */
95#define V9FS_START_FIDS 8192
96#define V9FS_START_TIDS 256
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index a759278acaae..43c9f7de0314 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -5,9 +5,8 @@
5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License version 2
9 * the Free Software Foundation; either version 2 of the License, or 9 * as published by the Free Software Foundation.
10 * (at your option) any later version.
11 * 10 *
12 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * 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 8100fb5171b7..efda46fb64d9 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * 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 12c9cc926b71..062daa6000ab 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,7 +50,7 @@
51 * 50 *
52 */ 51 */
53 52
54int v9fs_dentry_delete(struct dentry *dentry) 53static int v9fs_dentry_delete(struct dentry *dentry)
55{ 54{
56 dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); 55 dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry);
57 return 1; 56 return 1;
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index cd5eeb032d64..766f11f1215c 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * 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 de3a129698da..59e744163407 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -69,29 +68,30 @@ int v9fs_file_open(struct inode *inode, struct file *file)
69 68
70 fid = v9fs_get_idpool(&v9ses->fidpool); 69 fid = v9fs_get_idpool(&v9ses->fidpool);
71 if (fid < 0) { 70 if (fid < 0) {
72 eprintk(KERN_WARNING, "newfid fails!\n"); 71 eprintk(KERN_WARNING, "newfid fails!\n");
73 return -ENOSPC; 72 return -ENOSPC;
74 } 73 }
75 74
76 err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, NULL); 75 err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, NULL);
77 if (err < 0) { 76 if (err < 0) {
78 dprintk(DEBUG_ERROR, "rewalk didn't work\n"); 77 dprintk(DEBUG_ERROR, "rewalk didn't work\n");
79 goto put_fid; 78 goto put_fid;
80 } 79 }
81 80
82 vfid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); 81 /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
83 if (vfid == NULL) { 82 /* translate open mode appropriately */
84 dprintk(DEBUG_ERROR, "out of memory\n");
85 goto clunk_fid;
86 }
87
88 /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
89 /* translate open mode appropriately */
90 omode = v9fs_uflags2omode(file->f_flags); 83 omode = v9fs_uflags2omode(file->f_flags);
91 err = v9fs_t_open(v9ses, fid, omode, &fcall); 84 err = v9fs_t_open(v9ses, fid, omode, &fcall);
92 if (err < 0) { 85 if (err < 0) {
93 PRINT_FCALL_ERROR("open failed", fcall); 86 PRINT_FCALL_ERROR("open failed", fcall);
94 goto destroy_vfid; 87 goto clunk_fid;
88 }
89
90 vfid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL);
91 if (vfid == NULL) {
92 dprintk(DEBUG_ERROR, "out of memory\n");
93 err = -ENOMEM;
94 goto clunk_fid;
95 } 95 }
96 96
97 file->private_data = vfid; 97 file->private_data = vfid;
@@ -106,15 +106,12 @@ int v9fs_file_open(struct inode *inode, struct file *file)
106 106
107 return 0; 107 return 0;
108 108
109destroy_vfid:
110 v9fs_fid_destroy(vfid);
111
112clunk_fid: 109clunk_fid:
113 v9fs_t_clunk(v9ses, fid); 110 v9fs_t_clunk(v9ses, fid);
114 111
115put_fid: 112put_fid:
116 v9fs_put_idpool(fid, &v9ses->fidpool); 113 v9fs_put_idpool(fid, &v9ses->fidpool);
117 kfree(fcall); 114 kfree(fcall);
118 115
119 return err; 116 return err;
120} 117}
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 651a9e14d9a9..133db366d306 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -7,9 +7,8 @@
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License version 2
11 * the Free Software Foundation; either version 2 of the License, or 11 * as published by the Free Software Foundation.
12 * (at your option) any later version.
13 * 12 *
14 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * 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)
255} 254}
256 255
257static int 256static int
258v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, 257v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
259 u32 perm, u8 mode, u32 *fidp, struct v9fs_qid *qid, u32 *iounit) 258 u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
260{ 259{
261 u32 fid; 260 u32 fid;
262 int err; 261 int err;
@@ -271,14 +270,14 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
271 err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall); 270 err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall);
272 if (err < 0) { 271 if (err < 0) {
273 PRINT_FCALL_ERROR("clone error", fcall); 272 PRINT_FCALL_ERROR("clone error", fcall);
274 goto error; 273 goto put_fid;
275 } 274 }
276 kfree(fcall); 275 kfree(fcall);
277 276
278 err = v9fs_t_create(v9ses, fid, name, perm, mode, &fcall); 277 err = v9fs_t_create(v9ses, fid, name, perm, mode, extension, &fcall);
279 if (err < 0) { 278 if (err < 0) {
280 PRINT_FCALL_ERROR("create fails", fcall); 279 PRINT_FCALL_ERROR("create fails", fcall);
281 goto error; 280 goto clunk_fid;
282 } 281 }
283 282
284 if (iounit) 283 if (iounit)
@@ -293,7 +292,11 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
293 kfree(fcall); 292 kfree(fcall);
294 return 0; 293 return 0;
295 294
296error: 295clunk_fid:
296 v9fs_t_clunk(v9ses, fid);
297 fid = V9FS_NOFID;
298
299put_fid:
297 if (fid >= 0) 300 if (fid >= 0)
298 v9fs_put_idpool(fid, &v9ses->fidpool); 301 v9fs_put_idpool(fid, &v9ses->fidpool);
299 302
@@ -348,7 +351,7 @@ error:
348 return ERR_PTR(err); 351 return ERR_PTR(err);
349} 352}
350 353
351struct inode * 354static struct inode *
352v9fs_inode_from_fid(struct v9fs_session_info *v9ses, u32 fid, 355v9fs_inode_from_fid(struct v9fs_session_info *v9ses, u32 fid,
353 struct super_block *sb) 356 struct super_block *sb)
354{ 357{
@@ -474,7 +477,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
474 flags = O_RDWR; 477 flags = O_RDWR;
475 478
476 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, 479 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
477 perm, v9fs_uflags2omode(flags), &fid, &qid, &iounit); 480 perm, v9fs_uflags2omode(flags), NULL, &fid, &qid, &iounit);
478 481
479 if (err) 482 if (err)
480 goto error; 483 goto error;
@@ -550,7 +553,7 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
550 perm = unixmode2p9mode(v9ses, mode | S_IFDIR); 553 perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
551 554
552 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, 555 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
553 perm, V9FS_OREAD, &fid, NULL, NULL); 556 perm, V9FS_OREAD, NULL, &fid, NULL, NULL);
554 557
555 if (err) { 558 if (err) {
556 dprintk(DEBUG_ERROR, "create error %d\n", err); 559 dprintk(DEBUG_ERROR, "create error %d\n", err);
@@ -1008,11 +1011,13 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
1008 1011
1009 /* copy extension buffer into buffer */ 1012 /* copy extension buffer into buffer */
1010 if (fcall->params.rstat.stat.extension.len < buflen) 1013 if (fcall->params.rstat.stat.extension.len < buflen)
1011 buflen = fcall->params.rstat.stat.extension.len; 1014 buflen = fcall->params.rstat.stat.extension.len + 1;
1012 1015
1013 memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1); 1016 memmove(buffer, fcall->params.rstat.stat.extension.str, buflen - 1);
1014 buffer[buflen-1] = 0; 1017 buffer[buflen-1] = 0;
1015 1018
1019 dprintk(DEBUG_ERROR, "%s -> %.*s (%s)\n", dentry->d_name.name, fcall->params.rstat.stat.extension.len,
1020 fcall->params.rstat.stat.extension.str, buffer);
1016 retval = buflen; 1021 retval = buflen;
1017 1022
1018 FreeFcall: 1023 FreeFcall:
@@ -1072,7 +1077,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
1072 if (!link) 1077 if (!link)
1073 link = ERR_PTR(-ENOMEM); 1078 link = ERR_PTR(-ENOMEM);
1074 else { 1079 else {
1075 len = v9fs_readlink(dentry, link, strlen(link)); 1080 len = v9fs_readlink(dentry, link, PATH_MAX);
1076 1081
1077 if (len < 0) { 1082 if (len < 0) {
1078 __putname(link); 1083 __putname(link);
@@ -1109,10 +1114,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1109 struct v9fs_session_info *v9ses; 1114 struct v9fs_session_info *v9ses;
1110 struct v9fs_fid *dfid, *vfid; 1115 struct v9fs_fid *dfid, *vfid;
1111 struct inode *inode; 1116 struct inode *inode;
1112 struct v9fs_fcall *fcall;
1113 struct v9fs_wstat wstat;
1114 1117
1115 fcall = NULL;
1116 inode = NULL; 1118 inode = NULL;
1117 vfid = NULL; 1119 vfid = NULL;
1118 v9ses = v9fs_inode2v9ses(dir); 1120 v9ses = v9fs_inode2v9ses(dir);
@@ -1125,7 +1127,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1125 } 1127 }
1126 1128
1127 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, 1129 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
1128 perm, V9FS_OREAD, &fid, NULL, NULL); 1130 perm, V9FS_OREAD, (char *) extension, &fid, NULL, NULL);
1129 1131
1130 if (err) 1132 if (err)
1131 goto error; 1133 goto error;
@@ -1148,23 +1150,11 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1148 goto error; 1150 goto error;
1149 } 1151 }
1150 1152
1151 /* issue a Twstat */
1152 v9fs_blank_wstat(&wstat);
1153 wstat.muid = v9ses->name;
1154 wstat.extension = (char *) extension;
1155 err = v9fs_t_wstat(v9ses, vfid->fid, &wstat, &fcall);
1156 if (err < 0) {
1157 PRINT_FCALL_ERROR("wstat error", fcall);
1158 goto error;
1159 }
1160
1161 kfree(fcall);
1162 dentry->d_op = &v9fs_dentry_operations; 1153 dentry->d_op = &v9fs_dentry_operations;
1163 d_instantiate(dentry, inode); 1154 d_instantiate(dentry, inode);
1164 return 0; 1155 return 0;
1165 1156
1166error: 1157error:
1167 kfree(fcall);
1168 if (vfid) 1158 if (vfid)
1169 v9fs_fid_destroy(vfid); 1159 v9fs_fid_destroy(vfid);
1170 1160
@@ -1224,7 +1214,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1224 } 1214 }
1225 1215
1226 name = __getname(); 1216 name = __getname();
1227 sprintf(name, "hardlink(%d)\n", oldfid->fid); 1217 sprintf(name, "%d\n", oldfid->fid);
1228 retval = v9fs_vfs_mkspecial(dir, dentry, V9FS_DMLINK, name); 1218 retval = v9fs_vfs_mkspecial(dir, dentry, V9FS_DMLINK, name);
1229 __putname(name); 1219 __putname(name);
1230 1220
@@ -1253,6 +1243,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1253 return -EINVAL; 1243 return -EINVAL;
1254 1244
1255 name = __getname(); 1245 name = __getname();
1246 if (!name)
1247 return -ENOMEM;
1256 /* build extension */ 1248 /* build extension */
1257 if (S_ISBLK(mode)) 1249 if (S_ISBLK(mode))
1258 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev)); 1250 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index d05318fa684e..b0a0ae509c00 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -8,9 +8,8 @@
8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License version 2
12 * the Free Software Foundation; either version 2 of the License, or 12 * as published by the Free Software Foundation.
13 * (at your option) any later version.
14 * 13 *
15 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -262,7 +261,7 @@ static struct super_operations v9fs_super_ops = {
262}; 261};
263 262
264struct file_system_type v9fs_fs_type = { 263struct file_system_type v9fs_fs_type = {
265 .name = "9P", 264 .name = "9p",
266 .get_sb = v9fs_get_sb, 265 .get_sb = v9fs_get_sb,
267 .kill_sb = v9fs_kill_super, 266 .kill_sb = v9fs_kill_super,
268 .owner = THIS_MODULE, 267 .owner = THIS_MODULE,
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 243963228d10..252abda0d200 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -241,7 +241,8 @@ static int init_inodecache(void)
241{ 241{
242 adfs_inode_cachep = kmem_cache_create("adfs_inode_cache", 242 adfs_inode_cachep = kmem_cache_create("adfs_inode_cache",
243 sizeof(struct adfs_inode_info), 243 sizeof(struct adfs_inode_info),
244 0, SLAB_RECLAIM_ACCOUNT, 244 0, (SLAB_RECLAIM_ACCOUNT|
245 SLAB_MEM_SPREAD),
245 init_once, NULL); 246 init_once, NULL);
246 if (adfs_inode_cachep == NULL) 247 if (adfs_inode_cachep == NULL)
247 return -ENOMEM; 248 return -ENOMEM;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index aaec015a16e4..4d7e5b19e5cd 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -98,7 +98,8 @@ static int init_inodecache(void)
98{ 98{
99 affs_inode_cachep = kmem_cache_create("affs_inode_cache", 99 affs_inode_cachep = kmem_cache_create("affs_inode_cache",
100 sizeof(struct affs_inode_info), 100 sizeof(struct affs_inode_info),
101 0, SLAB_RECLAIM_ACCOUNT, 101 0, (SLAB_RECLAIM_ACCOUNT|
102 SLAB_MEM_SPREAD),
102 init_once, NULL); 103 init_once, NULL);
103 if (affs_inode_cachep == NULL) 104 if (affs_inode_cachep == NULL)
104 return -ENOMEM; 105 return -ENOMEM;
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 9eef6bf156ab..3d097fddcb7a 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -94,7 +94,7 @@ static struct rxrpc_service AFSCM_service = {
94 .error_func = afscm_error, 94 .error_func = afscm_error,
95 .aemap_func = afscm_aemap, 95 .aemap_func = afscm_aemap,
96 .ops_begin = &AFSCM_ops[0], 96 .ops_begin = &AFSCM_ops[0],
97 .ops_end = &AFSCM_ops[sizeof(AFSCM_ops) / sizeof(AFSCM_ops[0])], 97 .ops_end = &AFSCM_ops[ARRAY_SIZE(AFSCM_ops)],
98}; 98};
99 99
100static DECLARE_COMPLETION(kafscmd_alive); 100static DECLARE_COMPLETION(kafscmd_alive);
diff --git a/fs/afs/super.c b/fs/afs/super.c
index d6fa8e5999df..53c56e7231ab 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,
341 341
342 sb->s_flags = flags; 342 sb->s_flags = flags;
343 343
344 ret = afs_fill_super(sb, &params, flags & MS_VERBOSE ? 1 : 0); 344 ret = afs_fill_super(sb, &params, flags & MS_SILENT ? 1 : 0);
345 if (ret < 0) { 345 if (ret < 0) {
346 up_write(&sb->s_umount); 346 up_write(&sb->s_umount);
347 deactivate_super(sb); 347 deactivate_super(sb);
diff --git a/fs/aio.c b/fs/aio.c
index aec2b1916d1b..e41e932ba489 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -122,10 +122,9 @@ static int aio_setup_ring(struct kioctx *ctx)
122 info->nr = 0; 122 info->nr = 0;
123 info->ring_pages = info->internal_pages; 123 info->ring_pages = info->internal_pages;
124 if (nr_pages > AIO_RING_PAGES) { 124 if (nr_pages > AIO_RING_PAGES) {
125 info->ring_pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_KERNEL); 125 info->ring_pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
126 if (!info->ring_pages) 126 if (!info->ring_pages)
127 return -ENOMEM; 127 return -ENOMEM;
128 memset(info->ring_pages, 0, sizeof(struct page *) * nr_pages);
129 } 128 }
130 129
131 info->mmap_size = nr_pages * PAGE_SIZE; 130 info->mmap_size = nr_pages * PAGE_SIZE;
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 785f6b2d5d10..b7d6b920f65f 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,
118 * befs_read_lsmylink - read long symlink from datastream. 118 * befs_read_lsmylink - read long symlink from datastream.
119 * @sb: Filesystem superblock 119 * @sb: Filesystem superblock
120 * @ds: Datastrem to read from 120 * @ds: Datastrem to read from
121 * @buf: Buffer in wich to place long symlink data 121 * @buf: Buffer in which to place long symlink data
122 * @len: Length of the long symlink in bytes 122 * @len: Length of the long symlink in bytes
123 * 123 *
124 * Returns the number of bytes read 124 * Returns the number of bytes read
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index dd6048ce0532..044a59587829 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -427,7 +427,8 @@ befs_init_inodecache(void)
427{ 427{
428 befs_inode_cachep = kmem_cache_create("befs_inode_cache", 428 befs_inode_cachep = kmem_cache_create("befs_inode_cache",
429 sizeof (struct befs_inode_info), 429 sizeof (struct befs_inode_info),
430 0, SLAB_RECLAIM_ACCOUNT, 430 0, (SLAB_RECLAIM_ACCOUNT|
431 SLAB_MEM_SPREAD),
431 init_once, NULL); 432 init_once, NULL);
432 if (befs_inode_cachep == NULL) { 433 if (befs_inode_cachep == NULL) {
433 printk(KERN_ERR "befs_init_inodecache: " 434 printk(KERN_ERR "befs_init_inodecache: "
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 3af6c73c5b5a..55a7a78332f8 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -257,7 +257,8 @@ static int init_inodecache(void)
257{ 257{
258 bfs_inode_cachep = kmem_cache_create("bfs_inode_cache", 258 bfs_inode_cachep = kmem_cache_create("bfs_inode_cache",
259 sizeof(struct bfs_inode_info), 259 sizeof(struct bfs_inode_info),
260 0, SLAB_RECLAIM_ACCOUNT, 260 0, (SLAB_RECLAIM_ACCOUNT|
261 SLAB_MEM_SPREAD),
261 init_once, NULL); 262 init_once, NULL);
262 if (bfs_inode_cachep == NULL) 263 if (bfs_inode_cachep == NULL)
263 return -ENOMEM; 264 return -ENOMEM;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index c2eac2a50bd2..537893a16014 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -500,17 +500,22 @@ out:
500#define INTERPRETER_AOUT 1 500#define INTERPRETER_AOUT 1
501#define INTERPRETER_ELF 2 501#define INTERPRETER_ELF 2
502 502
503#ifndef STACK_RND_MASK
504#define STACK_RND_MASK 0x7ff /* with 4K pages 8MB of VA */
505#endif
503 506
504static unsigned long randomize_stack_top(unsigned long stack_top) 507static unsigned long randomize_stack_top(unsigned long stack_top)
505{ 508{
506 unsigned int random_variable = 0; 509 unsigned int random_variable = 0;
507 510
508 if (current->flags & PF_RANDOMIZE) 511 if (current->flags & PF_RANDOMIZE) {
509 random_variable = get_random_int() % (8*1024*1024); 512 random_variable = get_random_int() & STACK_RND_MASK;
513 random_variable <<= PAGE_SHIFT;
514 }
510#ifdef CONFIG_STACK_GROWSUP 515#ifdef CONFIG_STACK_GROWSUP
511 return PAGE_ALIGN(stack_top + random_variable); 516 return PAGE_ALIGN(stack_top) + random_variable;
512#else 517#else
513 return PAGE_ALIGN(stack_top - random_variable); 518 return PAGE_ALIGN(stack_top) - random_variable;
514#endif 519#endif
515} 520}
516 521
@@ -1334,7 +1339,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
1334 1339
1335 i = p->state ? ffz(~p->state) + 1 : 0; 1340 i = p->state ? ffz(~p->state) + 1 : 0;
1336 psinfo->pr_state = i; 1341 psinfo->pr_state = i;
1337 psinfo->pr_sname = (i < 0 || i > 5) ? '.' : "RSDTZW"[i]; 1342 psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i];
1338 psinfo->pr_zomb = psinfo->pr_sname == 'Z'; 1343 psinfo->pr_zomb = psinfo->pr_sname == 'Z';
1339 psinfo->pr_nice = task_nice(p); 1344 psinfo->pr_nice = task_nice(p);
1340 psinfo->pr_flag = p->flags; 1345 psinfo->pr_flag = p->flags;
@@ -1465,12 +1470,11 @@ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file)
1465 read_lock(&tasklist_lock); 1470 read_lock(&tasklist_lock);
1466 do_each_thread(g,p) 1471 do_each_thread(g,p)
1467 if (current->mm == p->mm && current != p) { 1472 if (current->mm == p->mm && current != p) {
1468 tmp = kmalloc(sizeof(*tmp), GFP_ATOMIC); 1473 tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);
1469 if (!tmp) { 1474 if (!tmp) {
1470 read_unlock(&tasklist_lock); 1475 read_unlock(&tasklist_lock);
1471 goto cleanup; 1476 goto cleanup;
1472 } 1477 }
1473 memset(tmp, 0, sizeof(*tmp));
1474 INIT_LIST_HEAD(&tmp->list); 1478 INIT_LIST_HEAD(&tmp->list);
1475 tmp->thread = p; 1479 tmp->thread = p;
1476 list_add(&tmp->list, &thread_list); 1480 list_add(&tmp->list, &thread_list);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 5b3076e8ee90..a2e48c999c24 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,
572 csp -= sizeof(unsigned long); 572 csp -= sizeof(unsigned long);
573 __put_user(bprm->argc, (unsigned long *) csp); 573 __put_user(bprm->argc, (unsigned long *) csp);
574 574
575 if (csp != sp) 575 BUG_ON(csp != sp);
576 BUG();
577 576
578 /* fill in the argv[] array */ 577 /* fill in the argv[] array */
579#ifdef CONFIG_MMU 578#ifdef CONFIG_MMU
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 108d56bbd0d0..69f44dcdb0b4 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -36,6 +36,7 @@
36#include <linux/personality.h> 36#include <linux/personality.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/flat.h> 38#include <linux/flat.h>
39#include <linux/syscalls.h>
39 40
40#include <asm/byteorder.h> 41#include <asm/byteorder.h>
41#include <asm/system.h> 42#include <asm/system.h>
@@ -426,6 +427,8 @@ static int load_flat_file(struct linux_binprm * bprm,
426 int i, rev, relocs = 0; 427 int i, rev, relocs = 0;
427 loff_t fpos; 428 loff_t fpos;
428 unsigned long start_code, end_code; 429 unsigned long start_code, end_code;
430 int ret;
431 int exec_fileno;
429 432
430 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */ 433 hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */
431 inode = bprm->file->f_dentry->d_inode; 434 inode = bprm->file->f_dentry->d_inode;
@@ -450,7 +453,8 @@ static int load_flat_file(struct linux_binprm * bprm,
450 */ 453 */
451 if (strncmp(hdr->magic, "#!", 2)) 454 if (strncmp(hdr->magic, "#!", 2))
452 printk("BINFMT_FLAT: bad header magic\n"); 455 printk("BINFMT_FLAT: bad header magic\n");
453 return -ENOEXEC; 456 ret = -ENOEXEC;
457 goto err;
454 } 458 }
455 459
456 if (flags & FLAT_FLAG_KTRACE) 460 if (flags & FLAT_FLAG_KTRACE)
@@ -458,14 +462,16 @@ static int load_flat_file(struct linux_binprm * bprm,
458 462
459 if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) { 463 if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) {
460 printk("BINFMT_FLAT: bad flat file version 0x%x (supported 0x%x and 0x%x)\n", rev, FLAT_VERSION, OLD_FLAT_VERSION); 464 printk("BINFMT_FLAT: bad flat file version 0x%x (supported 0x%x and 0x%x)\n", rev, FLAT_VERSION, OLD_FLAT_VERSION);
461 return -ENOEXEC; 465 ret = -ENOEXEC;
466 goto err;
462 } 467 }
463 468
464 /* Don't allow old format executables to use shared libraries */ 469 /* Don't allow old format executables to use shared libraries */
465 if (rev == OLD_FLAT_VERSION && id != 0) { 470 if (rev == OLD_FLAT_VERSION && id != 0) {
466 printk("BINFMT_FLAT: shared libraries are not available before rev 0x%x\n", 471 printk("BINFMT_FLAT: shared libraries are not available before rev 0x%x\n",
467 (int) FLAT_VERSION); 472 (int) FLAT_VERSION);
468 return -ENOEXEC; 473 ret = -ENOEXEC;
474 goto err;
469 } 475 }
470 476
471 /* 477 /*
@@ -478,7 +484,8 @@ static int load_flat_file(struct linux_binprm * bprm,
478#ifndef CONFIG_BINFMT_ZFLAT 484#ifndef CONFIG_BINFMT_ZFLAT
479 if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) { 485 if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
480 printk("Support for ZFLAT executables is not enabled.\n"); 486 printk("Support for ZFLAT executables is not enabled.\n");
481 return -ENOEXEC; 487 ret = -ENOEXEC;
488 goto err;
482 } 489 }
483#endif 490#endif
484 491
@@ -490,14 +497,27 @@ static int load_flat_file(struct linux_binprm * bprm,
490 rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur; 497 rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
491 if (rlim >= RLIM_INFINITY) 498 if (rlim >= RLIM_INFINITY)
492 rlim = ~0; 499 rlim = ~0;
493 if (data_len + bss_len > rlim) 500 if (data_len + bss_len > rlim) {
494 return -ENOMEM; 501 ret = -ENOMEM;
502 goto err;
503 }
504
505 /* check file descriptor */
506 exec_fileno = get_unused_fd();
507 if (exec_fileno < 0) {
508 ret = -EMFILE;
509 goto err;
510 }
511 get_file(bprm->file);
512 fd_install(exec_fileno, bprm->file);
495 513
496 /* Flush all traces of the currently running executable */ 514 /* Flush all traces of the currently running executable */
497 if (id == 0) { 515 if (id == 0) {
498 result = flush_old_exec(bprm); 516 result = flush_old_exec(bprm);
499 if (result) 517 if (result) {
500 return result; 518 ret = result;
519 goto err_close;
520 }
501 521
502 /* OK, This is the point of no return */ 522 /* OK, This is the point of no return */
503 set_personality(PER_LINUX); 523 set_personality(PER_LINUX);
@@ -527,7 +547,8 @@ static int load_flat_file(struct linux_binprm * bprm,
527 if (!textpos) 547 if (!textpos)
528 textpos = (unsigned long) -ENOMEM; 548 textpos = (unsigned long) -ENOMEM;
529 printk("Unable to mmap process text, errno %d\n", (int)-textpos); 549 printk("Unable to mmap process text, errno %d\n", (int)-textpos);
530 return(textpos); 550 ret = textpos;
551 goto err_close;
531 } 552 }
532 553
533 down_write(&current->mm->mmap_sem); 554 down_write(&current->mm->mmap_sem);
@@ -542,7 +563,8 @@ static int load_flat_file(struct linux_binprm * bprm,
542 printk("Unable to allocate RAM for process data, errno %d\n", 563 printk("Unable to allocate RAM for process data, errno %d\n",
543 (int)-datapos); 564 (int)-datapos);
544 do_munmap(current->mm, textpos, text_len); 565 do_munmap(current->mm, textpos, text_len);
545 return realdatastart; 566 ret = realdatastart;
567 goto err_close;
546 } 568 }
547 datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long); 569 datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
548 570
@@ -564,7 +586,8 @@ static int load_flat_file(struct linux_binprm * bprm,
564 printk("Unable to read data+bss, errno %d\n", (int)-result); 586 printk("Unable to read data+bss, errno %d\n", (int)-result);
565 do_munmap(current->mm, textpos, text_len); 587 do_munmap(current->mm, textpos, text_len);
566 do_munmap(current->mm, realdatastart, data_len + extra); 588 do_munmap(current->mm, realdatastart, data_len + extra);
567 return result; 589 ret = result;
590 goto err_close;
568 } 591 }
569 592
570 reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len)); 593 reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len));
@@ -582,7 +605,8 @@ static int load_flat_file(struct linux_binprm * bprm,
582 textpos = (unsigned long) -ENOMEM; 605 textpos = (unsigned long) -ENOMEM;
583 printk("Unable to allocate RAM for process text/data, errno %d\n", 606 printk("Unable to allocate RAM for process text/data, errno %d\n",
584 (int)-textpos); 607 (int)-textpos);
585 return(textpos); 608 ret = textpos;
609 goto err_close;
586 } 610 }
587 611
588 realdatastart = textpos + ntohl(hdr->data_start); 612 realdatastart = textpos + ntohl(hdr->data_start);
@@ -627,7 +651,8 @@ static int load_flat_file(struct linux_binprm * bprm,
627 printk("Unable to read code+data+bss, errno %d\n",(int)-result); 651 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
628 do_munmap(current->mm, textpos, text_len + data_len + extra + 652 do_munmap(current->mm, textpos, text_len + data_len + extra +
629 MAX_SHARED_LIBS * sizeof(unsigned long)); 653 MAX_SHARED_LIBS * sizeof(unsigned long));
630 return result; 654 ret = result;
655 goto err_close;
631 } 656 }
632 } 657 }
633 658
@@ -690,8 +715,10 @@ static int load_flat_file(struct linux_binprm * bprm,
690 unsigned long addr; 715 unsigned long addr;
691 if (*rp) { 716 if (*rp) {
692 addr = calc_reloc(*rp, libinfo, id, 0); 717 addr = calc_reloc(*rp, libinfo, id, 0);
693 if (addr == RELOC_FAILED) 718 if (addr == RELOC_FAILED) {
694 return -ENOEXEC; 719 ret = -ENOEXEC;
720 goto err_close;
721 }
695 *rp = addr; 722 *rp = addr;
696 } 723 }
697 } 724 }
@@ -718,8 +745,10 @@ static int load_flat_file(struct linux_binprm * bprm,
718 relval = ntohl(reloc[i]); 745 relval = ntohl(reloc[i]);
719 addr = flat_get_relocate_addr(relval); 746 addr = flat_get_relocate_addr(relval);
720 rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1); 747 rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1);
721 if (rp == (unsigned long *)RELOC_FAILED) 748 if (rp == (unsigned long *)RELOC_FAILED) {
722 return -ENOEXEC; 749 ret = -ENOEXEC;
750 goto err_close;
751 }
723 752
724 /* Get the pointer's value. */ 753 /* Get the pointer's value. */
725 addr = flat_get_addr_from_rp(rp, relval, flags); 754 addr = flat_get_addr_from_rp(rp, relval, flags);
@@ -731,8 +760,10 @@ static int load_flat_file(struct linux_binprm * bprm,
731 if ((flags & FLAT_FLAG_GOTPIC) == 0) 760 if ((flags & FLAT_FLAG_GOTPIC) == 0)
732 addr = ntohl(addr); 761 addr = ntohl(addr);
733 addr = calc_reloc(addr, libinfo, id, 0); 762 addr = calc_reloc(addr, libinfo, id, 0);
734 if (addr == RELOC_FAILED) 763 if (addr == RELOC_FAILED) {
735 return -ENOEXEC; 764 ret = -ENOEXEC;
765 goto err_close;
766 }
736 767
737 /* Write back the relocated pointer. */ 768 /* Write back the relocated pointer. */
738 flat_put_addr_at_rp(rp, addr, relval); 769 flat_put_addr_at_rp(rp, addr, relval);
@@ -752,6 +783,10 @@ static int load_flat_file(struct linux_binprm * bprm,
752 stack_len); 783 stack_len);
753 784
754 return 0; 785 return 0;
786err_close:
787 sys_close(exec_fileno);
788err:
789 return ret;
755} 790}
756 791
757 792
diff --git a/fs/bio.c b/fs/bio.c
index 0a8c59cb68f5..73e664c01d30 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -636,12 +636,10 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
636 return ERR_PTR(-ENOMEM); 636 return ERR_PTR(-ENOMEM);
637 637
638 ret = -ENOMEM; 638 ret = -ENOMEM;
639 pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL); 639 pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
640 if (!pages) 640 if (!pages)
641 goto out; 641 goto out;
642 642
643 memset(pages, 0, nr_pages * sizeof(struct page *));
644
645 for (i = 0; i < iov_count; i++) { 643 for (i = 0; i < iov_count; i++) {
646 unsigned long uaddr = (unsigned long)iov[i].iov_base; 644 unsigned long uaddr = (unsigned long)iov[i].iov_base;
647 unsigned long len = iov[i].iov_len; 645 unsigned long len = iov[i].iov_len;
@@ -1186,12 +1184,11 @@ void bioset_free(struct bio_set *bs)
1186 1184
1187struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale) 1185struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale)
1188{ 1186{
1189 struct bio_set *bs = kmalloc(sizeof(*bs), GFP_KERNEL); 1187 struct bio_set *bs = kzalloc(sizeof(*bs), GFP_KERNEL);
1190 1188
1191 if (!bs) 1189 if (!bs)
1192 return NULL; 1190 return NULL;
1193 1191
1194 memset(bs, 0, sizeof(*bs));
1195 bs->bio_pool = mempool_create(bio_pool_size, mempool_alloc_slab, 1192 bs->bio_pool = mempool_create(bio_pool_size, mempool_alloc_slab,
1196 mempool_free_slab, bio_slab); 1193 mempool_free_slab, bio_slab);
1197 1194
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 44d05e6e34db..573fc8e0b67a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -86,16 +86,12 @@ EXPORT_SYMBOL(set_blocksize);
86 86
87int sb_set_blocksize(struct super_block *sb, int size) 87int sb_set_blocksize(struct super_block *sb, int size)
88{ 88{
89 int bits = 9; /* 2^9 = 512 */
90
91 if (set_blocksize(sb->s_bdev, size)) 89 if (set_blocksize(sb->s_bdev, size))
92 return 0; 90 return 0;
93 /* If we get here, we know size is power of two 91 /* If we get here, we know size is power of two
94 * and it's value is between 512 and PAGE_SIZE */ 92 * and it's value is between 512 and PAGE_SIZE */
95 sb->s_blocksize = size; 93 sb->s_blocksize = size;
96 for (size >>= 10; size; size >>= 1) 94 sb->s_blocksize_bits = blksize_bits(size);
97 ++bits;
98 sb->s_blocksize_bits = bits;
99 return sb->s_blocksize; 95 return sb->s_blocksize;
100} 96}
101 97
@@ -319,7 +315,8 @@ void __init bdev_cache_init(void)
319{ 315{
320 int err; 316 int err;
321 bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode), 317 bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode),
322 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, 318 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
319 SLAB_MEM_SPREAD|SLAB_PANIC),
323 init_once, NULL); 320 init_once, NULL);
324 err = register_filesystem(&bd_type); 321 err = register_filesystem(&bd_type);
325 if (err) 322 if (err)
diff --git a/fs/buffer.c b/fs/buffer.c
index 0d6ca7bac6c8..3b3ab5281920 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -160,12 +160,7 @@ int sync_blockdev(struct block_device *bdev)
160} 160}
161EXPORT_SYMBOL(sync_blockdev); 161EXPORT_SYMBOL(sync_blockdev);
162 162
163/* 163static void __fsync_super(struct super_block *sb)
164 * Write out and wait upon all dirty data associated with this
165 * superblock. Filesystem data as well as the underlying block
166 * device. Takes the superblock lock.
167 */
168int fsync_super(struct super_block *sb)
169{ 164{
170 sync_inodes_sb(sb, 0); 165 sync_inodes_sb(sb, 0);
171 DQUOT_SYNC(sb); 166 DQUOT_SYNC(sb);
@@ -177,7 +172,16 @@ int fsync_super(struct super_block *sb)
177 sb->s_op->sync_fs(sb, 1); 172 sb->s_op->sync_fs(sb, 1);
178 sync_blockdev(sb->s_bdev); 173 sync_blockdev(sb->s_bdev);
179 sync_inodes_sb(sb, 1); 174 sync_inodes_sb(sb, 1);
175}
180 176
177/*
178 * Write out and wait upon all dirty data associated with this
179 * superblock. Filesystem data as well as the underlying block
180 * device. Takes the superblock lock.
181 */
182int fsync_super(struct super_block *sb)
183{
184 __fsync_super(sb);
181 return sync_blockdev(sb->s_bdev); 185 return sync_blockdev(sb->s_bdev);
182} 186}
183 187
@@ -216,19 +220,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
216 sb->s_frozen = SB_FREEZE_WRITE; 220 sb->s_frozen = SB_FREEZE_WRITE;
217 smp_wmb(); 221 smp_wmb();
218 222
219 sync_inodes_sb(sb, 0); 223 __fsync_super(sb);
220 DQUOT_SYNC(sb);
221
222 lock_super(sb);
223 if (sb->s_dirt && sb->s_op->write_super)
224 sb->s_op->write_super(sb);
225 unlock_super(sb);
226
227 if (sb->s_op->sync_fs)
228 sb->s_op->sync_fs(sb, 1);
229
230 sync_blockdev(sb->s_bdev);
231 sync_inodes_sb(sb, 1);
232 224
233 sb->s_frozen = SB_FREEZE_TRANS; 225 sb->s_frozen = SB_FREEZE_TRANS;
234 smp_wmb(); 226 smp_wmb();
@@ -327,31 +319,24 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
327 return ret; 319 return ret;
328} 320}
329 321
330static long do_fsync(unsigned int fd, int datasync) 322long do_fsync(struct file *file, int datasync)
331{ 323{
332 struct file * file; 324 int ret;
333 struct address_space *mapping; 325 int err;
334 int ret, err; 326 struct address_space *mapping = file->f_mapping;
335
336 ret = -EBADF;
337 file = fget(fd);
338 if (!file)
339 goto out;
340 327
341 ret = -EINVAL;
342 if (!file->f_op || !file->f_op->fsync) { 328 if (!file->f_op || !file->f_op->fsync) {
343 /* Why? We can still call filemap_fdatawrite */ 329 /* Why? We can still call filemap_fdatawrite */
344 goto out_putf; 330 ret = -EINVAL;
331 goto out;
345 } 332 }
346 333
347 mapping = file->f_mapping;
348
349 current->flags |= PF_SYNCWRITE; 334 current->flags |= PF_SYNCWRITE;
350 ret = filemap_fdatawrite(mapping); 335 ret = filemap_fdatawrite(mapping);
351 336
352 /* 337 /*
353 * We need to protect against concurrent writers, 338 * We need to protect against concurrent writers, which could cause
354 * which could cause livelocks in fsync_buffers_list 339 * livelocks in fsync_buffers_list().
355 */ 340 */
356 mutex_lock(&mapping->host->i_mutex); 341 mutex_lock(&mapping->host->i_mutex);
357 err = file->f_op->fsync(file, file->f_dentry, datasync); 342 err = file->f_op->fsync(file, file->f_dentry, datasync);
@@ -362,21 +347,31 @@ static long do_fsync(unsigned int fd, int datasync)
362 if (!ret) 347 if (!ret)
363 ret = err; 348 ret = err;
364 current->flags &= ~PF_SYNCWRITE; 349 current->flags &= ~PF_SYNCWRITE;
365
366out_putf:
367 fput(file);
368out: 350out:
369 return ret; 351 return ret;
370} 352}
371 353
354static long __do_fsync(unsigned int fd, int datasync)
355{
356 struct file *file;
357 int ret = -EBADF;
358
359 file = fget(fd);
360 if (file) {
361 ret = do_fsync(file, datasync);
362 fput(file);
363 }
364 return ret;
365}
366
372asmlinkage long sys_fsync(unsigned int fd) 367asmlinkage long sys_fsync(unsigned int fd)
373{ 368{
374 return do_fsync(fd, 0); 369 return __do_fsync(fd, 0);
375} 370}
376 371
377asmlinkage long sys_fdatasync(unsigned int fd) 372asmlinkage long sys_fdatasync(unsigned int fd)
378{ 373{
379 return do_fsync(fd, 1); 374 return __do_fsync(fd, 1);
380} 375}
381 376
382/* 377/*
@@ -865,8 +860,8 @@ int __set_page_dirty_buffers(struct page *page)
865 } 860 }
866 write_unlock_irq(&mapping->tree_lock); 861 write_unlock_irq(&mapping->tree_lock);
867 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 862 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
863 return 1;
868 } 864 }
869
870 return 0; 865 return 0;
871} 866}
872EXPORT_SYMBOL(__set_page_dirty_buffers); 867EXPORT_SYMBOL(__set_page_dirty_buffers);
@@ -3078,7 +3073,7 @@ static void recalc_bh_state(void)
3078 if (__get_cpu_var(bh_accounting).ratelimit++ < 4096) 3073 if (__get_cpu_var(bh_accounting).ratelimit++ < 4096)
3079 return; 3074 return;
3080 __get_cpu_var(bh_accounting).ratelimit = 0; 3075 __get_cpu_var(bh_accounting).ratelimit = 0;
3081 for_each_cpu(i) 3076 for_each_online_cpu(i)
3082 tot += per_cpu(bh_accounting, i).nr; 3077 tot += per_cpu(bh_accounting, i).nr;
3083 buffer_heads_over_limit = (tot > max_buffer_heads); 3078 buffer_heads_over_limit = (tot > max_buffer_heads);
3084} 3079}
@@ -3127,6 +3122,9 @@ static void buffer_exit_cpu(int cpu)
3127 brelse(b->bhs[i]); 3122 brelse(b->bhs[i]);
3128 b->bhs[i] = NULL; 3123 b->bhs[i] = NULL;
3129 } 3124 }
3125 get_cpu_var(bh_accounting).nr += per_cpu(bh_accounting, cpu).nr;
3126 per_cpu(bh_accounting, cpu).nr = 0;
3127 put_cpu_var(bh_accounting);
3130} 3128}
3131 3129
3132static int buffer_cpu_notify(struct notifier_block *self, 3130static int buffer_cpu_notify(struct notifier_block *self,
@@ -3143,8 +3141,11 @@ void __init buffer_init(void)
3143 int nrpages; 3141 int nrpages;
3144 3142
3145 bh_cachep = kmem_cache_create("buffer_head", 3143 bh_cachep = kmem_cache_create("buffer_head",
3146 sizeof(struct buffer_head), 0, 3144 sizeof(struct buffer_head), 0,
3147 SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, init_buffer_head, NULL); 3145 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
3146 SLAB_MEM_SPREAD),
3147 init_buffer_head,
3148 NULL);
3148 3149
3149 /* 3150 /*
3150 * Limit the bh occupancy to 10% of ZONE_NORMAL 3151 * Limit the bh occupancy to 10% of ZONE_NORMAL
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 5c36345c9bf7..8c6eb04d31e2 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -146,12 +146,10 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
146 int ret = 0; 146 int ret = 0;
147 int i; 147 int i;
148 148
149 cd = kmalloc(sizeof(struct char_device_struct), GFP_KERNEL); 149 cd = kzalloc(sizeof(struct char_device_struct), GFP_KERNEL);
150 if (cd == NULL) 150 if (cd == NULL)
151 return ERR_PTR(-ENOMEM); 151 return ERR_PTR(-ENOMEM);
152 152
153 memset(cd, 0, sizeof(struct char_device_struct));
154
155 mutex_lock(&chrdevs_lock); 153 mutex_lock(&chrdevs_lock);
156 154
157 /* temporary */ 155 /* temporary */
@@ -466,9 +464,8 @@ static struct kobj_type ktype_cdev_dynamic = {
466 464
467struct cdev *cdev_alloc(void) 465struct cdev *cdev_alloc(void)
468{ 466{
469 struct cdev *p = kmalloc(sizeof(struct cdev), GFP_KERNEL); 467 struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
470 if (p) { 468 if (p) {
471 memset(p, 0, sizeof(struct cdev));
472 p->kobj.ktype = &ktype_cdev_dynamic; 469 p->kobj.ktype = &ktype_cdev_dynamic;
473 INIT_LIST_HEAD(&p->list); 470 INIT_LIST_HEAD(&p->list);
474 kobject_init(&p->kobj); 471 kobject_init(&p->kobj);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 79eeccd0437f..221b3334b737 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -479,7 +479,7 @@ cifs_get_sb(struct file_system_type *fs_type,
479 479
480 sb->s_flags = flags; 480 sb->s_flags = flags;
481 481
482 rc = cifs_read_super(sb, data, dev_name, flags & MS_VERBOSE ? 1 : 0); 482 rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);
483 if (rc) { 483 if (rc) {
484 up_write(&sb->s_umount); 484 up_write(&sb->s_umount);
485 deactivate_super(sb); 485 deactivate_super(sb);
@@ -695,7 +695,8 @@ cifs_init_inodecache(void)
695{ 695{
696 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache", 696 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
697 sizeof (struct cifsInodeInfo), 697 sizeof (struct cifsInodeInfo),
698 0, SLAB_RECLAIM_ACCOUNT, 698 0, (SLAB_RECLAIM_ACCOUNT|
699 SLAB_MEM_SPREAD),
699 cifs_init_once, NULL); 700 cifs_init_once, NULL);
700 if (cifs_inode_cachep == NULL) 701 if (cifs_inode_cachep == NULL)
701 return -ENOMEM; 702 return -ENOMEM;
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index b41e8b379652..a243fe2792d5 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -4908,7 +4908,7 @@ SetEARetry:
4908 parm_data->list_len = cpu_to_le32(count); 4908 parm_data->list_len = cpu_to_le32(count);
4909 parm_data->list[0].EA_flags = 0; 4909 parm_data->list[0].EA_flags = 0;
4910 /* we checked above that name len is less than 255 */ 4910 /* we checked above that name len is less than 255 */
4911 parm_data->list[0].name_len = (__u8)name_len;; 4911 parm_data->list[0].name_len = (__u8)name_len;
4912 /* EA names are always ASCII */ 4912 /* EA names are always ASCII */
4913 if(ea_name) 4913 if(ea_name)
4914 strncpy(parm_data->list[0].name,ea_name,name_len); 4914 strncpy(parm_data->list[0].name,ea_name,name_len);
diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index c607d923350a..5d0527133266 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -51,7 +51,7 @@ void coda_cache_clear_all(struct super_block *sb)
51 struct coda_sb_info *sbi; 51 struct coda_sb_info *sbi;
52 52
53 sbi = coda_sbp(sb); 53 sbi = coda_sbp(sb);
54 if (!sbi) BUG(); 54 BUG_ON(!sbi);
55 55
56 atomic_inc(&permission_epoch); 56 atomic_inc(&permission_epoch);
57} 57}
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 23aeef5aa814..4c9fecbfa91f 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,
120 120
121 cii = ITOC(inode); 121 cii = ITOC(inode);
122 122
123 if (!coda_fideq(&cii->c_fid, oldfid)) 123 BUG_ON(!coda_fideq(&cii->c_fid, oldfid));
124 BUG();
125 124
126 /* replace fid and rehash inode */ 125 /* replace fid and rehash inode */
127 /* XXX we probably need to hold some lock here! */ 126 /* 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 000000000000..9e6338fea514
--- /dev/null
+++ b/fs/coda/coda_int.h
@@ -0,0 +1,13 @@
1#ifndef _CODA_INT_
2#define _CODA_INT_
3
4extern struct file_system_type coda_fs_type;
5
6void coda_destroy_inodecache(void);
7int coda_init_inodecache(void);
8int coda_fsync(struct file *coda_file, struct dentry *coda_dentry,
9 int datasync);
10
11#endif /* _CODA_INT_ */
12
13
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 8f1a517f8b4e..54f76de8a686 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -27,6 +27,8 @@
27#include <linux/coda_cache.h> 27#include <linux/coda_cache.h>
28#include <linux/coda_proc.h> 28#include <linux/coda_proc.h>
29 29
30#include "coda_int.h"
31
30/* dir inode-ops */ 32/* dir inode-ops */
31static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd); 33static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd);
32static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd); 34static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd);
@@ -50,7 +52,6 @@ static int coda_dentry_delete(struct dentry *);
50/* support routines */ 52/* support routines */
51static int coda_venus_readdir(struct file *filp, filldir_t filldir, 53static int coda_venus_readdir(struct file *filp, filldir_t filldir,
52 void *dirent, struct dentry *dir); 54 void *dirent, struct dentry *dir);
53int coda_fsync(struct file *, struct dentry *dentry, int datasync);
54 55
55/* same as fs/bad_inode.c */ 56/* same as fs/bad_inode.c */
56static int coda_return_EIO(void) 57static int coda_return_EIO(void)
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 30b4630bd735..146a991d6eb5 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -24,6 +24,8 @@
24#include <linux/coda_psdev.h> 24#include <linux/coda_psdev.h>
25#include <linux/coda_proc.h> 25#include <linux/coda_proc.h>
26 26
27#include "coda_int.h"
28
27/* if CODA_STORE fails with EOPNOTSUPP, venus clearly doesn't support 29/* if CODA_STORE fails with EOPNOTSUPP, venus clearly doesn't support
28 * CODA_STORE/CODA_RELEASE and we fall back on using the CODA_CLOSE upcall */ 30 * CODA_STORE/CODA_RELEASE and we fall back on using the CODA_CLOSE upcall */
29static int use_coda_close; 31static int use_coda_close;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 04a73fb4848f..ada1a81df6bd 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -31,6 +31,8 @@
31#include <linux/coda_fs_i.h> 31#include <linux/coda_fs_i.h>
32#include <linux/coda_cache.h> 32#include <linux/coda_cache.h>
33 33
34#include "coda_int.h"
35
34/* VFS super_block ops */ 36/* VFS super_block ops */
35static void coda_clear_inode(struct inode *); 37static void coda_clear_inode(struct inode *);
36static void coda_put_super(struct super_block *); 38static void coda_put_super(struct super_block *);
@@ -69,7 +71,7 @@ int coda_init_inodecache(void)
69{ 71{
70 coda_inode_cachep = kmem_cache_create("coda_inode_cache", 72 coda_inode_cachep = kmem_cache_create("coda_inode_cache",
71 sizeof(struct coda_inode_info), 73 sizeof(struct coda_inode_info),
72 0, SLAB_RECLAIM_ACCOUNT, 74 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
73 init_once, NULL); 75 init_once, NULL);
74 if (coda_inode_cachep == NULL) 76 if (coda_inode_cachep == NULL)
75 return -ENOMEM; 77 return -ENOMEM;
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 6a3df88accfe..98c74fe2e139 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -48,12 +48,9 @@
48#include <linux/coda_psdev.h> 48#include <linux/coda_psdev.h>
49#include <linux/coda_proc.h> 49#include <linux/coda_proc.h>
50 50
51#define upc_free(r) kfree(r) 51#include "coda_int.h"
52 52
53/* 53#define upc_free(r) kfree(r)
54 * Coda stuff
55 */
56extern struct file_system_type coda_fs_type;
57 54
58/* statistics */ 55/* statistics */
59int coda_hard; /* allows signals during upcalls */ 56int coda_hard; /* allows signals during upcalls */
@@ -394,8 +391,6 @@ out:
394MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>"); 391MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>");
395MODULE_LICENSE("GPL"); 392MODULE_LICENSE("GPL");
396 393
397extern int coda_init_inodecache(void);
398extern void coda_destroy_inodecache(void);
399static int __init init_coda(void) 394static int __init init_coda(void)
400{ 395{
401 int status; 396 int status;
diff --git a/fs/compat.c b/fs/compat.c
index 5333c7d7427f..ef5a0771592d 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -114,6 +114,7 @@ asmlinkage long compat_sys_newlstat(char __user * filename,
114 return error; 114 return error;
115} 115}
116 116
117#ifndef __ARCH_WANT_STAT64
117asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename, 118asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
118 struct compat_stat __user *statbuf, int flag) 119 struct compat_stat __user *statbuf, int flag)
119{ 120{
@@ -134,6 +135,7 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
134out: 135out:
135 return error; 136 return error;
136} 137}
138#endif
137 139
138asmlinkage long compat_sys_newfstat(unsigned int fd, 140asmlinkage long compat_sys_newfstat(unsigned int fd,
139 struct compat_stat __user * statbuf) 141 struct compat_stat __user * statbuf)
@@ -1474,10 +1476,9 @@ int compat_do_execve(char * filename,
1474 int i; 1476 int i;
1475 1477
1476 retval = -ENOMEM; 1478 retval = -ENOMEM;
1477 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL); 1479 bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
1478 if (!bprm) 1480 if (!bprm)
1479 goto out_ret; 1481 goto out_ret;
1480 memset(bprm, 0, sizeof(*bprm));
1481 1482
1482 file = open_exec(filename); 1483 file = open_exec(filename);
1483 retval = PTR_ERR(file); 1484 retval = PTR_ERR(file);
@@ -2168,9 +2169,12 @@ asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user *
2168 2169
2169 default: 2170 default:
2170 err = -EINVAL; 2171 err = -EINVAL;
2171 goto done; 2172 break;
2172 } 2173 }
2173 2174
2175 if (err)
2176 goto done;
2177
2174 oldfs = get_fs(); 2178 oldfs = get_fs();
2175 set_fs(KERNEL_DS); 2179 set_fs(KERNEL_DS);
2176 /* The __user pointer casts are valid because of the set_fs() */ 2180 /* The __user pointer casts are valid because of the set_fs() */
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 7c031f00fd79..d2c38875ab29 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1522,8 +1522,7 @@ static struct {
1522 { ATM_QUERYLOOP32, ATM_QUERYLOOP } 1522 { ATM_QUERYLOOP32, ATM_QUERYLOOP }
1523}; 1523};
1524 1524
1525#define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0])) 1525#define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
1526
1527 1526
1528static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg) 1527static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
1529{ 1528{
@@ -1824,7 +1823,7 @@ static struct {
1824 { FDWERRORGET32, FDWERRORGET } 1823 { FDWERRORGET32, FDWERRORGET }
1825}; 1824};
1826 1825
1827#define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0])) 1826#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
1828 1827
1829static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) 1828static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1830{ 1829{
diff --git a/fs/dcache.c b/fs/dcache.c
index 11dc83092d4a..939584648504 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)
325 325
326struct dentry * d_find_alias(struct inode *inode) 326struct dentry * d_find_alias(struct inode *inode)
327{ 327{
328 struct dentry *de; 328 struct dentry *de = NULL;
329 spin_lock(&dcache_lock); 329
330 de = __d_find_alias(inode, 0); 330 if (!list_empty(&inode->i_dentry)) {
331 spin_unlock(&dcache_lock); 331 spin_lock(&dcache_lock);
332 de = __d_find_alias(inode, 0);
333 spin_unlock(&dcache_lock);
334 }
332 return de; 335 return de;
333} 336}
334 337
@@ -486,6 +489,7 @@ repeat:
486 continue; 489 continue;
487 } 490 }
488 prune_one_dentry(dentry); 491 prune_one_dentry(dentry);
492 cond_resched_lock(&dcache_lock);
489 goto repeat; 493 goto repeat;
490 } 494 }
491 spin_unlock(&dcache_lock); 495 spin_unlock(&dcache_lock);
@@ -799,6 +803,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode)
799 if (inode) 803 if (inode)
800 list_add(&entry->d_alias, &inode->i_dentry); 804 list_add(&entry->d_alias, &inode->i_dentry);
801 entry->d_inode = inode; 805 entry->d_inode = inode;
806 fsnotify_d_instantiate(entry, inode);
802 spin_unlock(&dcache_lock); 807 spin_unlock(&dcache_lock);
803 security_d_instantiate(entry, inode); 808 security_d_instantiate(entry, inode);
804} 809}
@@ -850,6 +855,7 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode)
850 list_add(&entry->d_alias, &inode->i_dentry); 855 list_add(&entry->d_alias, &inode->i_dentry);
851do_negative: 856do_negative:
852 entry->d_inode = inode; 857 entry->d_inode = inode;
858 fsnotify_d_instantiate(entry, inode);
853 spin_unlock(&dcache_lock); 859 spin_unlock(&dcache_lock);
854 security_d_instantiate(entry, inode); 860 security_d_instantiate(entry, inode);
855 return NULL; 861 return NULL;
@@ -980,6 +986,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
980 new = __d_find_alias(inode, 1); 986 new = __d_find_alias(inode, 1);
981 if (new) { 987 if (new) {
982 BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); 988 BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED));
989 fsnotify_d_instantiate(new, inode);
983 spin_unlock(&dcache_lock); 990 spin_unlock(&dcache_lock);
984 security_d_instantiate(new, inode); 991 security_d_instantiate(new, inode);
985 d_rehash(dentry); 992 d_rehash(dentry);
@@ -989,6 +996,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
989 /* d_instantiate takes dcache_lock, so we do it by hand */ 996 /* d_instantiate takes dcache_lock, so we do it by hand */
990 list_add(&dentry->d_alias, &inode->i_dentry); 997 list_add(&dentry->d_alias, &inode->i_dentry);
991 dentry->d_inode = inode; 998 dentry->d_inode = inode;
999 fsnotify_d_instantiate(dentry, inode);
992 spin_unlock(&dcache_lock); 1000 spin_unlock(&dcache_lock);
993 security_d_instantiate(dentry, inode); 1001 security_d_instantiate(dentry, inode);
994 d_rehash(dentry); 1002 d_rehash(dentry);
@@ -1173,6 +1181,9 @@ void d_delete(struct dentry * dentry)
1173 spin_lock(&dentry->d_lock); 1181 spin_lock(&dentry->d_lock);
1174 isdir = S_ISDIR(dentry->d_inode->i_mode); 1182 isdir = S_ISDIR(dentry->d_inode->i_mode);
1175 if (atomic_read(&dentry->d_count) == 1) { 1183 if (atomic_read(&dentry->d_count) == 1) {
1184 /* remove this and other inotify debug checks after 2.6.18 */
1185 dentry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED;
1186
1176 dentry_iput(dentry); 1187 dentry_iput(dentry);
1177 fsnotify_nameremove(dentry, isdir); 1188 fsnotify_nameremove(dentry, isdir);
1178 return; 1189 return;
@@ -1339,6 +1350,7 @@ already_unhashed:
1339 1350
1340 list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs); 1351 list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs);
1341 spin_unlock(&target->d_lock); 1352 spin_unlock(&target->d_lock);
1353 fsnotify_d_move(dentry);
1342 spin_unlock(&dentry->d_lock); 1354 spin_unlock(&dentry->d_lock);
1343 write_sequnlock(&rename_lock); 1355 write_sequnlock(&rename_lock);
1344 spin_unlock(&dcache_lock); 1356 spin_unlock(&dcache_lock);
@@ -1682,7 +1694,8 @@ static void __init dcache_init(unsigned long mempages)
1682 dentry_cache = kmem_cache_create("dentry_cache", 1694 dentry_cache = kmem_cache_create("dentry_cache",
1683 sizeof(struct dentry), 1695 sizeof(struct dentry),
1684 0, 1696 0,
1685 SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, 1697 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
1698 SLAB_MEM_SPREAD),
1686 NULL, NULL); 1699 NULL, NULL);
1687 1700
1688 set_shrinker(DEFAULT_SEEKS, shrink_dcache_memory); 1701 set_shrinker(DEFAULT_SEEKS, shrink_dcache_memory);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 27f3e787faca..235ed8d1f11e 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -129,6 +129,7 @@ struct dio {
129 /* AIO related stuff */ 129 /* AIO related stuff */
130 struct kiocb *iocb; /* kiocb */ 130 struct kiocb *iocb; /* kiocb */
131 int is_async; /* is IO async ? */ 131 int is_async; /* is IO async ? */
132 int io_error; /* IO error in completion path */
132 ssize_t result; /* IO result */ 133 ssize_t result; /* IO result */
133}; 134};
134 135
@@ -250,6 +251,10 @@ static void finished_one_bio(struct dio *dio)
250 ((offset + transferred) > dio->i_size)) 251 ((offset + transferred) > dio->i_size))
251 transferred = dio->i_size - offset; 252 transferred = dio->i_size - offset;
252 253
254 /* check for error in completion path */
255 if (dio->io_error)
256 transferred = dio->io_error;
257
253 dio_complete(dio, offset, transferred); 258 dio_complete(dio, offset, transferred);
254 259
255 /* Complete AIO later if falling back to buffered i/o */ 260 /* 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)
406 int page_no; 411 int page_no;
407 412
408 if (!uptodate) 413 if (!uptodate)
409 dio->result = -EIO; 414 dio->io_error = -EIO;
410 415
411 if (dio->is_async && dio->rw == READ) { 416 if (dio->is_async && dio->rw == READ) {
412 bio_check_pages_dirty(bio); /* transfers ownership */ 417 bio_check_pages_dirty(bio); /* transfers ownership */
@@ -971,6 +976,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
971 dio->next_block_for_io = -1; 976 dio->next_block_for_io = -1;
972 977
973 dio->page_errors = 0; 978 dio->page_errors = 0;
979 dio->io_error = 0;
974 dio->result = 0; 980 dio->result = 0;
975 dio->iocb = iocb; 981 dio->iocb = iocb;
976 dio->i_size = i_size_read(inode); 982 dio->i_size = i_size_read(inode);
diff --git a/fs/dquot.c b/fs/dquot.c
index acf07e581f8c..6b3886920939 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1821,7 +1821,8 @@ static int __init dquot_init(void)
1821 1821
1822 dquot_cachep = kmem_cache_create("dquot", 1822 dquot_cachep = kmem_cache_create("dquot",
1823 sizeof(struct dquot), sizeof(unsigned long) * 4, 1823 sizeof(struct dquot), sizeof(unsigned long) * 4,
1824 SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, 1824 (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
1825 SLAB_MEM_SPREAD|SLAB_PANIC),
1825 NULL, NULL); 1826 NULL, NULL);
1826 1827
1827 order = 0; 1828 order = 0;
diff --git a/fs/efs/super.c b/fs/efs/super.c
index afc4891feb36..dff623e3ddbf 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -81,7 +81,7 @@ static int init_inodecache(void)
81{ 81{
82 efs_inode_cachep = kmem_cache_create("efs_inode_cache", 82 efs_inode_cachep = kmem_cache_create("efs_inode_cache",
83 sizeof(struct efs_inode_info), 83 sizeof(struct efs_inode_info),
84 0, SLAB_RECLAIM_ACCOUNT, 84 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
85 init_once, NULL); 85 init_once, NULL);
86 if (efs_inode_cachep == NULL) 86 if (efs_inode_cachep == NULL)
87 return -ENOMEM; 87 return -ENOMEM;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 1c2b16fda13a..a0f682cdd03e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -599,7 +599,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
599 switch (op) { 599 switch (op) {
600 case EPOLL_CTL_ADD: 600 case EPOLL_CTL_ADD:
601 if (!epi) { 601 if (!epi) {
602 epds.events |= POLLERR | POLLHUP; 602 epds.events |= POLLERR | POLLHUP | POLLRDHUP;
603 603
604 error = ep_insert(ep, &epds, tfile, fd); 604 error = ep_insert(ep, &epds, tfile, fd);
605 } else 605 } else
@@ -613,7 +613,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
613 break; 613 break;
614 case EPOLL_CTL_MOD: 614 case EPOLL_CTL_MOD:
615 if (epi) { 615 if (epi) {
616 epds.events |= POLLERR | POLLHUP; 616 epds.events |= POLLERR | POLLHUP | POLLRDHUP;
617 error = ep_modify(ep, epi, &epds); 617 error = ep_modify(ep, epi, &epds);
618 } else 618 } else
619 error = -ENOENT; 619 error = -ENOENT;
diff --git a/fs/exec.c b/fs/exec.c
index 0b515ac53134..995cba3c62b8 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -127,7 +127,7 @@ asmlinkage long sys_uselib(const char __user * library)
127 struct nameidata nd; 127 struct nameidata nd;
128 int error; 128 int error;
129 129
130 error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ); 130 error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
131 if (error) 131 if (error)
132 goto out; 132 goto out;
133 133
@@ -477,7 +477,7 @@ struct file *open_exec(const char *name)
477 int err; 477 int err;
478 struct file *file; 478 struct file *file;
479 479
480 err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ); 480 err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
481 file = ERR_PTR(err); 481 file = ERR_PTR(err);
482 482
483 if (!err) { 483 if (!err) {
@@ -1143,10 +1143,9 @@ int do_execve(char * filename,
1143 int i; 1143 int i;
1144 1144
1145 retval = -ENOMEM; 1145 retval = -ENOMEM;
1146 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL); 1146 bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
1147 if (!bprm) 1147 if (!bprm)
1148 goto out_ret; 1148 goto out_ret;
1149 memset(bprm, 0, sizeof(*bprm));
1150 1149
1151 file = open_exec(filename); 1150 file = open_exec(filename);
1152 retval = PTR_ERR(file); 1151 retval = PTR_ERR(file);
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 00de0a7312a2..11035ac7986f 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -138,6 +138,9 @@ extern void ext2_set_inode_flags(struct inode *inode);
138extern int ext2_ioctl (struct inode *, struct file *, unsigned int, 138extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
139 unsigned long); 139 unsigned long);
140 140
141/* namei.c */
142struct dentry *ext2_get_parent(struct dentry *child);
143
141/* super.c */ 144/* super.c */
142extern void ext2_error (struct super_block *, const char *, const char *, ...) 145extern void ext2_error (struct super_block *, const char *, const char *, ...)
143 __attribute__ ((format (printf, 3, 4))); 146 __attribute__ ((format (printf, 3, 4)));
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index cb6f9bd658de..7e30bae174ed 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -175,7 +175,8 @@ static int init_inodecache(void)
175{ 175{
176 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache", 176 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
177 sizeof(struct ext2_inode_info), 177 sizeof(struct ext2_inode_info),
178 0, SLAB_RECLAIM_ACCOUNT, 178 0, (SLAB_RECLAIM_ACCOUNT|
179 SLAB_MEM_SPREAD),
179 init_once, NULL); 180 init_once, NULL);
180 if (ext2_inode_cachep == NULL) 181 if (ext2_inode_cachep == NULL)
181 return -ENOMEM; 182 return -ENOMEM;
@@ -210,8 +211,6 @@ static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
210 211
211 if (sbi->s_mount_opt & EXT2_MOUNT_GRPID) 212 if (sbi->s_mount_opt & EXT2_MOUNT_GRPID)
212 seq_puts(seq, ",grpid"); 213 seq_puts(seq, ",grpid");
213 else
214 seq_puts(seq, ",nogrpid");
215 214
216#if defined(CONFIG_QUOTA) 215#if defined(CONFIG_QUOTA)
217 if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA) 216 if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA)
@@ -258,7 +257,6 @@ static struct super_operations ext2_sops = {
258 * systems, but can be improved upon. 257 * systems, but can be improved upon.
259 * Currently only get_parent is required. 258 * Currently only get_parent is required.
260 */ 259 */
261struct dentry *ext2_get_parent(struct dentry *child);
262static struct export_operations ext2_export_ops = { 260static struct export_operations ext2_export_ops = {
263 .get_parent = ext2_get_parent, 261 .get_parent = ext2_get_parent,
264}; 262};
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 6250fcdf14a1..46623f77666b 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -1493,12 +1493,33 @@ static int ext3_group_sparse(int group)
1493 */ 1493 */
1494int ext3_bg_has_super(struct super_block *sb, int group) 1494int ext3_bg_has_super(struct super_block *sb, int group)
1495{ 1495{
1496 if (EXT3_HAS_RO_COMPAT_FEATURE(sb,EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)&& 1496 if (EXT3_HAS_RO_COMPAT_FEATURE(sb,
1497 !ext3_group_sparse(group)) 1497 EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
1498 !ext3_group_sparse(group))
1498 return 0; 1499 return 0;
1499 return 1; 1500 return 1;
1500} 1501}
1501 1502
1503static unsigned long ext3_bg_num_gdb_meta(struct super_block *sb, int group)
1504{
1505 unsigned long metagroup = group / EXT3_DESC_PER_BLOCK(sb);
1506 unsigned long first = metagroup * EXT3_DESC_PER_BLOCK(sb);
1507 unsigned long last = first + EXT3_DESC_PER_BLOCK(sb) - 1;
1508
1509 if (group == first || group == first + 1 || group == last)
1510 return 1;
1511 return 0;
1512}
1513
1514static unsigned long ext3_bg_num_gdb_nometa(struct super_block *sb, int group)
1515{
1516 if (EXT3_HAS_RO_COMPAT_FEATURE(sb,
1517 EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
1518 !ext3_group_sparse(group))
1519 return 0;
1520 return EXT3_SB(sb)->s_gdb_count;
1521}
1522
1502/** 1523/**
1503 * ext3_bg_num_gdb - number of blocks used by the group table in group 1524 * ext3_bg_num_gdb - number of blocks used by the group table in group
1504 * @sb: superblock for filesystem 1525 * @sb: superblock for filesystem
@@ -1510,9 +1531,14 @@ int ext3_bg_has_super(struct super_block *sb, int group)
1510 */ 1531 */
1511unsigned long ext3_bg_num_gdb(struct super_block *sb, int group) 1532unsigned long ext3_bg_num_gdb(struct super_block *sb, int group)
1512{ 1533{
1513 if (EXT3_HAS_RO_COMPAT_FEATURE(sb,EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)&& 1534 unsigned long first_meta_bg =
1514 !ext3_group_sparse(group)) 1535 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
1515 return 0; 1536 unsigned long metagroup = group / EXT3_DESC_PER_BLOCK(sb);
1516 return EXT3_SB(sb)->s_gdb_count; 1537
1517} 1538 if (!EXT3_HAS_INCOMPAT_FEATURE(sb,EXT3_FEATURE_INCOMPAT_META_BG) ||
1539 metagroup < first_meta_bg)
1540 return ext3_bg_num_gdb_nometa(sb,group);
1518 1541
1542 return ext3_bg_num_gdb_meta(sb,group);
1543
1544}
diff --git a/fs/ext3/bitmap.c b/fs/ext3/bitmap.c
index cb16b4c5d5df..ce4f82b9e528 100644
--- a/fs/ext3/bitmap.c
+++ b/fs/ext3/bitmap.c
@@ -7,11 +7,11 @@
7 * Universite Pierre et Marie Curie (Paris VI) 7 * Universite Pierre et Marie Curie (Paris VI)
8 */ 8 */
9 9
10#ifdef EXT3FS_DEBUG
11
12#include <linux/buffer_head.h> 10#include <linux/buffer_head.h>
11#include <linux/jbd.h>
12#include <linux/ext3_fs.h>
13 13
14#include "ext3_fs.h" 14#ifdef EXT3FS_DEBUG
15 15
16static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; 16static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
17 17
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index efe5b20d7a5a..86e443182de4 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -481,7 +481,8 @@ static int init_inodecache(void)
481{ 481{
482 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache", 482 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache",
483 sizeof(struct ext3_inode_info), 483 sizeof(struct ext3_inode_info),
484 0, SLAB_RECLAIM_ACCOUNT, 484 0, (SLAB_RECLAIM_ACCOUNT|
485 SLAB_MEM_SPREAD),
485 init_once, NULL); 486 init_once, NULL);
486 if (ext3_inode_cachep == NULL) 487 if (ext3_inode_cachep == NULL)
487 return -ENOMEM; 488 return -ENOMEM;
@@ -2325,7 +2326,8 @@ restore_opts:
2325 2326
2326static int ext3_statfs (struct super_block * sb, struct kstatfs * buf) 2327static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
2327{ 2328{
2328 struct ext3_super_block *es = EXT3_SB(sb)->s_es; 2329 struct ext3_sb_info *sbi = EXT3_SB(sb);
2330 struct ext3_super_block *es = sbi->s_es;
2329 unsigned long overhead; 2331 unsigned long overhead;
2330 int i; 2332 int i;
2331 2333
@@ -2367,12 +2369,12 @@ static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
2367 buf->f_type = EXT3_SUPER_MAGIC; 2369 buf->f_type = EXT3_SUPER_MAGIC;
2368 buf->f_bsize = sb->s_blocksize; 2370 buf->f_bsize = sb->s_blocksize;
2369 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead; 2371 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
2370 buf->f_bfree = ext3_count_free_blocks (sb); 2372 buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
2371 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count); 2373 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
2372 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count)) 2374 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
2373 buf->f_bavail = 0; 2375 buf->f_bavail = 0;
2374 buf->f_files = le32_to_cpu(es->s_inodes_count); 2376 buf->f_files = le32_to_cpu(es->s_inodes_count);
2375 buf->f_ffree = ext3_count_free_inodes (sb); 2377 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2376 buf->f_namelen = EXT3_NAME_LEN; 2378 buf->f_namelen = EXT3_NAME_LEN;
2377 return 0; 2379 return 0;
2378} 2380}
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 1acc941245fb..97b967b84fc6 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -49,7 +49,7 @@ int __init fat_cache_init(void)
49{ 49{
50 fat_cache_cachep = kmem_cache_create("fat_cache", 50 fat_cache_cachep = kmem_cache_create("fat_cache",
51 sizeof(struct fat_cache), 51 sizeof(struct fat_cache),
52 0, SLAB_RECLAIM_ACCOUNT, 52 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53 init_once, NULL); 53 init_once, NULL);
54 if (fat_cache_cachep == NULL) 54 if (fat_cache_cachep == NULL)
55 return -ENOMEM; 55 return -ENOMEM;
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index e78d7b4842cc..297300fe81c2 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -518,7 +518,8 @@ static int __init fat_init_inodecache(void)
518{ 518{
519 fat_inode_cachep = kmem_cache_create("fat_inode_cache", 519 fat_inode_cachep = kmem_cache_create("fat_inode_cache",
520 sizeof(struct msdos_inode_info), 520 sizeof(struct msdos_inode_info),
521 0, SLAB_RECLAIM_ACCOUNT, 521 0, (SLAB_RECLAIM_ACCOUNT|
522 SLAB_MEM_SPREAD),
522 init_once, NULL); 523 init_once, NULL);
523 if (fat_inode_cachep == NULL) 524 if (fat_inode_cachep == NULL)
524 return -ENOMEM; 525 return -ENOMEM;
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
index 6aa6fbe4f8ee..b44c916d24a1 100644
--- a/fs/freevxfs/vxfs_super.c
+++ b/fs/freevxfs/vxfs_super.c
@@ -260,7 +260,7 @@ vxfs_init(void)
260{ 260{
261 vxfs_inode_cachep = kmem_cache_create("vxfs_inode", 261 vxfs_inode_cachep = kmem_cache_create("vxfs_inode",
262 sizeof(struct vxfs_inode_info), 0, 262 sizeof(struct vxfs_inode_info), 0,
263 SLAB_RECLAIM_ACCOUNT, NULL, NULL); 263 SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
264 if (vxfs_inode_cachep) 264 if (vxfs_inode_cachep)
265 return register_filesystem(&vxfs_fs_type); 265 return register_filesystem(&vxfs_fs_type);
266 return -ENOMEM; 266 return -ENOMEM;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 785c7213a54f..f3fbe2d030f4 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)
381 list_move(&inode->i_list, &sb->s_dirty); 381 list_move(&inode->i_list, &sb->s_dirty);
382 } 382 }
383 spin_unlock(&inode_lock); 383 spin_unlock(&inode_lock);
384 cond_resched();
385 iput(inode); 384 iput(inode);
385 cond_resched();
386 spin_lock(&inode_lock); 386 spin_lock(&inode_lock);
387 if (wbc->nr_to_write <= 0) 387 if (wbc->nr_to_write <= 0)
388 break; 388 break;
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 9488a794076e..d72d8c87c996 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -191,7 +191,8 @@ static int init_inodecache(void)
191{ 191{
192 hpfs_inode_cachep = kmem_cache_create("hpfs_inode_cache", 192 hpfs_inode_cachep = kmem_cache_create("hpfs_inode_cache",
193 sizeof(struct hpfs_inode_info), 193 sizeof(struct hpfs_inode_info),
194 0, SLAB_RECLAIM_ACCOUNT, 194 0, (SLAB_RECLAIM_ACCOUNT|
195 SLAB_MEM_SPREAD),
195 init_once, NULL); 196 init_once, NULL);
196 if (hpfs_inode_cachep == NULL) 197 if (hpfs_inode_cachep == NULL)
197 return -ENOMEM; 198 return -ENOMEM;
diff --git a/fs/inode.c b/fs/inode.c
index 25967b67903d..85da11044adc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -91,7 +91,7 @@ DEFINE_SPINLOCK(inode_lock);
91 * from its final dispose_list, the struct super_block they refer to 91 * from its final dispose_list, the struct super_block they refer to
92 * (for inode->i_sb->s_op) may already have been freed and reused. 92 * (for inode->i_sb->s_op) may already have been freed and reused.
93 */ 93 */
94DEFINE_MUTEX(iprune_mutex); 94static DEFINE_MUTEX(iprune_mutex);
95 95
96/* 96/*
97 * Statistics gathering.. 97 * Statistics gathering..
@@ -1375,8 +1375,13 @@ void __init inode_init(unsigned long mempages)
1375 int loop; 1375 int loop;
1376 1376
1377 /* inode slab cache */ 1377 /* inode slab cache */
1378 inode_cachep = kmem_cache_create("inode_cache", sizeof(struct inode), 1378 inode_cachep = kmem_cache_create("inode_cache",
1379 0, SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, init_once, NULL); 1379 sizeof(struct inode),
1380 0,
1381 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
1382 SLAB_MEM_SPREAD),
1383 init_once,
1384 NULL);
1380 set_shrinker(DEFAULT_SEEKS, shrink_icache_memory); 1385 set_shrinker(DEFAULT_SEEKS, shrink_icache_memory);
1381 1386
1382 /* Hash may have been set up in inode_init_early */ 1387 /* Hash may have been set up in inode_init_early */
diff --git a/fs/inotify.c b/fs/inotify.c
index 0ee39ef591c6..a61e93e17853 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -38,7 +38,6 @@
38#include <asm/ioctls.h> 38#include <asm/ioctls.h>
39 39
40static atomic_t inotify_cookie; 40static atomic_t inotify_cookie;
41static atomic_t inotify_watches;
42 41
43static kmem_cache_t *watch_cachep; 42static kmem_cache_t *watch_cachep;
44static kmem_cache_t *event_cachep; 43static kmem_cache_t *event_cachep;
@@ -381,6 +380,48 @@ static int find_inode(const char __user *dirname, struct nameidata *nd,
381} 380}
382 381
383/* 382/*
383 * inotify_inode_watched - returns nonzero if there are watches on this inode
384 * and zero otherwise. We call this lockless, we do not care if we race.
385 */
386static inline int inotify_inode_watched(struct inode *inode)
387{
388 return !list_empty(&inode->inotify_watches);
389}
390
391/*
392 * Get child dentry flag into synch with parent inode.
393 * Flag should always be clear for negative dentrys.
394 */
395static void set_dentry_child_flags(struct inode *inode, int watched)
396{
397 struct dentry *alias;
398
399 spin_lock(&dcache_lock);
400 list_for_each_entry(alias, &inode->i_dentry, d_alias) {
401 struct dentry *child;
402
403 list_for_each_entry(child, &alias->d_subdirs, d_u.d_child) {
404 if (!child->d_inode) {
405 WARN_ON(child->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
406 continue;
407 }
408 spin_lock(&child->d_lock);
409 if (watched) {
410 WARN_ON(child->d_flags &
411 DCACHE_INOTIFY_PARENT_WATCHED);
412 child->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
413 } else {
414 WARN_ON(!(child->d_flags &
415 DCACHE_INOTIFY_PARENT_WATCHED));
416 child->d_flags&=~DCACHE_INOTIFY_PARENT_WATCHED;
417 }
418 spin_unlock(&child->d_lock);
419 }
420 }
421 spin_unlock(&dcache_lock);
422}
423
424/*
384 * create_watch - creates a watch on the given device. 425 * create_watch - creates a watch on the given device.
385 * 426 *
386 * Callers must hold dev->mutex. Calls inotify_dev_get_wd() so may sleep. 427 * Callers must hold dev->mutex. Calls inotify_dev_get_wd() so may sleep.
@@ -426,7 +467,6 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
426 get_inotify_watch(watch); 467 get_inotify_watch(watch);
427 468
428 atomic_inc(&dev->user->inotify_watches); 469 atomic_inc(&dev->user->inotify_watches);
429 atomic_inc(&inotify_watches);
430 470
431 return watch; 471 return watch;
432} 472}
@@ -458,8 +498,10 @@ static void remove_watch_no_event(struct inotify_watch *watch,
458 list_del(&watch->i_list); 498 list_del(&watch->i_list);
459 list_del(&watch->d_list); 499 list_del(&watch->d_list);
460 500
501 if (!inotify_inode_watched(watch->inode))
502 set_dentry_child_flags(watch->inode, 0);
503
461 atomic_dec(&dev->user->inotify_watches); 504 atomic_dec(&dev->user->inotify_watches);
462 atomic_dec(&inotify_watches);
463 idr_remove(&dev->idr, watch->wd); 505 idr_remove(&dev->idr, watch->wd);
464 put_inotify_watch(watch); 506 put_inotify_watch(watch);
465} 507}
@@ -481,16 +523,39 @@ static void remove_watch(struct inotify_watch *watch,struct inotify_device *dev)
481 remove_watch_no_event(watch, dev); 523 remove_watch_no_event(watch, dev);
482} 524}
483 525
526/* Kernel API */
527
484/* 528/*
485 * inotify_inode_watched - returns nonzero if there are watches on this inode 529 * inotify_d_instantiate - instantiate dcache entry for inode
486 * and zero otherwise. We call this lockless, we do not care if we race.
487 */ 530 */
488static inline int inotify_inode_watched(struct inode *inode) 531void inotify_d_instantiate(struct dentry *entry, struct inode *inode)
489{ 532{
490 return !list_empty(&inode->inotify_watches); 533 struct dentry *parent;
534
535 if (!inode)
536 return;
537
538 WARN_ON(entry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
539 spin_lock(&entry->d_lock);
540 parent = entry->d_parent;
541 if (inotify_inode_watched(parent->d_inode))
542 entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
543 spin_unlock(&entry->d_lock);
491} 544}
492 545
493/* Kernel API */ 546/*
547 * inotify_d_move - dcache entry has been moved
548 */
549void inotify_d_move(struct dentry *entry)
550{
551 struct dentry *parent;
552
553 parent = entry->d_parent;
554 if (inotify_inode_watched(parent->d_inode))
555 entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
556 else
557 entry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED;
558}
494 559
495/** 560/**
496 * inotify_inode_queue_event - queue an event to all watches on this inode 561 * inotify_inode_queue_event - queue an event to all watches on this inode
@@ -538,7 +603,7 @@ void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
538 struct dentry *parent; 603 struct dentry *parent;
539 struct inode *inode; 604 struct inode *inode;
540 605
541 if (!atomic_read (&inotify_watches)) 606 if (!(dentry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED))
542 return; 607 return;
543 608
544 spin_lock(&dentry->d_lock); 609 spin_lock(&dentry->d_lock);
@@ -993,6 +1058,9 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
993 goto out; 1058 goto out;
994 } 1059 }
995 1060
1061 if (!inotify_inode_watched(inode))
1062 set_dentry_child_flags(inode, 1);
1063
996 /* Add the watch to the device's and the inode's list */ 1064 /* Add the watch to the device's and the inode's list */
997 list_add(&watch->d_list, &dev->watches); 1065 list_add(&watch->d_list, &dev->watches);
998 list_add(&watch->i_list, &inode->inotify_watches); 1066 list_add(&watch->i_list, &inode->inotify_watches);
@@ -1065,7 +1133,6 @@ static int __init inotify_setup(void)
1065 inotify_max_user_watches = 8192; 1133 inotify_max_user_watches = 8192;
1066 1134
1067 atomic_set(&inotify_cookie, 0); 1135 atomic_set(&inotify_cookie, 0);
1068 atomic_set(&inotify_watches, 0);
1069 1136
1070 watch_cachep = kmem_cache_create("inotify_watch_cache", 1137 watch_cachep = kmem_cache_create("inotify_watch_cache",
1071 sizeof(struct inotify_watch), 1138 sizeof(struct inotify_watch),
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 298f08be22d4..70adbb98bad1 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -87,7 +87,8 @@ static int init_inodecache(void)
87{ 87{
88 isofs_inode_cachep = kmem_cache_create("isofs_inode_cache", 88 isofs_inode_cachep = kmem_cache_create("isofs_inode_cache",
89 sizeof(struct iso_inode_info), 89 sizeof(struct iso_inode_info),
90 0, SLAB_RECLAIM_ACCOUNT, 90 0, (SLAB_RECLAIM_ACCOUNT|
91 SLAB_MEM_SPREAD),
91 init_once, NULL); 92 init_once, NULL);
92 if (isofs_inode_cachep == NULL) 93 if (isofs_inode_cachep == NULL)
93 return -ENOMEM; 94 return -ENOMEM;
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 38c75151fc66..439a19b1bf3e 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -178,15 +178,3 @@ extern struct inode_operations isofs_dir_inode_operations;
178extern struct file_operations isofs_dir_operations; 178extern struct file_operations isofs_dir_operations;
179extern struct address_space_operations isofs_symlink_aops; 179extern struct address_space_operations isofs_symlink_aops;
180extern struct export_operations isofs_export_ops; 180extern struct export_operations isofs_export_ops;
181
182/* The following macros are used to check for memory leaks. */
183#ifdef LEAK_CHECK
184#define free_s leak_check_free_s
185#define malloc leak_check_malloc
186#define sb_bread leak_check_bread
187#define brelse leak_check_brelse
188extern void * leak_check_malloc(unsigned int size);
189extern void leak_check_free_s(void * obj, int size);
190extern struct buffer_head * leak_check_bread(struct super_block *sb, int block);
191extern void leak_check_brelse(struct buffer_head * bh);
192#endif /* LEAK_CHECK */
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 95a628d8cac8..7f96b5cb6781 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -33,9 +33,11 @@
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/suspend.h> 34#include <linux/suspend.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/kthread.h>
37#include <linux/proc_fs.h>
38
36#include <asm/uaccess.h> 39#include <asm/uaccess.h>
37#include <asm/page.h> 40#include <asm/page.h>
38#include <linux/proc_fs.h>
39 41
40EXPORT_SYMBOL(journal_start); 42EXPORT_SYMBOL(journal_start);
41EXPORT_SYMBOL(journal_restart); 43EXPORT_SYMBOL(journal_restart);
@@ -111,18 +113,15 @@ static void commit_timeout(unsigned long __data)
111 113
112static int kjournald(void *arg) 114static int kjournald(void *arg)
113{ 115{
114 journal_t *journal = (journal_t *) arg; 116 journal_t *journal = arg;
115 transaction_t *transaction; 117 transaction_t *transaction;
116 struct timer_list timer;
117 118
118 daemonize("kjournald"); 119 /*
119 120 * Set up an interval timer which can be used to trigger a commit wakeup
120 /* Set up an interval timer which can be used to trigger a 121 * after the commit interval expires
121 commit wakeup after the commit interval expires */ 122 */
122 init_timer(&timer); 123 setup_timer(&journal->j_commit_timer, commit_timeout,
123 timer.data = (unsigned long) current; 124 (unsigned long)current);
124 timer.function = commit_timeout;
125 journal->j_commit_timer = &timer;
126 125
127 /* Record that the journal thread is running */ 126 /* Record that the journal thread is running */
128 journal->j_task = current; 127 journal->j_task = current;
@@ -146,7 +145,7 @@ loop:
146 if (journal->j_commit_sequence != journal->j_commit_request) { 145 if (journal->j_commit_sequence != journal->j_commit_request) {
147 jbd_debug(1, "OK, requests differ\n"); 146 jbd_debug(1, "OK, requests differ\n");
148 spin_unlock(&journal->j_state_lock); 147 spin_unlock(&journal->j_state_lock);
149 del_timer_sync(journal->j_commit_timer); 148 del_timer_sync(&journal->j_commit_timer);
150 journal_commit_transaction(journal); 149 journal_commit_transaction(journal);
151 spin_lock(&journal->j_state_lock); 150 spin_lock(&journal->j_state_lock);
152 goto loop; 151 goto loop;
@@ -203,7 +202,7 @@ loop:
203 202
204end_loop: 203end_loop:
205 spin_unlock(&journal->j_state_lock); 204 spin_unlock(&journal->j_state_lock);
206 del_timer_sync(journal->j_commit_timer); 205 del_timer_sync(&journal->j_commit_timer);
207 journal->j_task = NULL; 206 journal->j_task = NULL;
208 wake_up(&journal->j_wait_done_commit); 207 wake_up(&journal->j_wait_done_commit);
209 jbd_debug(1, "Journal thread exiting.\n"); 208 jbd_debug(1, "Journal thread exiting.\n");
@@ -212,7 +211,7 @@ end_loop:
212 211
213static void journal_start_thread(journal_t *journal) 212static void journal_start_thread(journal_t *journal)
214{ 213{
215 kernel_thread(kjournald, journal, CLONE_VM|CLONE_FS|CLONE_FILES); 214 kthread_run(kjournald, journal, "kjournald");
216 wait_event(journal->j_wait_done_commit, journal->j_task != 0); 215 wait_event(journal->j_wait_done_commit, journal->j_task != 0);
217} 216}
218 217
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 5fc40888f4cf..ada31fa272e3 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -53,8 +53,8 @@ get_transaction(journal_t *journal, transaction_t *transaction)
53 spin_lock_init(&transaction->t_handle_lock); 53 spin_lock_init(&transaction->t_handle_lock);
54 54
55 /* Set up the commit timer for the new transaction. */ 55 /* Set up the commit timer for the new transaction. */
56 journal->j_commit_timer->expires = transaction->t_expires; 56 journal->j_commit_timer.expires = transaction->t_expires;
57 add_timer(journal->j_commit_timer); 57 add_timer(&journal->j_commit_timer);
58 58
59 J_ASSERT(journal->j_running_transaction == NULL); 59 J_ASSERT(journal->j_running_transaction == NULL);
60 journal->j_running_transaction = transaction; 60 journal->j_running_transaction = transaction;
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 890d7ff7456d..5a4519e834da 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -1812,15 +1812,17 @@ init_jffs_fs(void)
1812 } 1812 }
1813#endif 1813#endif
1814 fm_cache = kmem_cache_create("jffs_fm", sizeof(struct jffs_fm), 1814 fm_cache = kmem_cache_create("jffs_fm", sizeof(struct jffs_fm),
1815 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 1815 0,
1816 NULL, NULL); 1816 SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
1817 NULL, NULL);
1817 if (!fm_cache) { 1818 if (!fm_cache) {
1818 return -ENOMEM; 1819 return -ENOMEM;
1819 } 1820 }
1820 1821
1821 node_cache = kmem_cache_create("jffs_node",sizeof(struct jffs_node), 1822 node_cache = kmem_cache_create("jffs_node",sizeof(struct jffs_node),
1822 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 1823 0,
1823 NULL, NULL); 1824 SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
1825 NULL, NULL);
1824 if (!node_cache) { 1826 if (!node_cache) {
1825 kmem_cache_destroy(fm_cache); 1827 kmem_cache_destroy(fm_cache);
1826 return -ENOMEM; 1828 return -ENOMEM;
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 93883817cbd0..ffd8e84b22cc 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,
152 sb->s_op = &jffs2_super_operations; 152 sb->s_op = &jffs2_super_operations;
153 sb->s_flags = flags | MS_NOATIME; 153 sb->s_flags = flags | MS_NOATIME;
154 154
155 ret = jffs2_do_fill_super(sb, data, (flags&MS_VERBOSE)?1:0); 155 ret = jffs2_do_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
156 156
157 if (ret) { 157 if (ret) {
158 /* Failure case... */ 158 /* Failure case... */
@@ -257,7 +257,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type,
257 } 257 }
258 258
259 if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) { 259 if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) {
260 if (!(flags & MS_VERBOSE)) /* Yes I mean this. Strangely */ 260 if (!(flags & MS_SILENT))
261 printk(KERN_NOTICE "Attempt to mount non-MTD device \"%s\" as JFFS2\n", 261 printk(KERN_NOTICE "Attempt to mount non-MTD device \"%s\" as JFFS2\n",
262 dev_name); 262 dev_name);
263 goto out; 263 goto out;
@@ -331,7 +331,8 @@ static int __init init_jffs2_fs(void)
331 331
332 jffs2_inode_cachep = kmem_cache_create("jffs2_i", 332 jffs2_inode_cachep = kmem_cache_create("jffs2_i",
333 sizeof(struct jffs2_inode_info), 333 sizeof(struct jffs2_inode_info),
334 0, SLAB_RECLAIM_ACCOUNT, 334 0, (SLAB_RECLAIM_ACCOUNT|
335 SLAB_MEM_SPREAD),
335 jffs2_i_init_once, NULL); 336 jffs2_i_init_once, NULL);
336 if (!jffs2_inode_cachep) { 337 if (!jffs2_inode_cachep) {
337 printk(KERN_ERR "JFFS2 error: Failed to initialise inode cache\n"); 338 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 4caea6b43b92..81f0e514c490 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -111,7 +111,7 @@ static struct {
111 { "loglevel", loglevel_read, loglevel_write } 111 { "loglevel", loglevel_read, loglevel_write }
112#endif 112#endif
113}; 113};
114#define NPROCENT (sizeof(Entries)/sizeof(Entries[0])) 114#define NPROCENT ARRAY_SIZE(Entries)
115 115
116void jfs_proc_init(void) 116void jfs_proc_init(void)
117{ 117{
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 18f69e6aa719..db6f41d6dd60 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -664,7 +664,8 @@ static int __init init_jfs_fs(void)
664 664
665 jfs_inode_cachep = 665 jfs_inode_cachep =
666 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0, 666 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
667 SLAB_RECLAIM_ACCOUNT, init_once, NULL); 667 SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
668 init_once, NULL);
668 if (jfs_inode_cachep == NULL) 669 if (jfs_inode_cachep == NULL)
669 return -ENOMEM; 670 return -ENOMEM;
670 671
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 5dd52b70859a..3fc683f46b3e 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -233,8 +233,8 @@ static struct rpc_procinfo nsm_procedures[] = {
233}; 233};
234 234
235static struct rpc_version nsm_version1 = { 235static struct rpc_version nsm_version1 = {
236 .number = 1, 236 .number = 1,
237 .nrprocs = sizeof(nsm_procedures)/sizeof(nsm_procedures[0]), 237 .nrprocs = ARRAY_SIZE(nsm_procedures),
238 .procs = nsm_procedures 238 .procs = nsm_procedures
239}; 239};
240 240
@@ -247,7 +247,7 @@ static struct rpc_stat nsm_stats;
247static struct rpc_program nsm_program = { 247static struct rpc_program nsm_program = {
248 .name = "statd", 248 .name = "statd",
249 .number = SM_PROGRAM, 249 .number = SM_PROGRAM,
250 .nrvers = sizeof(nsm_version)/sizeof(nsm_version[0]), 250 .nrvers = ARRAY_SIZE(nsm_version),
251 .version = nsm_version, 251 .version = nsm_version,
252 .stats = &nsm_stats 252 .stats = &nsm_stats
253}; 253};
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 71a30b416d1a..5e85bde6c123 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -509,7 +509,7 @@ static struct svc_version * nlmsvc_version[] = {
509 509
510static struct svc_stat nlmsvc_stats; 510static struct svc_stat nlmsvc_stats;
511 511
512#define NLM_NRVERS (sizeof(nlmsvc_version)/sizeof(nlmsvc_version[0])) 512#define NLM_NRVERS ARRAY_SIZE(nlmsvc_version)
513static struct svc_program nlmsvc_program = { 513static struct svc_program nlmsvc_program = {
514 .pg_prog = NLM_PROGRAM, /* program number */ 514 .pg_prog = NLM_PROGRAM, /* program number */
515 .pg_nvers = NLM_NRVERS, /* number of entries in nlmsvc_version */ 515 .pg_nvers = NLM_NRVERS, /* number of entries in nlmsvc_version */
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 766ce06146b5..f22a3764461a 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -604,7 +604,7 @@ static struct rpc_stat nlm_stats;
604struct rpc_program nlm_program = { 604struct rpc_program nlm_program = {
605 .name = "lockd", 605 .name = "lockd",
606 .number = NLM_PROGRAM, 606 .number = NLM_PROGRAM,
607 .nrvers = sizeof(nlm_versions) / sizeof(nlm_versions[0]), 607 .nrvers = ARRAY_SIZE(nlm_versions),
608 .version = nlm_versions, 608 .version = nlm_versions,
609 .stats = &nlm_stats, 609 .stats = &nlm_stats,
610}; 610};
diff --git a/fs/mbcache.c b/fs/mbcache.c
index f5bbe4c97c58..73e754fea2d8 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,
288 INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]); 288 INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]);
289 } 289 }
290 cache->c_entry_cache = kmem_cache_create(name, entry_size, 0, 290 cache->c_entry_cache = kmem_cache_create(name, entry_size, 0,
291 SLAB_RECLAIM_ACCOUNT, NULL, NULL); 291 SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
292 if (!cache->c_entry_cache) 292 if (!cache->c_entry_cache)
293 goto fail; 293 goto fail;
294 294
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index dc6a4e4abcdc..4a6abc49418e 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -56,7 +56,7 @@ void minix_free_block(struct inode * inode, int block)
56 unsigned int bit,zone; 56 unsigned int bit,zone;
57 57
58 if (block < sbi->s_firstdatazone || block >= sbi->s_nzones) { 58 if (block < sbi->s_firstdatazone || block >= sbi->s_nzones) {
59 printk("trying to free block not in datazone\n"); 59 printk("Trying to free block not in datazone\n");
60 return; 60 return;
61 } 61 }
62 zone = block - sbi->s_firstdatazone + 1; 62 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)
124 ino / MINIX_INODES_PER_BLOCK; 124 ino / MINIX_INODES_PER_BLOCK;
125 *bh = sb_bread(sb, block); 125 *bh = sb_bread(sb, block);
126 if (!*bh) { 126 if (!*bh) {
127 printk("unable to read i-node block\n"); 127 printk("Unable to read inode block\n");
128 return NULL; 128 return NULL;
129 } 129 }
130 p = (void *)(*bh)->b_data; 130 p = (void *)(*bh)->b_data;
@@ -149,7 +149,7 @@ minix_V2_raw_inode(struct super_block *sb, ino_t ino, struct buffer_head **bh)
149 ino / MINIX2_INODES_PER_BLOCK; 149 ino / MINIX2_INODES_PER_BLOCK;
150 *bh = sb_bread(sb, block); 150 *bh = sb_bread(sb, block);
151 if (!*bh) { 151 if (!*bh) {
152 printk("unable to read i-node block\n"); 152 printk("Unable to read inode block\n");
153 return NULL; 153 return NULL;
154 } 154 }
155 p = (void *)(*bh)->b_data; 155 p = (void *)(*bh)->b_data;
@@ -204,7 +204,7 @@ void minix_free_inode(struct inode * inode)
204 bh = sbi->s_imap[ino >> 13]; 204 bh = sbi->s_imap[ino >> 13];
205 lock_kernel(); 205 lock_kernel();
206 if (!minix_test_and_clear_bit(ino & 8191, bh->b_data)) 206 if (!minix_test_and_clear_bit(ino & 8191, bh->b_data))
207 printk("minix_free_inode: bit %lu already cleared.\n", ino); 207 printk("minix_free_inode: bit %lu already cleared\n", ino);
208 unlock_kernel(); 208 unlock_kernel();
209 mark_buffer_dirty(bh); 209 mark_buffer_dirty(bh);
210 out: 210 out:
@@ -238,7 +238,7 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)
238 return NULL; 238 return NULL;
239 } 239 }
240 if (minix_test_and_set_bit(j,bh->b_data)) { /* shouldn't happen */ 240 if (minix_test_and_set_bit(j,bh->b_data)) { /* shouldn't happen */
241 printk("new_inode: bit already set"); 241 printk("new_inode: bit already set\n");
242 unlock_kernel(); 242 unlock_kernel();
243 iput(inode); 243 iput(inode);
244 return NULL; 244 return NULL;
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 790cc0d0e970..2dcccf1d1b7f 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -80,7 +80,8 @@ static int init_inodecache(void)
80{ 80{
81 minix_inode_cachep = kmem_cache_create("minix_inode_cache", 81 minix_inode_cachep = kmem_cache_create("minix_inode_cache",
82 sizeof(struct minix_inode_info), 82 sizeof(struct minix_inode_info),
83 0, SLAB_RECLAIM_ACCOUNT, 83 0, (SLAB_RECLAIM_ACCOUNT|
84 SLAB_MEM_SPREAD),
84 init_once, NULL); 85 init_once, NULL);
85 if (minix_inode_cachep == NULL) 86 if (minix_inode_cachep == NULL)
86 return -ENOMEM; 87 return -ENOMEM;
@@ -126,11 +127,11 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
126 mark_buffer_dirty(sbi->s_sbh); 127 mark_buffer_dirty(sbi->s_sbh);
127 128
128 if (!(sbi->s_mount_state & MINIX_VALID_FS)) 129 if (!(sbi->s_mount_state & MINIX_VALID_FS))
129 printk ("MINIX-fs warning: remounting unchecked fs, " 130 printk("MINIX-fs warning: remounting unchecked fs, "
130 "running fsck is recommended.\n"); 131 "running fsck is recommended\n");
131 else if ((sbi->s_mount_state & MINIX_ERROR_FS)) 132 else if ((sbi->s_mount_state & MINIX_ERROR_FS))
132 printk ("MINIX-fs warning: remounting fs with errors, " 133 printk("MINIX-fs warning: remounting fs with errors, "
133 "running fsck is recommended.\n"); 134 "running fsck is recommended\n");
134 } 135 }
135 return 0; 136 return 0;
136} 137}
@@ -244,11 +245,11 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
244 mark_buffer_dirty(bh); 245 mark_buffer_dirty(bh);
245 } 246 }
246 if (!(sbi->s_mount_state & MINIX_VALID_FS)) 247 if (!(sbi->s_mount_state & MINIX_VALID_FS))
247 printk ("MINIX-fs: mounting unchecked file system, " 248 printk("MINIX-fs: mounting unchecked file system, "
248 "running fsck is recommended.\n"); 249 "running fsck is recommended\n");
249 else if (sbi->s_mount_state & MINIX_ERROR_FS) 250 else if (sbi->s_mount_state & MINIX_ERROR_FS)
250 printk ("MINIX-fs: mounting file system with errors, " 251 printk("MINIX-fs: mounting file system with errors, "
251 "running fsck is recommended.\n"); 252 "running fsck is recommended\n");
252 return 0; 253 return 0;
253 254
254out_iput: 255out_iput:
@@ -272,19 +273,19 @@ out_no_bitmap:
272 273
273out_no_map: 274out_no_map:
274 if (!silent) 275 if (!silent)
275 printk ("MINIX-fs: can't allocate map\n"); 276 printk("MINIX-fs: can't allocate map\n");
276 goto out_release; 277 goto out_release;
277 278
278out_no_fs: 279out_no_fs:
279 if (!silent) 280 if (!silent)
280 printk("VFS: Can't find a Minix or Minix V2 filesystem on device " 281 printk("VFS: Can't find a Minix or Minix V2 filesystem "
281 "%s.\n", s->s_id); 282 "on device %s\n", s->s_id);
282 out_release: 283 out_release:
283 brelse(bh); 284 brelse(bh);
284 goto out; 285 goto out;
285 286
286out_bad_hblock: 287out_bad_hblock:
287 printk("MINIX-fs: blocksize too small for device.\n"); 288 printk("MINIX-fs: blocksize too small for device\n");
288 goto out; 289 goto out;
289 290
290out_bad_sb: 291out_bad_sb:
@@ -523,7 +524,7 @@ int minix_sync_inode(struct inode * inode)
523 sync_dirty_buffer(bh); 524 sync_dirty_buffer(bh);
524 if (buffer_req(bh) && !buffer_uptodate(bh)) 525 if (buffer_req(bh) && !buffer_uptodate(bh))
525 { 526 {
526 printk ("IO error syncing minix inode [%s:%08lx]\n", 527 printk("IO error syncing minix inode [%s:%08lx]\n",
527 inode->i_sb->s_id, inode->i_ino); 528 inode->i_sb->s_id, inode->i_ino);
528 err = -1; 529 err = -1;
529 } 530 }
diff --git a/fs/minix/itree_v1.c b/fs/minix/itree_v1.c
index ba06aef4aca1..656b1347a25b 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])
25 int n = 0; 25 int n = 0;
26 26
27 if (block < 0) { 27 if (block < 0) {
28 printk("minix_bmap: block<0"); 28 printk("minix_bmap: block<0\n");
29 } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) { 29 } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
30 printk("minix_bmap: block>big"); 30 printk("minix_bmap: block>big\n");
31 } else if (block < 7) { 31 } else if (block < 7) {
32 offsets[n++] = block; 32 offsets[n++] = block;
33 } else if ((block -= 7) < 512) { 33 } else if ((block -= 7) < 512) {
diff --git a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c
index 3adc7675560f..9adcdc754e0f 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])
25 int n = 0; 25 int n = 0;
26 26
27 if (block < 0) { 27 if (block < 0) {
28 printk("minix_bmap: block<0"); 28 printk("minix_bmap: block<0\n");
29 } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) { 29 } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
30 printk("minix_bmap: block>big"); 30 printk("minix_bmap: block>big\n");
31 } else if (block < 7) { 31 } else if (block < 7) {
32 offsets[n++] = block; 32 offsets[n++] = block;
33 } else if ((block -= 7) < 256) { 33 } else if ((block -= 7) < 256) {
diff --git a/fs/namei.c b/fs/namei.c
index c72b940797fc..712dfc77793b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1628,6 +1628,12 @@ do_last:
1628 goto exit; 1628 goto exit;
1629 } 1629 }
1630 1630
1631 if (IS_ERR(nd->intent.open.file)) {
1632 mutex_unlock(&dir->d_inode->i_mutex);
1633 error = PTR_ERR(nd->intent.open.file);
1634 goto exit_dput;
1635 }
1636
1631 /* Negative dentry, just create the file */ 1637 /* Negative dentry, just create the file */
1632 if (!path.dentry->d_inode) { 1638 if (!path.dentry->d_inode) {
1633 if (!IS_POSIXACL(dir->d_inode)) 1639 if (!IS_POSIXACL(dir->d_inode))
@@ -2621,16 +2627,27 @@ int __page_symlink(struct inode *inode, const char *symname, int len,
2621 int err = -ENOMEM; 2627 int err = -ENOMEM;
2622 char *kaddr; 2628 char *kaddr;
2623 2629
2630retry:
2624 page = find_or_create_page(mapping, 0, gfp_mask); 2631 page = find_or_create_page(mapping, 0, gfp_mask);
2625 if (!page) 2632 if (!page)
2626 goto fail; 2633 goto fail;
2627 err = mapping->a_ops->prepare_write(NULL, page, 0, len-1); 2634 err = mapping->a_ops->prepare_write(NULL, page, 0, len-1);
2635 if (err == AOP_TRUNCATED_PAGE) {
2636 page_cache_release(page);
2637 goto retry;
2638 }
2628 if (err) 2639 if (err)
2629 goto fail_map; 2640 goto fail_map;
2630 kaddr = kmap_atomic(page, KM_USER0); 2641 kaddr = kmap_atomic(page, KM_USER0);
2631 memcpy(kaddr, symname, len-1); 2642 memcpy(kaddr, symname, len-1);
2632 kunmap_atomic(kaddr, KM_USER0); 2643 kunmap_atomic(kaddr, KM_USER0);
2633 mapping->a_ops->commit_write(NULL, page, 0, len-1); 2644 err = mapping->a_ops->commit_write(NULL, page, 0, len-1);
2645 if (err == AOP_TRUNCATED_PAGE) {
2646 page_cache_release(page);
2647 goto retry;
2648 }
2649 if (err)
2650 goto fail_map;
2634 /* 2651 /*
2635 * Notice that we are _not_ going to block here - end of page is 2652 * Notice that we are _not_ going to block here - end of page is
2636 * unmapped, so this will only try to map the rest of page, see 2653 * 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,
2640 */ 2657 */
2641 if (!PageUptodate(page)) { 2658 if (!PageUptodate(page)) {
2642 err = mapping->a_ops->readpage(NULL, page); 2659 err = mapping->a_ops->readpage(NULL, page);
2643 wait_on_page_locked(page); 2660 if (err != AOP_TRUNCATED_PAGE)
2661 wait_on_page_locked(page);
2644 } else { 2662 } else {
2645 unlock_page(page); 2663 unlock_page(page);
2646 } 2664 }
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 0b521d3d97ce..a1f3e972c6ef 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -72,7 +72,8 @@ static int init_inodecache(void)
72{ 72{
73 ncp_inode_cachep = kmem_cache_create("ncp_inode_cache", 73 ncp_inode_cachep = kmem_cache_create("ncp_inode_cache",
74 sizeof(struct ncp_inode_info), 74 sizeof(struct ncp_inode_info),
75 0, SLAB_RECLAIM_ACCOUNT, 75 0, (SLAB_RECLAIM_ACCOUNT|
76 SLAB_MEM_SPREAD),
76 init_once, NULL); 77 init_once, NULL);
77 if (ncp_inode_cachep == NULL) 78 if (ncp_inode_cachep == NULL)
78 return -ENOMEM; 79 return -ENOMEM;
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index cbef57a16ffb..0f583cb16ddb 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -898,7 +898,8 @@ int nfs_init_directcache(void)
898{ 898{
899 nfs_direct_cachep = kmem_cache_create("nfs_direct_cache", 899 nfs_direct_cachep = kmem_cache_create("nfs_direct_cache",
900 sizeof(struct nfs_direct_req), 900 sizeof(struct nfs_direct_req),
901 0, SLAB_RECLAIM_ACCOUNT, 901 0, (SLAB_RECLAIM_ACCOUNT|
902 SLAB_MEM_SPREAD),
902 NULL, NULL); 903 NULL, NULL);
903 if (nfs_direct_cachep == NULL) 904 if (nfs_direct_cachep == NULL)
904 return -ENOMEM; 905 return -ENOMEM;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 60aac58270a8..2f7656b911b6 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -107,7 +107,7 @@ static struct rpc_version * nfs_version[] = {
107static struct rpc_program nfs_program = { 107static struct rpc_program nfs_program = {
108 .name = "nfs", 108 .name = "nfs",
109 .number = NFS_PROGRAM, 109 .number = NFS_PROGRAM,
110 .nrvers = sizeof(nfs_version) / sizeof(nfs_version[0]), 110 .nrvers = ARRAY_SIZE(nfs_version),
111 .version = nfs_version, 111 .version = nfs_version,
112 .stats = &nfs_rpcstat, 112 .stats = &nfs_rpcstat,
113 .pipe_dir_name = "/nfs", 113 .pipe_dir_name = "/nfs",
@@ -122,7 +122,7 @@ static struct rpc_version * nfsacl_version[] = {
122struct rpc_program nfsacl_program = { 122struct rpc_program nfsacl_program = {
123 .name = "nfsacl", 123 .name = "nfsacl",
124 .number = NFS_ACL_PROGRAM, 124 .number = NFS_ACL_PROGRAM,
125 .nrvers = sizeof(nfsacl_version) / sizeof(nfsacl_version[0]), 125 .nrvers = ARRAY_SIZE(nfsacl_version),
126 .version = nfsacl_version, 126 .version = nfsacl_version,
127 .stats = &nfsacl_rpcstat, 127 .stats = &nfsacl_rpcstat,
128}; 128};
@@ -1786,7 +1786,7 @@ static struct super_block *nfs_get_sb(struct file_system_type *fs_type,
1786 1786
1787 s->s_flags = flags; 1787 s->s_flags = flags;
1788 1788
1789 error = nfs_fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); 1789 error = nfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
1790 if (error) { 1790 if (error) {
1791 up_write(&s->s_umount); 1791 up_write(&s->s_umount);
1792 deactivate_super(s); 1792 deactivate_super(s);
@@ -2107,7 +2107,7 @@ static struct super_block *nfs4_get_sb(struct file_system_type *fs_type,
2107 2107
2108 s->s_flags = flags; 2108 s->s_flags = flags;
2109 2109
2110 error = nfs4_fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); 2110 error = nfs4_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
2111 if (error) { 2111 if (error) {
2112 up_write(&s->s_umount); 2112 up_write(&s->s_umount);
2113 deactivate_super(s); 2113 deactivate_super(s);
@@ -2276,7 +2276,8 @@ static int nfs_init_inodecache(void)
2276{ 2276{
2277 nfs_inode_cachep = kmem_cache_create("nfs_inode_cache", 2277 nfs_inode_cachep = kmem_cache_create("nfs_inode_cache",
2278 sizeof(struct nfs_inode), 2278 sizeof(struct nfs_inode),
2279 0, SLAB_RECLAIM_ACCOUNT, 2279 0, (SLAB_RECLAIM_ACCOUNT|
2280 SLAB_MEM_SPREAD),
2280 init_once, NULL); 2281 init_once, NULL);
2281 if (nfs_inode_cachep == NULL) 2282 if (nfs_inode_cachep == NULL)
2282 return -ENOMEM; 2283 return -ENOMEM;
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index c44d87bdddb3..445abb4d4214 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -185,7 +185,7 @@ static struct rpc_stat mnt_stats;
185static struct rpc_program mnt_program = { 185static struct rpc_program mnt_program = {
186 .name = "mount", 186 .name = "mount",
187 .number = NFS_MNT_PROGRAM, 187 .number = NFS_MNT_PROGRAM,
188 .nrvers = sizeof(mnt_version)/sizeof(mnt_version[0]), 188 .nrvers = ARRAY_SIZE(mnt_version),
189 .version = mnt_version, 189 .version = mnt_version,
190 .stats = &mnt_stats, 190 .stats = &mnt_stats,
191}; 191};
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 8cdc792ff3c7..f0015fa876e1 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -706,6 +706,6 @@ struct rpc_procinfo nfs_procedures[] = {
706 706
707struct rpc_version nfs_version2 = { 707struct rpc_version nfs_version2 = {
708 .number = 2, 708 .number = 2,
709 .nrprocs = sizeof(nfs_procedures)/sizeof(nfs_procedures[0]), 709 .nrprocs = ARRAY_SIZE(nfs_procedures),
710 .procs = nfs_procedures 710 .procs = nfs_procedures
711}; 711};
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 2d8701a230f0..ec233619687e 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1140,7 +1140,7 @@ struct rpc_procinfo nfs3_procedures[] = {
1140 1140
1141struct rpc_version nfs_version3 = { 1141struct rpc_version nfs_version3 = {
1142 .number = 3, 1142 .number = 3,
1143 .nrprocs = sizeof(nfs3_procedures)/sizeof(nfs3_procedures[0]), 1143 .nrprocs = ARRAY_SIZE(nfs3_procedures),
1144 .procs = nfs3_procedures 1144 .procs = nfs3_procedures
1145}; 1145};
1146 1146
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index b95675349ba3..7c5d70efe720 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4386,7 +4386,7 @@ struct rpc_procinfo nfs4_procedures[] = {
4386 4386
4387struct rpc_version nfs_version4 = { 4387struct rpc_version nfs_version4 = {
4388 .number = 4, 4388 .number = 4,
4389 .nrprocs = sizeof(nfs4_procedures)/sizeof(nfs4_procedures[0]), 4389 .nrprocs = ARRAY_SIZE(nfs4_procedures),
4390 .procs = nfs4_procedures 4390 .procs = nfs4_procedures
4391}; 4391};
4392 4392
diff --git a/fs/nfsctl.c b/fs/nfsctl.c
index 1c72c7f85ddc..a5a18d4aca40 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
101 if (version != NFSCTL_VERSION) 101 if (version != NFSCTL_VERSION)
102 return -EINVAL; 102 return -EINVAL;
103 103
104 if (cmd < 0 || cmd >= sizeof(map)/sizeof(map[0]) || !map[cmd].name) 104 if (cmd < 0 || cmd >= ARRAY_SIZE(map) || !map[cmd].name)
105 return -EINVAL; 105 return -EINVAL;
106 106
107 file = do_open(map[cmd].name, map[cmd].rsize ? O_RDWR : O_WRONLY); 107 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 4a2105552ac4..7391f4aabedb 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -907,7 +907,7 @@ nfs4_acl_get_whotype(char *p, u32 len)
907{ 907{
908 int i; 908 int i;
909 909
910 for (i=0; i < sizeof(s2t_map) / sizeof(*s2t_map); i++) { 910 for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
911 if (s2t_map[i].stringlen == len && 911 if (s2t_map[i].stringlen == len &&
912 0 == memcmp(s2t_map[i].string, p, len)) 912 0 == memcmp(s2t_map[i].string, p, len))
913 return s2t_map[i].type; 913 return s2t_map[i].type;
@@ -920,7 +920,7 @@ nfs4_acl_write_who(int who, char *p)
920{ 920{
921 int i; 921 int i;
922 922
923 for (i=0; i < sizeof(s2t_map) / sizeof(*s2t_map); i++) { 923 for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
924 if (s2t_map[i].type == who) { 924 if (s2t_map[i].type == who) {
925 memcpy(p, s2t_map[i].string, s2t_map[i].stringlen); 925 memcpy(p, s2t_map[i].string, s2t_map[i].stringlen);
926 return s2t_map[i].stringlen; 926 return s2t_map[i].stringlen;
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 4f391cbf2fd1..c872bd07fc10 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -337,7 +337,7 @@ static struct rpc_procinfo nfs4_cb_procedures[] = {
337 337
338static struct rpc_version nfs_cb_version4 = { 338static struct rpc_version nfs_cb_version4 = {
339 .number = 1, 339 .number = 1,
340 .nrprocs = sizeof(nfs4_cb_procedures)/sizeof(nfs4_cb_procedures[0]), 340 .nrprocs = ARRAY_SIZE(nfs4_cb_procedures),
341 .procs = nfs4_cb_procedures 341 .procs = nfs4_cb_procedures
342}; 342};
343 343
@@ -413,7 +413,7 @@ nfsd4_probe_callback(struct nfs4_client *clp)
413 /* Initialize rpc_program */ 413 /* Initialize rpc_program */
414 program->name = "nfs4_cb"; 414 program->name = "nfs4_cb";
415 program->number = cb->cb_prog; 415 program->number = cb->cb_prog;
416 program->nrvers = sizeof(nfs_cb_version)/sizeof(nfs_cb_version[0]); 416 program->nrvers = ARRAY_SIZE(nfs_cb_version);
417 program->version = nfs_cb_version; 417 program->version = nfs_cb_version;
418 program->stats = stat; 418 program->stats = stat;
419 419
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 69d3501173a8..03857fd81126 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -992,7 +992,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
992 if (argp->opcnt > 100) 992 if (argp->opcnt > 100)
993 goto xdr_error; 993 goto xdr_error;
994 994
995 if (argp->opcnt > sizeof(argp->iops)/sizeof(argp->iops[0])) { 995 if (argp->opcnt > ARRAY_SIZE(argp->iops)) {
996 argp->ops = kmalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); 996 argp->ops = kmalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL);
997 if (!argp->ops) { 997 if (!argp->ops) {
998 argp->ops = argp->iops; 998 argp->ops = argp->iops;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index a0871b3efeb7..c8960aff0968 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
105 char *data; 105 char *data;
106 ssize_t rv; 106 ssize_t rv;
107 107
108 if (ino >= sizeof(write_op)/sizeof(write_op[0]) || !write_op[ino]) 108 if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
109 return -EINVAL; 109 return -EINVAL;
110 110
111 data = simple_transaction_get(file, buf, size); 111 data = simple_transaction_get(file, buf, size);
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 1d163b616915..3790727e5dfd 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -72,7 +72,7 @@ static struct svc_version * nfsd_acl_version[] = {
72}; 72};
73 73
74#define NFSD_ACL_MINVERS 2 74#define NFSD_ACL_MINVERS 2
75#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0])) 75#define NFSD_ACL_NRVERS ARRAY_SIZE(nfsd_acl_version)
76static struct svc_version *nfsd_acl_versions[NFSD_ACL_NRVERS]; 76static struct svc_version *nfsd_acl_versions[NFSD_ACL_NRVERS];
77 77
78static struct svc_program nfsd_acl_program = { 78static struct svc_program nfsd_acl_program = {
@@ -101,7 +101,7 @@ static struct svc_version * nfsd_version[] = {
101}; 101};
102 102
103#define NFSD_MINVERS 2 103#define NFSD_MINVERS 2
104#define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0])) 104#define NFSD_NRVERS ARRAY_SIZE(nfsd_version)
105static struct svc_version *nfsd_versions[NFSD_NRVERS]; 105static struct svc_version *nfsd_versions[NFSD_NRVERS];
106 106
107struct svc_program nfsd_program = { 107struct svc_program nfsd_program = {
diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
index 80f108ae6661..06640c3e4021 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] = {
268 {0xFC, 0x4B}, 268 {0xFC, 0x4B},
269}; 269};
270 270
271#define MAP_ELEMENT_OF(map) (sizeof(map) / sizeof(map[0]))
272
273static inline int sjisibm2euc(unsigned char *euc, const unsigned char sjis_hi, 271static inline int sjisibm2euc(unsigned char *euc, const unsigned char sjis_hi,
274 const unsigned char sjis_lo); 272 const unsigned char sjis_lo);
275static inline int euc2sjisibm_jisx0212(unsigned char *sjis, const unsigned char euc_hi, 273static 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
310 unsigned short euc; 308 unsigned short euc;
311 309
312 min_index = 0; 310 min_index = 0;
313 max_index = MAP_ELEMENT_OF(euc2sjisibm_jisx0212_map) - 1; 311 max_index = ARRAY_SIZE(euc2sjisibm_jisx0212_map) - 1;
314 euc = (euc_hi << 8) | euc_lo; 312 euc = (euc_hi << 8) | euc_lo;
315 313
316 while (min_index <= max_index) { 314 while (min_index <= max_index) {
@@ -339,7 +337,7 @@ static inline int euc2sjisibm_g3upper(unsigned char *sjis, const unsigned char e
339 else 337 else
340 index = ((euc_hi << 8) | euc_lo) - 0xF4A1 + 12; 338 index = ((euc_hi << 8) | euc_lo) - 0xF4A1 + 12;
341 339
342 if ((index < 0) || (index >= MAP_ELEMENT_OF(euc2sjisibm_g3upper_map))) 340 if ((index < 0) || (index >= ARRAY_SIZE(euc2sjisibm_g3upper_map)))
343 return 0; 341 return 0;
344 342
345 sjis[0] = euc2sjisibm_g3upper_map[index][0]; 343 sjis[0] = euc2sjisibm_g3upper_map[index][0];
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 7646b5059389..27833f6df49f 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3163,7 +3163,7 @@ static int __init init_ntfs_fs(void)
3163 3163
3164 ntfs_inode_cache = kmem_cache_create(ntfs_inode_cache_name, 3164 ntfs_inode_cache = kmem_cache_create(ntfs_inode_cache_name,
3165 sizeof(ntfs_inode), 0, 3165 sizeof(ntfs_inode), 0,
3166 SLAB_RECLAIM_ACCOUNT, NULL, NULL); 3166 SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
3167 if (!ntfs_inode_cache) { 3167 if (!ntfs_inode_cache) {
3168 printk(KERN_CRIT "NTFS: Failed to create %s!\n", 3168 printk(KERN_CRIT "NTFS: Failed to create %s!\n",
3169 ntfs_inode_cache_name); 3169 ntfs_inode_cache_name);
@@ -3172,7 +3172,7 @@ static int __init init_ntfs_fs(void)
3172 3172
3173 ntfs_big_inode_cache = kmem_cache_create(ntfs_big_inode_cache_name, 3173 ntfs_big_inode_cache = kmem_cache_create(ntfs_big_inode_cache_name,
3174 sizeof(big_ntfs_inode), 0, 3174 sizeof(big_ntfs_inode), 0,
3175 SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 3175 SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
3176 ntfs_big_inode_init_once, NULL); 3176 ntfs_big_inode_init_once, NULL);
3177 if (!ntfs_big_inode_cache) { 3177 if (!ntfs_big_inode_cache) {
3178 printk(KERN_CRIT "NTFS: Failed to create %s!\n", 3178 printk(KERN_CRIT "NTFS: Failed to create %s!\n",
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 6b9812db3779..edaab05a93e0 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -566,9 +566,8 @@ static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
566 next_free = le16_to_cpu(el->l_next_free_rec); 566 next_free = le16_to_cpu(el->l_next_free_rec);
567 if (next_free == 0) { 567 if (next_free == 0) {
568 ocfs2_error(inode->i_sb, 568 ocfs2_error(inode->i_sb,
569 "Dinode %"MLFu64" has a bad " 569 "Dinode %llu has a bad extent list",
570 "extent list", 570 (unsigned long long)OCFS2_I(inode)->ip_blkno);
571 OCFS2_I(inode)->ip_blkno);
572 status = -EIO; 571 status = -EIO;
573 goto bail; 572 goto bail;
574 } 573 }
@@ -611,9 +610,8 @@ static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
611 next_free = le16_to_cpu(el->l_next_free_rec); 610 next_free = le16_to_cpu(el->l_next_free_rec);
612 if (next_free == 0) { 611 if (next_free == 0) {
613 ocfs2_error(inode->i_sb, 612 ocfs2_error(inode->i_sb,
614 "Dinode %"MLFu64" has a bad " 613 "Dinode %llu has a bad extent list",
615 "extent list", 614 (unsigned long long)OCFS2_I(inode)->ip_blkno);
616 OCFS2_I(inode)->ip_blkno);
617 status = -EIO; 615 status = -EIO;
618 goto bail; 616 goto bail;
619 } 617 }
@@ -652,8 +650,9 @@ static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
652 /* having an empty extent at eof is legal. */ 650 /* having an empty extent at eof is legal. */
653 if (el->l_recs[i].e_cpos != fe->i_clusters) { 651 if (el->l_recs[i].e_cpos != fe->i_clusters) {
654 ocfs2_error(inode->i_sb, 652 ocfs2_error(inode->i_sb,
655 "Dinode %"MLFu64" trailing extent is bad: " 653 "Dinode %llu trailing extent is bad: "
656 "cpos (%u) != number of clusters (%u)", 654 "cpos (%u) != number of clusters (%u)",
655 (unsigned long long)OCFS2_I(inode)->ip_blkno,
657 le32_to_cpu(el->l_recs[i].e_cpos), 656 le32_to_cpu(el->l_recs[i].e_cpos),
658 le32_to_cpu(fe->i_clusters)); 657 le32_to_cpu(fe->i_clusters));
659 status = -EIO; 658 status = -EIO;
@@ -747,19 +746,19 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
747 746
748 while(le16_to_cpu(el->l_tree_depth) > 1) { 747 while(le16_to_cpu(el->l_tree_depth) > 1) {
749 if (le16_to_cpu(el->l_next_free_rec) == 0) { 748 if (le16_to_cpu(el->l_next_free_rec) == 0) {
750 ocfs2_error(inode->i_sb, "Dinode %"MLFu64" has empty " 749 ocfs2_error(inode->i_sb, "Dinode %llu has empty "
751 "extent list (next_free_rec == 0)", 750 "extent list (next_free_rec == 0)",
752 OCFS2_I(inode)->ip_blkno); 751 (unsigned long long)OCFS2_I(inode)->ip_blkno);
753 status = -EIO; 752 status = -EIO;
754 goto bail; 753 goto bail;
755 } 754 }
756 i = le16_to_cpu(el->l_next_free_rec) - 1; 755 i = le16_to_cpu(el->l_next_free_rec) - 1;
757 blkno = le64_to_cpu(el->l_recs[i].e_blkno); 756 blkno = le64_to_cpu(el->l_recs[i].e_blkno);
758 if (!blkno) { 757 if (!blkno) {
759 ocfs2_error(inode->i_sb, "Dinode %"MLFu64" has extent " 758 ocfs2_error(inode->i_sb, "Dinode %llu has extent "
760 "list where extent # %d has no physical " 759 "list where extent # %d has no physical "
761 "block start", 760 "block start",
762 OCFS2_I(inode)->ip_blkno, i); 761 (unsigned long long)OCFS2_I(inode)->ip_blkno, i);
763 status = -EIO; 762 status = -EIO;
764 goto bail; 763 goto bail;
765 } 764 }
@@ -826,9 +825,9 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
826 825
827 mlog_entry_void(); 826 mlog_entry_void();
828 827
829 mlog(0, "add %u clusters starting at block %"MLFu64" to " 828 mlog(0, "add %u clusters starting at block %llu to inode %llu\n",
830 "inode %"MLFu64"\n", 829 new_clusters, (unsigned long long)start_blk,
831 new_clusters, start_blk, OCFS2_I(inode)->ip_blkno); 830 (unsigned long long)OCFS2_I(inode)->ip_blkno);
832 831
833 fe = (struct ocfs2_dinode *) fe_bh->b_data; 832 fe = (struct ocfs2_dinode *) fe_bh->b_data;
834 el = &fe->id2.i_list; 833 el = &fe->id2.i_list;
@@ -963,8 +962,8 @@ static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
963 struct ocfs2_dinode *di; 962 struct ocfs2_dinode *di;
964 struct ocfs2_truncate_log *tl; 963 struct ocfs2_truncate_log *tl;
965 964
966 mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk, 965 mlog_entry("start_blk = %llu, num_clusters = %u\n",
967 num_clusters); 966 (unsigned long long)start_blk, num_clusters);
968 967
969 BUG_ON(mutex_trylock(&tl_inode->i_mutex)); 968 BUG_ON(mutex_trylock(&tl_inode->i_mutex));
970 969
@@ -981,8 +980,9 @@ static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
981 tl_count = le16_to_cpu(tl->tl_count); 980 tl_count = le16_to_cpu(tl->tl_count);
982 mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) || 981 mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) ||
983 tl_count == 0, 982 tl_count == 0,
984 "Truncate record count on #%"MLFu64" invalid (" 983 "Truncate record count on #%llu invalid "
985 "wanted %u, actual %u\n", OCFS2_I(tl_inode)->ip_blkno, 984 "wanted %u, actual %u\n",
985 (unsigned long long)OCFS2_I(tl_inode)->ip_blkno,
986 ocfs2_truncate_recs_per_inode(osb->sb), 986 ocfs2_truncate_recs_per_inode(osb->sb),
987 le16_to_cpu(tl->tl_count)); 987 le16_to_cpu(tl->tl_count));
988 988
@@ -1002,8 +1002,8 @@ static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
1002 } 1002 }
1003 1003
1004 mlog(0, "Log truncate of %u clusters starting at cluster %u to " 1004 mlog(0, "Log truncate of %u clusters starting at cluster %u to "
1005 "%"MLFu64" (index = %d)\n", num_clusters, start_cluster, 1005 "%llu (index = %d)\n", num_clusters, start_cluster,
1006 OCFS2_I(tl_inode)->ip_blkno, index); 1006 (unsigned long long)OCFS2_I(tl_inode)->ip_blkno, index);
1007 1007
1008 if (ocfs2_truncate_log_can_coalesce(tl, start_cluster)) { 1008 if (ocfs2_truncate_log_can_coalesce(tl, start_cluster)) {
1009 /* 1009 /*
@@ -1134,8 +1134,8 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1134 } 1134 }
1135 1135
1136 num_to_flush = le16_to_cpu(tl->tl_used); 1136 num_to_flush = le16_to_cpu(tl->tl_used);
1137 mlog(0, "Flush %u records from truncate log #%"MLFu64"\n", 1137 mlog(0, "Flush %u records from truncate log #%llu\n",
1138 num_to_flush, OCFS2_I(tl_inode)->ip_blkno); 1138 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno);
1139 if (!num_to_flush) { 1139 if (!num_to_flush) {
1140 status = 0; 1140 status = 0;
1141 goto bail; 1141 goto bail;
@@ -1360,8 +1360,8 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1360 1360
1361 tl = &tl_copy->id2.i_dealloc; 1361 tl = &tl_copy->id2.i_dealloc;
1362 num_recs = le16_to_cpu(tl->tl_used); 1362 num_recs = le16_to_cpu(tl->tl_used);
1363 mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs, 1363 mlog(0, "cleanup %u records from %llu\n", num_recs,
1364 tl_copy->i_blkno); 1364 (unsigned long long)tl_copy->i_blkno);
1365 1365
1366 mutex_lock(&tl_inode->i_mutex); 1366 mutex_lock(&tl_inode->i_mutex);
1367 for(i = 0; i < num_recs; i++) { 1367 for(i = 0; i < num_recs; i++) {
@@ -1529,7 +1529,8 @@ static int ocfs2_find_new_last_ext_blk(struct ocfs2_super *osb,
1529 1529
1530 *new_last_eb = bh; 1530 *new_last_eb = bh;
1531 get_bh(*new_last_eb); 1531 get_bh(*new_last_eb);
1532 mlog(0, "returning block %"MLFu64"\n", le64_to_cpu(eb->h_blkno)); 1532 mlog(0, "returning block %llu\n",
1533 (unsigned long long)le64_to_cpu(eb->h_blkno));
1533bail: 1534bail:
1534 if (bh) 1535 if (bh)
1535 brelse(bh); 1536 brelse(bh);
@@ -1646,8 +1647,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
1646 1647
1647 /* if our tree depth > 0, update all the tree blocks below us. */ 1648 /* if our tree depth > 0, update all the tree blocks below us. */
1648 while (depth) { 1649 while (depth) {
1649 mlog(0, "traveling tree (depth = %d, next_eb = %"MLFu64")\n", 1650 mlog(0, "traveling tree (depth = %d, next_eb = %llu)\n",
1650 depth, next_eb); 1651 depth, (unsigned long long)next_eb);
1651 status = ocfs2_read_block(osb, next_eb, &eb_bh, 1652 status = ocfs2_read_block(osb, next_eb, &eb_bh,
1652 OCFS2_BH_CACHED, inode); 1653 OCFS2_BH_CACHED, inode);
1653 if (status < 0) { 1654 if (status < 0) {
@@ -1674,12 +1675,12 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
1674 1675
1675 i = le16_to_cpu(el->l_next_free_rec) - 1; 1676 i = le16_to_cpu(el->l_next_free_rec) - 1;
1676 1677
1677 mlog(0, "extent block %"MLFu64", before: record %d: " 1678 mlog(0, "extent block %llu, before: record %d: "
1678 "(%u, %u, %"MLFu64"), next = %u\n", 1679 "(%u, %u, %llu), next = %u\n",
1679 le64_to_cpu(eb->h_blkno), i, 1680 (unsigned long long)le64_to_cpu(eb->h_blkno), i,
1680 le32_to_cpu(el->l_recs[i].e_cpos), 1681 le32_to_cpu(el->l_recs[i].e_cpos),
1681 le32_to_cpu(el->l_recs[i].e_clusters), 1682 le32_to_cpu(el->l_recs[i].e_clusters),
1682 le64_to_cpu(el->l_recs[i].e_blkno), 1683 (unsigned long long)le64_to_cpu(el->l_recs[i].e_blkno),
1683 le16_to_cpu(el->l_next_free_rec)); 1684 le16_to_cpu(el->l_next_free_rec));
1684 1685
1685 BUG_ON(le32_to_cpu(el->l_recs[i].e_clusters) < clusters_to_del); 1686 BUG_ON(le32_to_cpu(el->l_recs[i].e_clusters) < clusters_to_del);
@@ -1697,12 +1698,12 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
1697 BUG_ON(!el->l_next_free_rec); 1698 BUG_ON(!el->l_next_free_rec);
1698 le16_add_cpu(&el->l_next_free_rec, -1); 1699 le16_add_cpu(&el->l_next_free_rec, -1);
1699 } 1700 }
1700 mlog(0, "extent block %"MLFu64", after: record %d: " 1701 mlog(0, "extent block %llu, after: record %d: "
1701 "(%u, %u, %"MLFu64"), next = %u\n", 1702 "(%u, %u, %llu), next = %u\n",
1702 le64_to_cpu(eb->h_blkno), i, 1703 (unsigned long long)le64_to_cpu(eb->h_blkno), i,
1703 le32_to_cpu(el->l_recs[i].e_cpos), 1704 le32_to_cpu(el->l_recs[i].e_cpos),
1704 le32_to_cpu(el->l_recs[i].e_clusters), 1705 le32_to_cpu(el->l_recs[i].e_clusters),
1705 le64_to_cpu(el->l_recs[i].e_blkno), 1706 (unsigned long long)le64_to_cpu(el->l_recs[i].e_blkno),
1706 le16_to_cpu(el->l_next_free_rec)); 1707 le16_to_cpu(el->l_next_free_rec));
1707 1708
1708 status = ocfs2_journal_dirty(handle, eb_bh); 1709 status = ocfs2_journal_dirty(handle, eb_bh);
@@ -1792,10 +1793,10 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
1792 last_eb = le64_to_cpu(fe->i_last_eb_blk); 1793 last_eb = le64_to_cpu(fe->i_last_eb_blk);
1793start: 1794start:
1794 mlog(0, "ocfs2_commit_truncate: fe->i_clusters = %u, " 1795 mlog(0, "ocfs2_commit_truncate: fe->i_clusters = %u, "
1795 "last_eb = %"MLFu64", fe->i_last_eb_blk = %"MLFu64", " 1796 "last_eb = %llu, fe->i_last_eb_blk = %llu, "
1796 "fe->id2.i_list.l_tree_depth = %u last_eb_bh = %p\n", 1797 "fe->id2.i_list.l_tree_depth = %u last_eb_bh = %p\n",
1797 le32_to_cpu(fe->i_clusters), last_eb, 1798 le32_to_cpu(fe->i_clusters), (unsigned long long)last_eb,
1798 le64_to_cpu(fe->i_last_eb_blk), 1799 (unsigned long long)le64_to_cpu(fe->i_last_eb_blk),
1799 le16_to_cpu(fe->id2.i_list.l_tree_depth), last_eb_bh); 1800 le16_to_cpu(fe->id2.i_list.l_tree_depth), last_eb_bh);
1800 1801
1801 if (last_eb != le64_to_cpu(fe->i_last_eb_blk)) { 1802 if (last_eb != le64_to_cpu(fe->i_last_eb_blk)) {
@@ -1934,16 +1935,17 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
1934 fe = (struct ocfs2_dinode *) fe_bh->b_data; 1935 fe = (struct ocfs2_dinode *) fe_bh->b_data;
1935 1936
1936 mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size =" 1937 mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size ="
1937 "%"MLFu64"\n", fe->i_clusters, new_i_clusters, fe->i_size); 1938 "%llu\n", fe->i_clusters, new_i_clusters,
1939 (unsigned long long)fe->i_size);
1938 1940
1939 if (le32_to_cpu(fe->i_clusters) <= new_i_clusters) { 1941 if (le32_to_cpu(fe->i_clusters) <= new_i_clusters) {
1940 ocfs2_error(inode->i_sb, "Dinode %"MLFu64" has cluster count " 1942 ocfs2_error(inode->i_sb, "Dinode %llu has cluster count "
1941 "%u and size %"MLFu64" whereas struct inode has " 1943 "%u and size %llu whereas struct inode has "
1942 "cluster count %u and size %llu which caused an " 1944 "cluster count %u and size %llu which caused an "
1943 "invalid truncate to %u clusters.", 1945 "invalid truncate to %u clusters.",
1944 le64_to_cpu(fe->i_blkno), 1946 (unsigned long long)le64_to_cpu(fe->i_blkno),
1945 le32_to_cpu(fe->i_clusters), 1947 le32_to_cpu(fe->i_clusters),
1946 le64_to_cpu(fe->i_size), 1948 (unsigned long long)le64_to_cpu(fe->i_size),
1947 OCFS2_I(inode)->ip_clusters, i_size_read(inode), 1949 OCFS2_I(inode)->ip_clusters, i_size_read(inode),
1948 new_i_clusters); 1950 new_i_clusters);
1949 mlog_meta_lvb(ML_ERROR, &OCFS2_I(inode)->ip_meta_lockres); 1951 mlog_meta_lvb(ML_ERROR, &OCFS2_I(inode)->ip_meta_lockres);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 8f4467a930a5..bf931ba1d364 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -74,8 +74,8 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
74 fe = (struct ocfs2_dinode *) bh->b_data; 74 fe = (struct ocfs2_dinode *) bh->b_data;
75 75
76 if (!OCFS2_IS_VALID_DINODE(fe)) { 76 if (!OCFS2_IS_VALID_DINODE(fe)) {
77 mlog(ML_ERROR, "Invalid dinode #%"MLFu64": signature = %.*s\n", 77 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
78 fe->i_blkno, 7, fe->i_signature); 78 (unsigned long long)fe->i_blkno, 7, fe->i_signature);
79 goto bail; 79 goto bail;
80 } 80 }
81 81
@@ -162,8 +162,8 @@ static int ocfs2_get_block(struct inode *inode, sector_t iblock,
162 NULL); 162 NULL);
163 if (err) { 163 if (err) {
164 mlog(ML_ERROR, "Error %d from get_blocks(0x%p, %llu, 1, " 164 mlog(ML_ERROR, "Error %d from get_blocks(0x%p, %llu, 1, "
165 "%"MLFu64", NULL)\n", err, inode, 165 "%llu, NULL)\n", err, inode, (unsigned long long)iblock,
166 (unsigned long long)iblock, p_blkno); 166 (unsigned long long)p_blkno);
167 goto bail; 167 goto bail;
168 } 168 }
169 169
@@ -171,13 +171,15 @@ static int ocfs2_get_block(struct inode *inode, sector_t iblock,
171 171
172 if (bh_result->b_blocknr == 0) { 172 if (bh_result->b_blocknr == 0) {
173 err = -EIO; 173 err = -EIO;
174 mlog(ML_ERROR, "iblock = %llu p_blkno = %"MLFu64" " 174 mlog(ML_ERROR, "iblock = %llu p_blkno = %llu blkno=(%llu)\n",
175 "blkno=(%"MLFu64")\n", (unsigned long long)iblock, 175 (unsigned long long)iblock,
176 p_blkno, OCFS2_I(inode)->ip_blkno); 176 (unsigned long long)p_blkno,
177 (unsigned long long)OCFS2_I(inode)->ip_blkno);
177 } 178 }
178 179
179 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); 180 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
180 mlog(0, "Inode %lu, past_eof = %"MLFu64"\n", inode->i_ino, past_eof); 181 mlog(0, "Inode %lu, past_eof = %llu\n", inode->i_ino,
182 (unsigned long long)past_eof);
181 183
182 if (create && (iblock >= past_eof)) 184 if (create && (iblock >= past_eof))
183 set_buffer_new(bh_result); 185 set_buffer_new(bh_result);
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index bae3d7548bea..9a24adf9be6e 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -97,8 +97,8 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
97 int i, ignore_cache = 0; 97 int i, ignore_cache = 0;
98 struct buffer_head *bh; 98 struct buffer_head *bh;
99 99
100 mlog_entry("(block=(%"MLFu64"), nr=(%d), flags=%d, inode=%p)\n", 100 mlog_entry("(block=(%llu), nr=(%d), flags=%d, inode=%p)\n",
101 block, nr, flags, inode); 101 (unsigned long long)block, nr, flags, inode);
102 102
103 if (osb == NULL || osb->sb == NULL || bhs == NULL) { 103 if (osb == NULL || osb->sb == NULL || bhs == NULL) {
104 status = -EINVAL; 104 status = -EINVAL;
@@ -143,9 +143,9 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
143 if (flags & OCFS2_BH_CACHED && 143 if (flags & OCFS2_BH_CACHED &&
144 !ocfs2_buffer_uptodate(inode, bh)) { 144 !ocfs2_buffer_uptodate(inode, bh)) {
145 mlog(ML_UPTODATE, 145 mlog(ML_UPTODATE,
146 "bh (%llu), inode %"MLFu64" not uptodate\n", 146 "bh (%llu), inode %llu not uptodate\n",
147 (unsigned long long)bh->b_blocknr, 147 (unsigned long long)bh->b_blocknr,
148 OCFS2_I(inode)->ip_blkno); 148 (unsigned long long)OCFS2_I(inode)->ip_blkno);
149 ignore_cache = 1; 149 ignore_cache = 1;
150 } 150 }
151 151
@@ -222,7 +222,8 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
222 if (inode) 222 if (inode)
223 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); 223 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
224 224
225 mlog(ML_BH_IO, "block=(%"MLFu64"), nr=(%d), cached=%s\n", block, nr, 225 mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s\n",
226 (unsigned long long)block, nr,
226 (!(flags & OCFS2_BH_CACHED) || ignore_cache) ? "no" : "yes"); 227 (!(flags & OCFS2_BH_CACHED) || ignore_cache) ? "no" : "yes");
227 228
228bail: 229bail:
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index d08971d29b63..bff0f0d06867 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -449,11 +449,11 @@ static u32 o2hb_compute_block_crc_le(struct o2hb_region *reg,
449 449
450static void o2hb_dump_slot(struct o2hb_disk_heartbeat_block *hb_block) 450static void o2hb_dump_slot(struct o2hb_disk_heartbeat_block *hb_block)
451{ 451{
452 mlog(ML_ERROR, "Dump slot information: seq = 0x%"MLFx64", node = %u, " 452 mlog(ML_ERROR, "Dump slot information: seq = 0x%llx, node = %u, "
453 "cksum = 0x%x, generation 0x%"MLFx64"\n", 453 "cksum = 0x%x, generation 0x%llx\n",
454 le64_to_cpu(hb_block->hb_seq), hb_block->hb_node, 454 (long long)le64_to_cpu(hb_block->hb_seq),
455 le32_to_cpu(hb_block->hb_cksum), 455 hb_block->hb_node, le32_to_cpu(hb_block->hb_cksum),
456 le64_to_cpu(hb_block->hb_generation)); 456 (long long)le64_to_cpu(hb_block->hb_generation));
457} 457}
458 458
459static int o2hb_verify_crc(struct o2hb_region *reg, 459static int o2hb_verify_crc(struct o2hb_region *reg,
@@ -516,8 +516,9 @@ static inline void o2hb_prepare_block(struct o2hb_region *reg,
516 hb_block->hb_cksum = cpu_to_le32(o2hb_compute_block_crc_le(reg, 516 hb_block->hb_cksum = cpu_to_le32(o2hb_compute_block_crc_le(reg,
517 hb_block)); 517 hb_block));
518 518
519 mlog(ML_HB_BIO, "our node generation = 0x%"MLFx64", cksum = 0x%x\n", 519 mlog(ML_HB_BIO, "our node generation = 0x%llx, cksum = 0x%x\n",
520 cpu_to_le64(generation), le32_to_cpu(hb_block->hb_cksum)); 520 (long long)cpu_to_le64(generation),
521 le32_to_cpu(hb_block->hb_cksum));
521} 522}
522 523
523static void o2hb_fire_callbacks(struct o2hb_callback *hbcall, 524static void o2hb_fire_callbacks(struct o2hb_callback *hbcall,
@@ -686,19 +687,20 @@ static int o2hb_check_slot(struct o2hb_region *reg,
686 if (slot->ds_last_generation != le64_to_cpu(hb_block->hb_generation)) { 687 if (slot->ds_last_generation != le64_to_cpu(hb_block->hb_generation)) {
687 gen_changed = 1; 688 gen_changed = 1;
688 slot->ds_equal_samples = 0; 689 slot->ds_equal_samples = 0;
689 mlog(ML_HEARTBEAT, "Node %d changed generation (0x%"MLFx64" " 690 mlog(ML_HEARTBEAT, "Node %d changed generation (0x%llx "
690 "to 0x%"MLFx64")\n", slot->ds_node_num, 691 "to 0x%llx)\n", slot->ds_node_num,
691 slot->ds_last_generation, 692 (long long)slot->ds_last_generation,
692 le64_to_cpu(hb_block->hb_generation)); 693 (long long)le64_to_cpu(hb_block->hb_generation));
693 } 694 }
694 695
695 slot->ds_last_generation = le64_to_cpu(hb_block->hb_generation); 696 slot->ds_last_generation = le64_to_cpu(hb_block->hb_generation);
696 697
697 mlog(ML_HEARTBEAT, "Slot %d gen 0x%"MLFx64" cksum 0x%x " 698 mlog(ML_HEARTBEAT, "Slot %d gen 0x%llx cksum 0x%x "
698 "seq %"MLFu64" last %"MLFu64" changed %u equal %u\n", 699 "seq %llu last %llu changed %u equal %u\n",
699 slot->ds_node_num, slot->ds_last_generation, 700 slot->ds_node_num, (long long)slot->ds_last_generation,
700 le32_to_cpu(hb_block->hb_cksum), le64_to_cpu(hb_block->hb_seq), 701 le32_to_cpu(hb_block->hb_cksum),
701 slot->ds_last_time, slot->ds_changed_samples, 702 (unsigned long long)le64_to_cpu(hb_block->hb_seq),
703 (unsigned long long)slot->ds_last_time, slot->ds_changed_samples,
702 slot->ds_equal_samples); 704 slot->ds_equal_samples);
703 705
704 spin_lock(&o2hb_live_lock); 706 spin_lock(&o2hb_live_lock);
@@ -708,8 +710,8 @@ fire_callbacks:
708 * changes at any time during their dead time */ 710 * changes at any time during their dead time */
709 if (list_empty(&slot->ds_live_item) && 711 if (list_empty(&slot->ds_live_item) &&
710 slot->ds_changed_samples >= O2HB_LIVE_THRESHOLD) { 712 slot->ds_changed_samples >= O2HB_LIVE_THRESHOLD) {
711 mlog(ML_HEARTBEAT, "Node %d (id 0x%"MLFx64") joined my " 713 mlog(ML_HEARTBEAT, "Node %d (id 0x%llx) joined my region\n",
712 "region\n", slot->ds_node_num, slot->ds_last_generation); 714 slot->ds_node_num, (long long)slot->ds_last_generation);
713 715
714 /* first on the list generates a callback */ 716 /* first on the list generates a callback */
715 if (list_empty(&o2hb_live_slots[slot->ds_node_num])) { 717 if (list_empty(&o2hb_live_slots[slot->ds_node_num])) {
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h
index 2cadc3009c83..73edad782537 100644
--- a/fs/ocfs2/cluster/masklog.h
+++ b/fs/ocfs2/cluster/masklog.h
@@ -256,16 +256,6 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits;
256 } \ 256 } \
257} while (0) 257} while (0)
258 258
259#if (BITS_PER_LONG == 32) || defined(CONFIG_X86_64) || (defined(CONFIG_UML_X86) && defined(CONFIG_64BIT))
260#define MLFi64 "lld"
261#define MLFu64 "llu"
262#define MLFx64 "llx"
263#else
264#define MLFi64 "ld"
265#define MLFu64 "lu"
266#define MLFx64 "lx"
267#endif
268
269#include <linux/kobject.h> 259#include <linux/kobject.h>
270#include <linux/sysfs.h> 260#include <linux/sysfs.h>
271int mlog_sys_init(struct subsystem *o2cb_subsys); 261int mlog_sys_init(struct subsystem *o2cb_subsys);
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index bd85182e97bc..1a01380e3878 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -64,15 +64,16 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry,
64 /* did we or someone else delete this inode? */ 64 /* did we or someone else delete this inode? */
65 if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { 65 if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) {
66 spin_unlock(&OCFS2_I(inode)->ip_lock); 66 spin_unlock(&OCFS2_I(inode)->ip_lock);
67 mlog(0, "inode (%"MLFu64") deleted, returning false\n", 67 mlog(0, "inode (%llu) deleted, returning false\n",
68 OCFS2_I(inode)->ip_blkno); 68 (unsigned long long)OCFS2_I(inode)->ip_blkno);
69 goto bail; 69 goto bail;
70 } 70 }
71 spin_unlock(&OCFS2_I(inode)->ip_lock); 71 spin_unlock(&OCFS2_I(inode)->ip_lock);
72 72
73 if (!inode->i_nlink) { 73 if (!inode->i_nlink) {
74 mlog(0, "Inode %"MLFu64" orphaned, returning false " 74 mlog(0, "Inode %llu orphaned, returning false "
75 "dir = %d\n", OCFS2_I(inode)->ip_blkno, 75 "dir = %d\n",
76 (unsigned long long)OCFS2_I(inode)->ip_blkno,
76 S_ISDIR(inode->i_mode)); 77 S_ISDIR(inode->i_mode));
77 goto bail; 78 goto bail;
78 } 79 }
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 57158fa75d91..ae47f450792f 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -83,7 +83,8 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
83 struct super_block * sb = inode->i_sb; 83 struct super_block * sb = inode->i_sb;
84 int have_disk_lock = 0; 84 int have_disk_lock = 0;
85 85
86 mlog_entry("dirino=%"MLFu64"\n", OCFS2_I(inode)->ip_blkno); 86 mlog_entry("dirino=%llu\n",
87 (unsigned long long)OCFS2_I(inode)->ip_blkno);
87 88
88 stored = 0; 89 stored = 0;
89 bh = NULL; 90 bh = NULL;
@@ -104,9 +105,9 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
104 blk = (filp->f_pos) >> sb->s_blocksize_bits; 105 blk = (filp->f_pos) >> sb->s_blocksize_bits;
105 bh = ocfs2_bread(inode, blk, &err, 0); 106 bh = ocfs2_bread(inode, blk, &err, 0);
106 if (!bh) { 107 if (!bh) {
107 mlog(ML_ERROR, "directory #%"MLFu64" contains a hole " 108 mlog(ML_ERROR,
108 "at offset %lld\n", 109 "directory #%llu contains a hole at offset %lld\n",
109 OCFS2_I(inode)->ip_blkno, 110 (unsigned long long)OCFS2_I(inode)->ip_blkno,
110 filp->f_pos); 111 filp->f_pos);
111 filp->f_pos += sb->s_blocksize - offset; 112 filp->f_pos += sb->s_blocksize - offset;
112 continue; 113 continue;
@@ -214,9 +215,9 @@ int ocfs2_find_files_on_disk(const char *name,
214 int status = -ENOENT; 215 int status = -ENOENT;
215 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 216 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
216 217
217 mlog_entry("(osb=%p, parent=%"MLFu64", name='%.*s', blkno=%p, " 218 mlog_entry("(osb=%p, parent=%llu, name='%.*s', blkno=%p, inode=%p)\n",
218 "inode=%p)\n", 219 osb, (unsigned long long)OCFS2_I(inode)->ip_blkno,
219 osb, OCFS2_I(inode)->ip_blkno, namelen, name, blkno, inode); 220 namelen, name, blkno, inode);
220 221
221 *dirent_bh = ocfs2_find_entry(name, namelen, inode, dirent); 222 *dirent_bh = ocfs2_find_entry(name, namelen, inode, dirent);
222 if (!*dirent_bh || !*dirent) { 223 if (!*dirent_bh || !*dirent) {
@@ -255,8 +256,8 @@ int ocfs2_check_dir_for_entry(struct inode *dir,
255 struct buffer_head *dirent_bh = NULL; 256 struct buffer_head *dirent_bh = NULL;
256 struct ocfs2_dir_entry *dirent = NULL; 257 struct ocfs2_dir_entry *dirent = NULL;
257 258
258 mlog_entry("dir %"MLFu64", name '%.*s'\n", OCFS2_I(dir)->ip_blkno, 259 mlog_entry("dir %llu, name '%.*s'\n",
259 namelen, name); 260 (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name);
260 261
261 ret = -EEXIST; 262 ret = -EEXIST;
262 dirent_bh = ocfs2_find_entry(name, namelen, dir, &dirent); 263 dirent_bh = ocfs2_find_entry(name, namelen, dir, &dirent);
@@ -287,9 +288,8 @@ int ocfs2_empty_dir(struct inode *inode)
287 if ((i_size_read(inode) < 288 if ((i_size_read(inode) <
288 (OCFS2_DIR_REC_LEN(1) + OCFS2_DIR_REC_LEN(2))) || 289 (OCFS2_DIR_REC_LEN(1) + OCFS2_DIR_REC_LEN(2))) ||
289 !(bh = ocfs2_bread(inode, 0, &err, 0))) { 290 !(bh = ocfs2_bread(inode, 0, &err, 0))) {
290 mlog(ML_ERROR, "bad directory (dir #%"MLFu64") - " 291 mlog(ML_ERROR, "bad directory (dir #%llu) - no data block\n",
291 "no data block\n", 292 (unsigned long long)OCFS2_I(inode)->ip_blkno);
292 OCFS2_I(inode)->ip_blkno);
293 return 1; 293 return 1;
294 } 294 }
295 295
@@ -300,9 +300,8 @@ int ocfs2_empty_dir(struct inode *inode)
300 !le64_to_cpu(de1->inode) || 300 !le64_to_cpu(de1->inode) ||
301 strcmp(".", de->name) || 301 strcmp(".", de->name) ||
302 strcmp("..", de1->name)) { 302 strcmp("..", de1->name)) {
303 mlog(ML_ERROR, "bad directory (dir #%"MLFu64") - " 303 mlog(ML_ERROR, "bad directory (dir #%llu) - no `.' or `..'\n",
304 "no `.' or `..'\n", 304 (unsigned long long)OCFS2_I(inode)->ip_blkno);
305 OCFS2_I(inode)->ip_blkno);
306 brelse(bh); 305 brelse(bh);
307 return 1; 306 return 1;
308 } 307 }
@@ -314,9 +313,8 @@ int ocfs2_empty_dir(struct inode *inode)
314 bh = ocfs2_bread(inode, 313 bh = ocfs2_bread(inode,
315 offset >> sb->s_blocksize_bits, &err, 0); 314 offset >> sb->s_blocksize_bits, &err, 0);
316 if (!bh) { 315 if (!bh) {
317 mlog(ML_ERROR, "directory #%"MLFu64" contains " 316 mlog(ML_ERROR, "dir %llu has a hole at %lu\n",
318 "a hole at offset %lu\n", 317 (unsigned long long)OCFS2_I(inode)->ip_blkno, offset);
319 OCFS2_I(inode)->ip_blkno, offset);
320 offset += sb->s_blocksize; 318 offset += sb->s_blocksize;
321 continue; 319 continue;
322 } 320 }
@@ -406,8 +404,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
406 mlog_entry_void(); 404 mlog_entry_void();
407 405
408 dir_i_size = i_size_read(dir); 406 dir_i_size = i_size_read(dir);
409 mlog(0, "extending dir %"MLFu64" (i_size = %lld)\n", 407 mlog(0, "extending dir %llu (i_size = %lld)\n",
410 OCFS2_I(dir)->ip_blkno, dir_i_size); 408 (unsigned long long)OCFS2_I(dir)->ip_blkno, dir_i_size);
411 409
412 handle = ocfs2_alloc_handle(osb); 410 handle = ocfs2_alloc_handle(osb);
413 if (handle == NULL) { 411 if (handle == NULL) {
@@ -531,8 +529,8 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
531 529
532 mlog_entry_void(); 530 mlog_entry_void();
533 531
534 mlog(0, "getting ready to insert namelen %d into dir %"MLFu64"\n", 532 mlog(0, "getting ready to insert namelen %d into dir %llu\n",
535 namelen, OCFS2_I(dir)->ip_blkno); 533 namelen, (unsigned long long)OCFS2_I(dir)->ip_blkno);
536 534
537 BUG_ON(!S_ISDIR(dir->i_mode)); 535 BUG_ON(!S_ISDIR(dir->i_mode));
538 fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; 536 fe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
index 8d17d28ef91c..355593dd8ef8 100644
--- a/fs/ocfs2/dlm/dlmast.c
+++ b/fs/ocfs2/dlm/dlmast.c
@@ -307,8 +307,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data)
307 307
308 if (past->type != DLM_AST && 308 if (past->type != DLM_AST &&
309 past->type != DLM_BAST) { 309 past->type != DLM_BAST) {
310 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%"MLFu64", " 310 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%u:%llu"
311 "name=%.*s\n", past->type, cookie, locklen, name); 311 "name=%.*s\n", past->type,
312 dlm_get_lock_cookie_node(cookie),
313 dlm_get_lock_cookie_seq(cookie),
314 locklen, name);
312 ret = DLM_IVLOCKID; 315 ret = DLM_IVLOCKID;
313 goto leave; 316 goto leave;
314 } 317 }
@@ -316,9 +319,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data)
316 res = dlm_lookup_lockres(dlm, name, locklen); 319 res = dlm_lookup_lockres(dlm, name, locklen);
317 if (!res) { 320 if (!res) {
318 mlog(ML_ERROR, "got %sast for unknown lockres! " 321 mlog(ML_ERROR, "got %sast for unknown lockres! "
319 "cookie=%"MLFu64", name=%.*s, namelen=%u\n", 322 "cookie=%u:%llu, name=%.*s, namelen=%u\n",
320 past->type == DLM_AST ? "" : "b", 323 past->type == DLM_AST ? "" : "b",
321 cookie, locklen, name, locklen); 324 dlm_get_lock_cookie_node(cookie),
325 dlm_get_lock_cookie_seq(cookie),
326 locklen, name, locklen);
322 ret = DLM_IVLOCKID; 327 ret = DLM_IVLOCKID;
323 goto leave; 328 goto leave;
324 } 329 }
@@ -360,9 +365,12 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data)
360 goto do_ast; 365 goto do_ast;
361 } 366 }
362 367
363 mlog(ML_ERROR, "got %sast for unknown lock! cookie=%"MLFu64", " 368 mlog(ML_ERROR, "got %sast for unknown lock! cookie=%u:%llu, "
364 "name=%.*s, namelen=%u\n", 369 "name=%.*s, namelen=%u\n",
365 past->type == DLM_AST ? "" : "b", cookie, locklen, name, locklen); 370 past->type == DLM_AST ? "" : "b",
371 dlm_get_lock_cookie_node(cookie),
372 dlm_get_lock_cookie_seq(cookie),
373 locklen, name, locklen);
366 374
367 ret = DLM_NORMAL; 375 ret = DLM_NORMAL;
368unlock_out: 376unlock_out:
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index 9c772583744a..88cc43df18f1 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -630,6 +630,21 @@ __dlm_lockres_state_to_status(struct dlm_lock_resource *res)
630 return status; 630 return status;
631} 631}
632 632
633static inline u8 dlm_get_lock_cookie_node(u64 cookie)
634{
635 u8 ret;
636 cookie >>= 56;
637 ret = (u8)(cookie & 0xffULL);
638 return ret;
639}
640
641static inline unsigned long long dlm_get_lock_cookie_seq(u64 cookie)
642{
643 unsigned long long ret;
644 ret = ((unsigned long long)cookie) & 0x00ffffffffffffffULL;
645 return ret;
646}
647
633struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie, 648struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
634 struct dlm_lockstatus *lksb); 649 struct dlm_lockstatus *lksb);
635void dlm_lock_get(struct dlm_lock *lock); 650void dlm_lock_get(struct dlm_lock *lock);
@@ -658,6 +673,7 @@ void dlm_complete_thread(struct dlm_ctxt *dlm);
658int dlm_launch_recovery_thread(struct dlm_ctxt *dlm); 673int dlm_launch_recovery_thread(struct dlm_ctxt *dlm);
659void dlm_complete_recovery_thread(struct dlm_ctxt *dlm); 674void dlm_complete_recovery_thread(struct dlm_ctxt *dlm);
660void dlm_wait_for_recovery(struct dlm_ctxt *dlm); 675void dlm_wait_for_recovery(struct dlm_ctxt *dlm);
676void dlm_kick_recovery_thread(struct dlm_ctxt *dlm);
661int dlm_is_node_dead(struct dlm_ctxt *dlm, u8 node); 677int dlm_is_node_dead(struct dlm_ctxt *dlm, u8 node);
662int dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout); 678int dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout);
663 679
@@ -762,6 +778,11 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data);
762int dlm_reco_data_done_handler(struct o2net_msg *msg, u32 len, void *data); 778int dlm_reco_data_done_handler(struct o2net_msg *msg, u32 len, void *data);
763int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data); 779int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data);
764int dlm_finalize_reco_handler(struct o2net_msg *msg, u32 len, void *data); 780int dlm_finalize_reco_handler(struct o2net_msg *msg, u32 len, void *data);
781int dlm_do_master_requery(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
782 u8 nodenum, u8 *real_master);
783int dlm_lockres_master_requery(struct dlm_ctxt *dlm,
784 struct dlm_lock_resource *res, u8 *real_master);
785
765 786
766int dlm_dispatch_assert_master(struct dlm_ctxt *dlm, 787int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
767 struct dlm_lock_resource *res, 788 struct dlm_lock_resource *res,
diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c
index f66e2d818ccd..8285228d9e37 100644
--- a/fs/ocfs2/dlm/dlmconvert.c
+++ b/fs/ocfs2/dlm/dlmconvert.c
@@ -284,8 +284,10 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm,
284 if (lock->ml.convert_type != LKM_IVMODE) { 284 if (lock->ml.convert_type != LKM_IVMODE) {
285 __dlm_print_one_lock_resource(res); 285 __dlm_print_one_lock_resource(res);
286 mlog(ML_ERROR, "converting a remote lock that is already " 286 mlog(ML_ERROR, "converting a remote lock that is already "
287 "converting! (cookie=%"MLFu64", conv=%d)\n", 287 "converting! (cookie=%u:%llu, conv=%d)\n",
288 lock->ml.cookie, lock->ml.convert_type); 288 dlm_get_lock_cookie_node(lock->ml.cookie),
289 dlm_get_lock_cookie_seq(lock->ml.cookie),
290 lock->ml.convert_type);
289 status = DLM_DENIED; 291 status = DLM_DENIED;
290 goto bail; 292 goto bail;
291 } 293 }
@@ -513,8 +515,9 @@ int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data)
513leave: 515leave:
514 if (!lock) 516 if (!lock)
515 mlog(ML_ERROR, "did not find lock to convert on grant queue! " 517 mlog(ML_ERROR, "did not find lock to convert on grant queue! "
516 "cookie=%"MLFu64"\n", 518 "cookie=%u:%llu\n",
517 cnv->cookie); 519 dlm_get_lock_cookie_node(cnv->cookie),
520 dlm_get_lock_cookie_seq(cnv->cookie));
518 else 521 else
519 dlm_lock_put(lock); 522 dlm_lock_put(lock);
520 523
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index 54f61b76ab51..c7eae5d3324e 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -72,8 +72,10 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
72 lock = list_entry(iter2, struct dlm_lock, list); 72 lock = list_entry(iter2, struct dlm_lock, list);
73 spin_lock(&lock->spinlock); 73 spin_lock(&lock->spinlock);
74 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " 74 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, "
75 "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", 75 "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n",
76 lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, 76 lock->ml.type, lock->ml.convert_type, lock->ml.node,
77 dlm_get_lock_cookie_node(lock->ml.cookie),
78 dlm_get_lock_cookie_seq(lock->ml.cookie),
77 list_empty(&lock->ast_list) ? 'y' : 'n', 79 list_empty(&lock->ast_list) ? 'y' : 'n',
78 lock->ast_pending ? 'y' : 'n', 80 lock->ast_pending ? 'y' : 'n',
79 list_empty(&lock->bast_list) ? 'y' : 'n', 81 list_empty(&lock->bast_list) ? 'y' : 'n',
@@ -85,8 +87,10 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
85 lock = list_entry(iter2, struct dlm_lock, list); 87 lock = list_entry(iter2, struct dlm_lock, list);
86 spin_lock(&lock->spinlock); 88 spin_lock(&lock->spinlock);
87 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " 89 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, "
88 "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", 90 "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n",
89 lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, 91 lock->ml.type, lock->ml.convert_type, lock->ml.node,
92 dlm_get_lock_cookie_node(lock->ml.cookie),
93 dlm_get_lock_cookie_seq(lock->ml.cookie),
90 list_empty(&lock->ast_list) ? 'y' : 'n', 94 list_empty(&lock->ast_list) ? 'y' : 'n',
91 lock->ast_pending ? 'y' : 'n', 95 lock->ast_pending ? 'y' : 'n',
92 list_empty(&lock->bast_list) ? 'y' : 'n', 96 list_empty(&lock->bast_list) ? 'y' : 'n',
@@ -98,8 +102,10 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
98 lock = list_entry(iter2, struct dlm_lock, list); 102 lock = list_entry(iter2, struct dlm_lock, list);
99 spin_lock(&lock->spinlock); 103 spin_lock(&lock->spinlock);
100 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " 104 mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, "
101 "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", 105 "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n",
102 lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, 106 lock->ml.type, lock->ml.convert_type, lock->ml.node,
107 dlm_get_lock_cookie_node(lock->ml.cookie),
108 dlm_get_lock_cookie_seq(lock->ml.cookie),
103 list_empty(&lock->ast_list) ? 'y' : 'n', 109 list_empty(&lock->ast_list) ? 'y' : 'n',
104 lock->ast_pending ? 'y' : 'n', 110 lock->ast_pending ? 'y' : 'n',
105 list_empty(&lock->bast_list) ? 'y' : 'n', 111 list_empty(&lock->bast_list) ? 'y' : 'n',
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index dd2d24dc25e0..7e88e24b3471 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -596,7 +596,8 @@ static int __init init_dlmfs_fs(void)
596 596
597 dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache", 597 dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache",
598 sizeof(struct dlmfs_inode_private), 598 sizeof(struct dlmfs_inode_private),
599 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 599 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
600 SLAB_MEM_SPREAD),
600 dlmfs_init_once, NULL); 601 dlmfs_init_once, NULL);
601 if (!dlmfs_inode_cache) 602 if (!dlmfs_inode_cache)
602 return -ENOMEM; 603 return -ENOMEM;
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index 671d4ff222cc..6fea28318d6d 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -141,13 +141,23 @@ static enum dlm_status dlmlock_master(struct dlm_ctxt *dlm,
141 res->lockname.len)) { 141 res->lockname.len)) {
142 kick_thread = 1; 142 kick_thread = 1;
143 call_ast = 1; 143 call_ast = 1;
144 } else {
145 mlog(0, "%s: returning DLM_NORMAL to "
146 "node %u for reco lock\n", dlm->name,
147 lock->ml.node);
144 } 148 }
145 } else { 149 } else {
146 /* for NOQUEUE request, unless we get the 150 /* for NOQUEUE request, unless we get the
147 * lock right away, return DLM_NOTQUEUED */ 151 * lock right away, return DLM_NOTQUEUED */
148 if (flags & LKM_NOQUEUE) 152 if (flags & LKM_NOQUEUE) {
149 status = DLM_NOTQUEUED; 153 status = DLM_NOTQUEUED;
150 else { 154 if (dlm_is_recovery_lock(res->lockname.name,
155 res->lockname.len)) {
156 mlog(0, "%s: returning NOTQUEUED to "
157 "node %u for reco lock\n", dlm->name,
158 lock->ml.node);
159 }
160 } else {
151 dlm_lock_get(lock); 161 dlm_lock_get(lock);
152 list_add_tail(&lock->list, &res->blocked); 162 list_add_tail(&lock->list, &res->blocked);
153 kick_thread = 1; 163 kick_thread = 1;
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 847dd3cc4cf5..940be4c13b1f 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -239,6 +239,8 @@ static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm,
239static int dlm_mark_lockres_migrating(struct dlm_ctxt *dlm, 239static int dlm_mark_lockres_migrating(struct dlm_ctxt *dlm,
240 struct dlm_lock_resource *res, 240 struct dlm_lock_resource *res,
241 u8 target); 241 u8 target);
242static int dlm_pre_master_reco_lockres(struct dlm_ctxt *dlm,
243 struct dlm_lock_resource *res);
242 244
243 245
244int dlm_is_host_down(int errno) 246int dlm_is_host_down(int errno)
@@ -677,6 +679,7 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
677 struct dlm_node_iter iter; 679 struct dlm_node_iter iter;
678 unsigned int namelen; 680 unsigned int namelen;
679 int tries = 0; 681 int tries = 0;
682 int bit, wait_on_recovery = 0;
680 683
681 BUG_ON(!lockid); 684 BUG_ON(!lockid);
682 685
@@ -762,6 +765,18 @@ lookup:
762 dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0); 765 dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0);
763 set_bit(dlm->node_num, mle->maybe_map); 766 set_bit(dlm->node_num, mle->maybe_map);
764 list_add(&mle->list, &dlm->master_list); 767 list_add(&mle->list, &dlm->master_list);
768
769 /* still holding the dlm spinlock, check the recovery map
770 * to see if there are any nodes that still need to be
771 * considered. these will not appear in the mle nodemap
772 * but they might own this lockres. wait on them. */
773 bit = find_next_bit(dlm->recovery_map, O2NM_MAX_NODES, 0);
774 if (bit < O2NM_MAX_NODES) {
775 mlog(ML_NOTICE, "%s:%.*s: at least one node (%d) to"
776 "recover before lock mastery can begin\n",
777 dlm->name, namelen, (char *)lockid, bit);
778 wait_on_recovery = 1;
779 }
765 } 780 }
766 781
767 /* at this point there is either a DLM_MLE_BLOCK or a 782 /* at this point there is either a DLM_MLE_BLOCK or a
@@ -779,6 +794,39 @@ lookup:
779 spin_unlock(&dlm->master_lock); 794 spin_unlock(&dlm->master_lock);
780 spin_unlock(&dlm->spinlock); 795 spin_unlock(&dlm->spinlock);
781 796
797 while (wait_on_recovery) {
798 /* any cluster changes that occurred after dropping the
799 * dlm spinlock would be detectable be a change on the mle,
800 * so we only need to clear out the recovery map once. */
801 if (dlm_is_recovery_lock(lockid, namelen)) {
802 mlog(ML_NOTICE, "%s: recovery map is not empty, but "
803 "must master $RECOVERY lock now\n", dlm->name);
804 if (!dlm_pre_master_reco_lockres(dlm, res))
805 wait_on_recovery = 0;
806 else {
807 mlog(0, "%s: waiting 500ms for heartbeat state "
808 "change\n", dlm->name);
809 msleep(500);
810 }
811 continue;
812 }
813
814 dlm_kick_recovery_thread(dlm);
815 msleep(100);
816 dlm_wait_for_recovery(dlm);
817
818 spin_lock(&dlm->spinlock);
819 bit = find_next_bit(dlm->recovery_map, O2NM_MAX_NODES, 0);
820 if (bit < O2NM_MAX_NODES) {
821 mlog(ML_NOTICE, "%s:%.*s: at least one node (%d) to"
822 "recover before lock mastery can begin\n",
823 dlm->name, namelen, (char *)lockid, bit);
824 wait_on_recovery = 1;
825 } else
826 wait_on_recovery = 0;
827 spin_unlock(&dlm->spinlock);
828 }
829
782 /* must wait for lock to be mastered elsewhere */ 830 /* must wait for lock to be mastered elsewhere */
783 if (blocked) 831 if (blocked)
784 goto wait; 832 goto wait;
@@ -792,7 +840,15 @@ redo_request:
792 mlog_errno(ret); 840 mlog_errno(ret);
793 if (mle->master != O2NM_MAX_NODES) { 841 if (mle->master != O2NM_MAX_NODES) {
794 /* found a master ! */ 842 /* found a master ! */
795 break; 843 if (mle->master <= nodenum)
844 break;
845 /* if our master request has not reached the master
846 * yet, keep going until it does. this is how the
847 * master will know that asserts are needed back to
848 * the lower nodes. */
849 mlog(0, "%s:%.*s: requests only up to %u but master "
850 "is %u, keep going\n", dlm->name, namelen,
851 lockid, nodenum, mle->master);
796 } 852 }
797 } 853 }
798 854
@@ -860,7 +916,19 @@ recheck:
860 /* check if another node has already become the owner */ 916 /* check if another node has already become the owner */
861 spin_lock(&res->spinlock); 917 spin_lock(&res->spinlock);
862 if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) { 918 if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) {
919 mlog(0, "%s:%.*s: owner is suddenly %u\n", dlm->name,
920 res->lockname.len, res->lockname.name, res->owner);
863 spin_unlock(&res->spinlock); 921 spin_unlock(&res->spinlock);
922 /* this will cause the master to re-assert across
923 * the whole cluster, freeing up mles */
924 ret = dlm_do_master_request(mle, res->owner);
925 if (ret < 0) {
926 /* give recovery a chance to run */
927 mlog(ML_ERROR, "link to %u went down?: %d\n", res->owner, ret);
928 msleep(500);
929 goto recheck;
930 }
931 ret = 0;
864 goto leave; 932 goto leave;
865 } 933 }
866 spin_unlock(&res->spinlock); 934 spin_unlock(&res->spinlock);
@@ -1244,13 +1312,14 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data)
1244{ 1312{
1245 u8 response = DLM_MASTER_RESP_MAYBE; 1313 u8 response = DLM_MASTER_RESP_MAYBE;
1246 struct dlm_ctxt *dlm = data; 1314 struct dlm_ctxt *dlm = data;
1247 struct dlm_lock_resource *res; 1315 struct dlm_lock_resource *res = NULL;
1248 struct dlm_master_request *request = (struct dlm_master_request *) msg->buf; 1316 struct dlm_master_request *request = (struct dlm_master_request *) msg->buf;
1249 struct dlm_master_list_entry *mle = NULL, *tmpmle = NULL; 1317 struct dlm_master_list_entry *mle = NULL, *tmpmle = NULL;
1250 char *name; 1318 char *name;
1251 unsigned int namelen; 1319 unsigned int namelen;
1252 int found, ret; 1320 int found, ret;
1253 int set_maybe; 1321 int set_maybe;
1322 int dispatch_assert = 0;
1254 1323
1255 if (!dlm_grab(dlm)) 1324 if (!dlm_grab(dlm))
1256 return DLM_MASTER_RESP_NO; 1325 return DLM_MASTER_RESP_NO;
@@ -1287,7 +1356,6 @@ way_up_top:
1287 } 1356 }
1288 1357
1289 if (res->owner == dlm->node_num) { 1358 if (res->owner == dlm->node_num) {
1290 u32 flags = DLM_ASSERT_MASTER_MLE_CLEANUP;
1291 spin_unlock(&res->spinlock); 1359 spin_unlock(&res->spinlock);
1292 // mlog(0, "this node is the master\n"); 1360 // mlog(0, "this node is the master\n");
1293 response = DLM_MASTER_RESP_YES; 1361 response = DLM_MASTER_RESP_YES;
@@ -1300,16 +1368,7 @@ way_up_top:
1300 * caused all nodes up to this one to 1368 * caused all nodes up to this one to
1301 * create mles. this node now needs to 1369 * create mles. this node now needs to
1302 * go back and clean those up. */ 1370 * go back and clean those up. */
1303 mlog(0, "%u is the owner of %.*s, cleaning everyone else\n", 1371 dispatch_assert = 1;
1304 dlm->node_num, res->lockname.len, res->lockname.name);
1305 ret = dlm_dispatch_assert_master(dlm, res, 1,
1306 request->node_idx,
1307 flags);
1308 if (ret < 0) {
1309 mlog(ML_ERROR, "failed to dispatch assert "
1310 "master work\n");
1311 response = DLM_MASTER_RESP_ERROR;
1312 }
1313 goto send_response; 1372 goto send_response;
1314 } else if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) { 1373 } else if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) {
1315 spin_unlock(&res->spinlock); 1374 spin_unlock(&res->spinlock);
@@ -1357,9 +1416,13 @@ way_up_top:
1357 } 1416 }
1358 } else if (tmpmle->master != DLM_LOCK_RES_OWNER_UNKNOWN) { 1417 } else if (tmpmle->master != DLM_LOCK_RES_OWNER_UNKNOWN) {
1359 set_maybe = 0; 1418 set_maybe = 0;
1360 if (tmpmle->master == dlm->node_num) 1419 if (tmpmle->master == dlm->node_num) {
1361 response = DLM_MASTER_RESP_YES; 1420 response = DLM_MASTER_RESP_YES;
1362 else 1421 /* this node will be the owner.
1422 * go back and clean the mles on any
1423 * other nodes */
1424 dispatch_assert = 1;
1425 } else
1363 response = DLM_MASTER_RESP_NO; 1426 response = DLM_MASTER_RESP_NO;
1364 } else { 1427 } else {
1365 // mlog(0, "this node is attempting to " 1428 // mlog(0, "this node is attempting to "
@@ -1398,8 +1461,8 @@ way_up_top:
1398 mle = (struct dlm_master_list_entry *) 1461 mle = (struct dlm_master_list_entry *)
1399 kmem_cache_alloc(dlm_mle_cache, GFP_KERNEL); 1462 kmem_cache_alloc(dlm_mle_cache, GFP_KERNEL);
1400 if (!mle) { 1463 if (!mle) {
1401 // bad bad bad... this sucks.
1402 response = DLM_MASTER_RESP_ERROR; 1464 response = DLM_MASTER_RESP_ERROR;
1465 mlog_errno(-ENOMEM);
1403 goto send_response; 1466 goto send_response;
1404 } 1467 }
1405 spin_lock(&dlm->spinlock); 1468 spin_lock(&dlm->spinlock);
@@ -1418,25 +1481,19 @@ way_up_top:
1418 // mlog(0, "mle was found\n"); 1481 // mlog(0, "mle was found\n");
1419 set_maybe = 1; 1482 set_maybe = 1;
1420 spin_lock(&tmpmle->spinlock); 1483 spin_lock(&tmpmle->spinlock);
1484 if (tmpmle->master == dlm->node_num) {
1485 mlog(ML_ERROR, "no lockres, but an mle with this node as master!\n");
1486 BUG();
1487 }
1421 if (tmpmle->type == DLM_MLE_BLOCK) 1488 if (tmpmle->type == DLM_MLE_BLOCK)
1422 response = DLM_MASTER_RESP_NO; 1489 response = DLM_MASTER_RESP_NO;
1423 else if (tmpmle->type == DLM_MLE_MIGRATION) { 1490 else if (tmpmle->type == DLM_MLE_MIGRATION) {
1424 mlog(0, "migration mle was found (%u->%u)\n", 1491 mlog(0, "migration mle was found (%u->%u)\n",
1425 tmpmle->master, tmpmle->new_master); 1492 tmpmle->master, tmpmle->new_master);
1426 if (tmpmle->master == dlm->node_num) {
1427 mlog(ML_ERROR, "no lockres, but migration mle "
1428 "says that this node is master!\n");
1429 BUG();
1430 }
1431 /* real master can respond on its own */ 1493 /* real master can respond on its own */
1432 response = DLM_MASTER_RESP_NO; 1494 response = DLM_MASTER_RESP_NO;
1433 } else { 1495 } else
1434 if (tmpmle->master == dlm->node_num) { 1496 response = DLM_MASTER_RESP_MAYBE;
1435 response = DLM_MASTER_RESP_YES;
1436 set_maybe = 0;
1437 } else
1438 response = DLM_MASTER_RESP_MAYBE;
1439 }
1440 if (set_maybe) 1497 if (set_maybe)
1441 set_bit(request->node_idx, tmpmle->maybe_map); 1498 set_bit(request->node_idx, tmpmle->maybe_map);
1442 spin_unlock(&tmpmle->spinlock); 1499 spin_unlock(&tmpmle->spinlock);
@@ -1449,6 +1506,24 @@ way_up_top:
1449 dlm_put_mle(tmpmle); 1506 dlm_put_mle(tmpmle);
1450 } 1507 }
1451send_response: 1508send_response:
1509
1510 if (dispatch_assert) {
1511 if (response != DLM_MASTER_RESP_YES)
1512 mlog(ML_ERROR, "invalid response %d\n", response);
1513 if (!res) {
1514 mlog(ML_ERROR, "bad lockres while trying to assert!\n");
1515 BUG();
1516 }
1517 mlog(0, "%u is the owner of %.*s, cleaning everyone else\n",
1518 dlm->node_num, res->lockname.len, res->lockname.name);
1519 ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx,
1520 DLM_ASSERT_MASTER_MLE_CLEANUP);
1521 if (ret < 0) {
1522 mlog(ML_ERROR, "failed to dispatch assert master work\n");
1523 response = DLM_MASTER_RESP_ERROR;
1524 }
1525 }
1526
1452 dlm_put(dlm); 1527 dlm_put(dlm);
1453 return response; 1528 return response;
1454} 1529}
@@ -1471,8 +1546,11 @@ static int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname,
1471 int to, tmpret; 1546 int to, tmpret;
1472 struct dlm_node_iter iter; 1547 struct dlm_node_iter iter;
1473 int ret = 0; 1548 int ret = 0;
1549 int reassert;
1474 1550
1475 BUG_ON(namelen > O2NM_MAX_NAME_LEN); 1551 BUG_ON(namelen > O2NM_MAX_NAME_LEN);
1552again:
1553 reassert = 0;
1476 1554
1477 /* note that if this nodemap is empty, it returns 0 */ 1555 /* note that if this nodemap is empty, it returns 0 */
1478 dlm_node_iter_init(nodemap, &iter); 1556 dlm_node_iter_init(nodemap, &iter);
@@ -1504,9 +1582,17 @@ static int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname,
1504 "got %d.\n", namelen, lockname, to, r); 1582 "got %d.\n", namelen, lockname, to, r);
1505 dlm_dump_lock_resources(dlm); 1583 dlm_dump_lock_resources(dlm);
1506 BUG(); 1584 BUG();
1585 } else if (r == EAGAIN) {
1586 mlog(0, "%.*s: node %u create mles on other "
1587 "nodes and requests a re-assert\n",
1588 namelen, lockname, to);
1589 reassert = 1;
1507 } 1590 }
1508 } 1591 }
1509 1592
1593 if (reassert)
1594 goto again;
1595
1510 return ret; 1596 return ret;
1511} 1597}
1512 1598
@@ -1528,6 +1614,8 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data)
1528 char *name; 1614 char *name;
1529 unsigned int namelen; 1615 unsigned int namelen;
1530 u32 flags; 1616 u32 flags;
1617 int master_request = 0;
1618 int ret = 0;
1531 1619
1532 if (!dlm_grab(dlm)) 1620 if (!dlm_grab(dlm))
1533 return 0; 1621 return 0;
@@ -1642,11 +1730,22 @@ ok:
1642 // mlog(0, "woo! got an assert_master from node %u!\n", 1730 // mlog(0, "woo! got an assert_master from node %u!\n",
1643 // assert->node_idx); 1731 // assert->node_idx);
1644 if (mle) { 1732 if (mle) {
1645 int extra_ref; 1733 int extra_ref = 0;
1734 int nn = -1;
1646 1735
1647 spin_lock(&mle->spinlock); 1736 spin_lock(&mle->spinlock);
1648 extra_ref = !!(mle->type == DLM_MLE_BLOCK 1737 if (mle->type == DLM_MLE_BLOCK || mle->type == DLM_MLE_MIGRATION)
1649 || mle->type == DLM_MLE_MIGRATION); 1738 extra_ref = 1;
1739 else {
1740 /* MASTER mle: if any bits set in the response map
1741 * then the calling node needs to re-assert to clear
1742 * up nodes that this node contacted */
1743 while ((nn = find_next_bit (mle->response_map, O2NM_MAX_NODES,
1744 nn+1)) < O2NM_MAX_NODES) {
1745 if (nn != dlm->node_num && nn != assert->node_idx)
1746 master_request = 1;
1747 }
1748 }
1650 mle->master = assert->node_idx; 1749 mle->master = assert->node_idx;
1651 atomic_set(&mle->woken, 1); 1750 atomic_set(&mle->woken, 1);
1652 wake_up(&mle->wq); 1751 wake_up(&mle->wq);
@@ -1677,10 +1776,15 @@ ok:
1677 } 1776 }
1678 1777
1679done: 1778done:
1779 ret = 0;
1680 if (res) 1780 if (res)
1681 dlm_lockres_put(res); 1781 dlm_lockres_put(res);
1682 dlm_put(dlm); 1782 dlm_put(dlm);
1683 return 0; 1783 if (master_request) {
1784 mlog(0, "need to tell master to reassert\n");
1785 ret = EAGAIN; // positive. negative would shoot down the node.
1786 }
1787 return ret;
1684 1788
1685kill: 1789kill:
1686 /* kill the caller! */ 1790 /* kill the caller! */
@@ -1713,6 +1817,10 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
1713 item->u.am.request_from = request_from; 1817 item->u.am.request_from = request_from;
1714 item->u.am.flags = flags; 1818 item->u.am.flags = flags;
1715 1819
1820 if (ignore_higher)
1821 mlog(0, "IGNORE HIGHER: %.*s\n", res->lockname.len,
1822 res->lockname.name);
1823
1716 spin_lock(&dlm->work_lock); 1824 spin_lock(&dlm->work_lock);
1717 list_add_tail(&item->list, &dlm->work_list); 1825 list_add_tail(&item->list, &dlm->work_list);
1718 spin_unlock(&dlm->work_lock); 1826 spin_unlock(&dlm->work_lock);
@@ -1775,6 +1883,61 @@ static void dlm_assert_master_worker(struct dlm_work_item *item, void *data)
1775 mlog(0, "finished with dlm_assert_master_worker\n"); 1883 mlog(0, "finished with dlm_assert_master_worker\n");
1776} 1884}
1777 1885
1886/* SPECIAL CASE for the $RECOVERY lock used by the recovery thread.
1887 * We cannot wait for node recovery to complete to begin mastering this
1888 * lockres because this lockres is used to kick off recovery! ;-)
1889 * So, do a pre-check on all living nodes to see if any of those nodes
1890 * think that $RECOVERY is currently mastered by a dead node. If so,
1891 * we wait a short time to allow that node to get notified by its own
1892 * heartbeat stack, then check again. All $RECOVERY lock resources
1893 * mastered by dead nodes are purged when the hearbeat callback is
1894 * fired, so we can know for sure that it is safe to continue once
1895 * the node returns a live node or no node. */
1896static int dlm_pre_master_reco_lockres(struct dlm_ctxt *dlm,
1897 struct dlm_lock_resource *res)
1898{
1899 struct dlm_node_iter iter;
1900 int nodenum;
1901 int ret = 0;
1902 u8 master = DLM_LOCK_RES_OWNER_UNKNOWN;
1903
1904 spin_lock(&dlm->spinlock);
1905 dlm_node_iter_init(dlm->domain_map, &iter);
1906 spin_unlock(&dlm->spinlock);
1907
1908 while ((nodenum = dlm_node_iter_next(&iter)) >= 0) {
1909 /* do not send to self */
1910 if (nodenum == dlm->node_num)
1911 continue;
1912 ret = dlm_do_master_requery(dlm, res, nodenum, &master);
1913 if (ret < 0) {
1914 mlog_errno(ret);
1915 if (!dlm_is_host_down(ret))
1916 BUG();
1917 /* host is down, so answer for that node would be
1918 * DLM_LOCK_RES_OWNER_UNKNOWN. continue. */
1919 }
1920
1921 if (master != DLM_LOCK_RES_OWNER_UNKNOWN) {
1922 /* check to see if this master is in the recovery map */
1923 spin_lock(&dlm->spinlock);
1924 if (test_bit(master, dlm->recovery_map)) {
1925 mlog(ML_NOTICE, "%s: node %u has not seen "
1926 "node %u go down yet, and thinks the "
1927 "dead node is mastering the recovery "
1928 "lock. must wait.\n", dlm->name,
1929 nodenum, master);
1930 ret = -EAGAIN;
1931 }
1932 spin_unlock(&dlm->spinlock);
1933 mlog(0, "%s: reco lock master is %u\n", dlm->name,
1934 master);
1935 break;
1936 }
1937 }
1938 return ret;
1939}
1940
1778 1941
1779/* 1942/*
1780 * DLM_MIGRATE_LOCKRES 1943 * DLM_MIGRATE_LOCKRES
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 1e232000f3f7..805cbabac051 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -58,7 +58,7 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node);
58static int dlm_recovery_thread(void *data); 58static int dlm_recovery_thread(void *data);
59void dlm_complete_recovery_thread(struct dlm_ctxt *dlm); 59void dlm_complete_recovery_thread(struct dlm_ctxt *dlm);
60int dlm_launch_recovery_thread(struct dlm_ctxt *dlm); 60int dlm_launch_recovery_thread(struct dlm_ctxt *dlm);
61static void dlm_kick_recovery_thread(struct dlm_ctxt *dlm); 61void dlm_kick_recovery_thread(struct dlm_ctxt *dlm);
62static int dlm_do_recovery(struct dlm_ctxt *dlm); 62static int dlm_do_recovery(struct dlm_ctxt *dlm);
63 63
64static int dlm_pick_recovery_master(struct dlm_ctxt *dlm); 64static int dlm_pick_recovery_master(struct dlm_ctxt *dlm);
@@ -78,15 +78,9 @@ static int dlm_send_mig_lockres_msg(struct dlm_ctxt *dlm,
78 u8 send_to, 78 u8 send_to,
79 struct dlm_lock_resource *res, 79 struct dlm_lock_resource *res,
80 int total_locks); 80 int total_locks);
81static int dlm_lockres_master_requery(struct dlm_ctxt *dlm,
82 struct dlm_lock_resource *res,
83 u8 *real_master);
84static int dlm_process_recovery_data(struct dlm_ctxt *dlm, 81static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
85 struct dlm_lock_resource *res, 82 struct dlm_lock_resource *res,
86 struct dlm_migratable_lockres *mres); 83 struct dlm_migratable_lockres *mres);
87static int dlm_do_master_requery(struct dlm_ctxt *dlm,
88 struct dlm_lock_resource *res,
89 u8 nodenum, u8 *real_master);
90static int dlm_send_finalize_reco_message(struct dlm_ctxt *dlm); 84static int dlm_send_finalize_reco_message(struct dlm_ctxt *dlm);
91static int dlm_send_all_done_msg(struct dlm_ctxt *dlm, 85static int dlm_send_all_done_msg(struct dlm_ctxt *dlm,
92 u8 dead_node, u8 send_to); 86 u8 dead_node, u8 send_to);
@@ -165,7 +159,7 @@ void dlm_dispatch_work(void *data)
165 * RECOVERY THREAD 159 * RECOVERY THREAD
166 */ 160 */
167 161
168static void dlm_kick_recovery_thread(struct dlm_ctxt *dlm) 162void dlm_kick_recovery_thread(struct dlm_ctxt *dlm)
169{ 163{
170 /* wake the recovery thread 164 /* wake the recovery thread
171 * this will wake the reco thread in one of three places 165 * this will wake the reco thread in one of three places
@@ -750,10 +744,12 @@ static void dlm_request_all_locks_worker(struct dlm_work_item *item, void *data)
750 dlm->name, dlm->reco.dead_node, dlm->reco.new_master, 744 dlm->name, dlm->reco.dead_node, dlm->reco.new_master,
751 dead_node, reco_master); 745 dead_node, reco_master);
752 mlog(ML_ERROR, "%s: name=%.*s master=%u locks=%u/%u flags=%u " 746 mlog(ML_ERROR, "%s: name=%.*s master=%u locks=%u/%u flags=%u "
753 "entry[0]={c=%"MLFu64",l=%u,f=%u,t=%d,ct=%d,hb=%d,n=%u}\n", 747 "entry[0]={c=%u:%llu,l=%u,f=%u,t=%d,ct=%d,hb=%d,n=%u}\n",
754 dlm->name, mres->lockname_len, mres->lockname, mres->master, 748 dlm->name, mres->lockname_len, mres->lockname, mres->master,
755 mres->num_locks, mres->total_locks, mres->flags, 749 mres->num_locks, mres->total_locks, mres->flags,
756 mres->ml[0].cookie, mres->ml[0].list, mres->ml[0].flags, 750 dlm_get_lock_cookie_node(mres->ml[0].cookie),
751 dlm_get_lock_cookie_seq(mres->ml[0].cookie),
752 mres->ml[0].list, mres->ml[0].flags,
757 mres->ml[0].type, mres->ml[0].convert_type, 753 mres->ml[0].type, mres->ml[0].convert_type,
758 mres->ml[0].highest_blocked, mres->ml[0].node); 754 mres->ml[0].highest_blocked, mres->ml[0].node);
759 BUG(); 755 BUG();
@@ -1316,9 +1312,8 @@ leave:
1316 1312
1317 1313
1318 1314
1319static int dlm_lockres_master_requery(struct dlm_ctxt *dlm, 1315int dlm_lockres_master_requery(struct dlm_ctxt *dlm,
1320 struct dlm_lock_resource *res, 1316 struct dlm_lock_resource *res, u8 *real_master)
1321 u8 *real_master)
1322{ 1317{
1323 struct dlm_node_iter iter; 1318 struct dlm_node_iter iter;
1324 int nodenum; 1319 int nodenum;
@@ -1360,8 +1355,10 @@ static int dlm_lockres_master_requery(struct dlm_ctxt *dlm,
1360 ret = dlm_do_master_requery(dlm, res, nodenum, real_master); 1355 ret = dlm_do_master_requery(dlm, res, nodenum, real_master);
1361 if (ret < 0) { 1356 if (ret < 0) {
1362 mlog_errno(ret); 1357 mlog_errno(ret);
1363 BUG(); 1358 if (!dlm_is_host_down(ret))
1364 /* TODO: need to figure a way to restart this */ 1359 BUG();
1360 /* host is down, so answer for that node would be
1361 * DLM_LOCK_RES_OWNER_UNKNOWN. continue. */
1365 } 1362 }
1366 if (*real_master != DLM_LOCK_RES_OWNER_UNKNOWN) { 1363 if (*real_master != DLM_LOCK_RES_OWNER_UNKNOWN) {
1367 mlog(0, "lock master is %u\n", *real_master); 1364 mlog(0, "lock master is %u\n", *real_master);
@@ -1372,9 +1369,8 @@ static int dlm_lockres_master_requery(struct dlm_ctxt *dlm,
1372} 1369}
1373 1370
1374 1371
1375static int dlm_do_master_requery(struct dlm_ctxt *dlm, 1372int dlm_do_master_requery(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
1376 struct dlm_lock_resource *res, 1373 u8 nodenum, u8 *real_master)
1377 u8 nodenum, u8 *real_master)
1378{ 1374{
1379 int ret = -EINVAL; 1375 int ret = -EINVAL;
1380 struct dlm_master_requery req; 1376 struct dlm_master_requery req;
@@ -1519,9 +1515,11 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
1519 /* lock is always created locally first, and 1515 /* lock is always created locally first, and
1520 * destroyed locally last. it must be on the list */ 1516 * destroyed locally last. it must be on the list */
1521 if (!lock) { 1517 if (!lock) {
1518 u64 c = ml->cookie;
1522 mlog(ML_ERROR, "could not find local lock " 1519 mlog(ML_ERROR, "could not find local lock "
1523 "with cookie %"MLFu64"!\n", 1520 "with cookie %u:%llu!\n",
1524 ml->cookie); 1521 dlm_get_lock_cookie_node(c),
1522 dlm_get_lock_cookie_seq(c));
1525 BUG(); 1523 BUG();
1526 } 1524 }
1527 BUG_ON(lock->ml.node != ml->node); 1525 BUG_ON(lock->ml.node != ml->node);
@@ -1739,6 +1737,13 @@ static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm,
1739 } else 1737 } else
1740 continue; 1738 continue;
1741 1739
1740 if (!list_empty(&res->recovering)) {
1741 mlog(0, "%s:%.*s: lockres was "
1742 "marked RECOVERING, owner=%u\n",
1743 dlm->name, res->lockname.len,
1744 res->lockname.name, res->owner);
1745 list_del_init(&res->recovering);
1746 }
1742 spin_lock(&res->spinlock); 1747 spin_lock(&res->spinlock);
1743 dlm_change_lockres_owner(dlm, res, new_master); 1748 dlm_change_lockres_owner(dlm, res, new_master);
1744 res->state &= ~DLM_LOCK_RES_RECOVERING; 1749 res->state &= ~DLM_LOCK_RES_RECOVERING;
@@ -2258,7 +2263,10 @@ int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data)
2258 mlog(0, "%u not in domain/live_nodes map " 2263 mlog(0, "%u not in domain/live_nodes map "
2259 "so setting it in reco map manually\n", 2264 "so setting it in reco map manually\n",
2260 br->dead_node); 2265 br->dead_node);
2261 set_bit(br->dead_node, dlm->recovery_map); 2266 /* force the recovery cleanup in __dlm_hb_node_down
2267 * both of these will be cleared in a moment */
2268 set_bit(br->dead_node, dlm->domain_map);
2269 set_bit(br->dead_node, dlm->live_nodes_map);
2262 __dlm_hb_node_down(dlm, br->dead_node); 2270 __dlm_hb_node_down(dlm, br->dead_node);
2263 } 2271 }
2264 spin_unlock(&dlm->spinlock); 2272 spin_unlock(&dlm->spinlock);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index c95f08d2e925..7b1a27542674 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -244,8 +244,10 @@ leave:
244 if (actions & DLM_UNLOCK_FREE_LOCK) { 244 if (actions & DLM_UNLOCK_FREE_LOCK) {
245 /* this should always be coupled with list removal */ 245 /* this should always be coupled with list removal */
246 BUG_ON(!(actions & DLM_UNLOCK_REMOVE_LOCK)); 246 BUG_ON(!(actions & DLM_UNLOCK_REMOVE_LOCK));
247 mlog(0, "lock %"MLFu64" should be gone now! refs=%d\n", 247 mlog(0, "lock %u:%llu should be gone now! refs=%d\n",
248 lock->ml.cookie, atomic_read(&lock->lock_refs.refcount)-1); 248 dlm_get_lock_cookie_node(lock->ml.cookie),
249 dlm_get_lock_cookie_seq(lock->ml.cookie),
250 atomic_read(&lock->lock_refs.refcount)-1);
249 dlm_lock_put(lock); 251 dlm_lock_put(lock);
250 } 252 }
251 if (actions & DLM_UNLOCK_CALL_AST) 253 if (actions & DLM_UNLOCK_CALL_AST)
@@ -493,8 +495,9 @@ int dlm_unlock_lock_handler(struct o2net_msg *msg, u32 len, void *data)
493not_found: 495not_found:
494 if (!found) 496 if (!found)
495 mlog(ML_ERROR, "failed to find lock to unlock! " 497 mlog(ML_ERROR, "failed to find lock to unlock! "
496 "cookie=%"MLFu64"\n", 498 "cookie=%u:%llu\n",
497 unlock->cookie); 499 dlm_get_lock_cookie_node(unlock->cookie),
500 dlm_get_lock_cookie_seq(unlock->cookie));
498 else { 501 else {
499 /* send the lksb->status back to the other node */ 502 /* send the lksb->status back to the other node */
500 status = lksb->status; 503 status = lksb->status;
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index e971ec2f8407..84f153aca692 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -231,9 +231,9 @@ static void ocfs2_build_lock_name(enum ocfs2_lock_type type,
231 231
232 BUG_ON(type >= OCFS2_NUM_LOCK_TYPES); 232 BUG_ON(type >= OCFS2_NUM_LOCK_TYPES);
233 233
234 len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"MLFx64"%08x", 234 len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016llx%08x",
235 ocfs2_lock_type_char(type), OCFS2_LOCK_ID_PAD, blkno, 235 ocfs2_lock_type_char(type), OCFS2_LOCK_ID_PAD,
236 generation); 236 (long long)blkno, generation);
237 237
238 BUG_ON(len != (OCFS2_LOCK_ID_MAX_LEN - 1)); 238 BUG_ON(len != (OCFS2_LOCK_ID_MAX_LEN - 1));
239 239
@@ -533,8 +533,8 @@ static void ocfs2_inode_ast_func(void *opaque)
533 533
534 inode = ocfs2_lock_res_inode(lockres); 534 inode = ocfs2_lock_res_inode(lockres);
535 535
536 mlog(0, "AST fired for inode %"MLFu64", l_action = %u, type = %s\n", 536 mlog(0, "AST fired for inode %llu, l_action = %u, type = %s\n",
537 OCFS2_I(inode)->ip_blkno, lockres->l_action, 537 (unsigned long long)OCFS2_I(inode)->ip_blkno, lockres->l_action,
538 ocfs2_lock_type_string(lockres->l_type)); 538 ocfs2_lock_type_string(lockres->l_type));
539 539
540 BUG_ON(!ocfs2_is_inode_lock(lockres)); 540 BUG_ON(!ocfs2_is_inode_lock(lockres));
@@ -544,8 +544,8 @@ static void ocfs2_inode_ast_func(void *opaque)
544 lksb = &(lockres->l_lksb); 544 lksb = &(lockres->l_lksb);
545 if (lksb->status != DLM_NORMAL) { 545 if (lksb->status != DLM_NORMAL) {
546 mlog(ML_ERROR, "ocfs2_inode_ast_func: lksb status value of %u " 546 mlog(ML_ERROR, "ocfs2_inode_ast_func: lksb status value of %u "
547 "on inode %"MLFu64"\n", lksb->status, 547 "on inode %llu\n", lksb->status,
548 OCFS2_I(inode)->ip_blkno); 548 (unsigned long long)OCFS2_I(inode)->ip_blkno);
549 spin_unlock_irqrestore(&lockres->l_lock, flags); 549 spin_unlock_irqrestore(&lockres->l_lock, flags);
550 mlog_exit_void(); 550 mlog_exit_void();
551 return; 551 return;
@@ -646,10 +646,9 @@ static void ocfs2_inode_bast_func(void *opaque, int level)
646 inode = ocfs2_lock_res_inode(lockres); 646 inode = ocfs2_lock_res_inode(lockres);
647 osb = OCFS2_SB(inode->i_sb); 647 osb = OCFS2_SB(inode->i_sb);
648 648
649 mlog(0, "BAST fired for inode %"MLFu64", blocking = %d, level = %d " 649 mlog(0, "BAST fired for inode %llu, blocking %d, level %d type %s\n",
650 "type = %s\n", OCFS2_I(inode)->ip_blkno, level, 650 (unsigned long long)OCFS2_I(inode)->ip_blkno, level,
651 lockres->l_level, 651 lockres->l_level, ocfs2_lock_type_string(lockres->l_type));
652 ocfs2_lock_type_string(lockres->l_type));
653 652
654 ocfs2_generic_bast_func(osb, lockres, level); 653 ocfs2_generic_bast_func(osb, lockres, level);
655 654
@@ -1104,7 +1103,7 @@ int ocfs2_create_new_inode_locks(struct inode *inode)
1104 1103
1105 mlog_entry_void(); 1104 mlog_entry_void();
1106 1105
1107 mlog(0, "Inode %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); 1106 mlog(0, "Inode %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno);
1108 1107
1109 /* NOTE: That we don't increment any of the holder counts, nor 1108 /* NOTE: That we don't increment any of the holder counts, nor
1110 * do we add anything to a journal handle. Since this is 1109 * do we add anything to a journal handle. Since this is
@@ -1149,8 +1148,8 @@ int ocfs2_rw_lock(struct inode *inode, int write)
1149 1148
1150 mlog_entry_void(); 1149 mlog_entry_void();
1151 1150
1152 mlog(0, "inode %"MLFu64" take %s RW lock\n", 1151 mlog(0, "inode %llu take %s RW lock\n",
1153 OCFS2_I(inode)->ip_blkno, 1152 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1154 write ? "EXMODE" : "PRMODE"); 1153 write ? "EXMODE" : "PRMODE");
1155 1154
1156 lockres = &OCFS2_I(inode)->ip_rw_lockres; 1155 lockres = &OCFS2_I(inode)->ip_rw_lockres;
@@ -1173,8 +1172,8 @@ void ocfs2_rw_unlock(struct inode *inode, int write)
1173 1172
1174 mlog_entry_void(); 1173 mlog_entry_void();
1175 1174
1176 mlog(0, "inode %"MLFu64" drop %s RW lock\n", 1175 mlog(0, "inode %llu drop %s RW lock\n",
1177 OCFS2_I(inode)->ip_blkno, 1176 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1178 write ? "EXMODE" : "PRMODE"); 1177 write ? "EXMODE" : "PRMODE");
1179 1178
1180 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1179 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
@@ -1193,8 +1192,8 @@ int ocfs2_data_lock_full(struct inode *inode,
1193 1192
1194 mlog_entry_void(); 1193 mlog_entry_void();
1195 1194
1196 mlog(0, "inode %"MLFu64" take %s DATA lock\n", 1195 mlog(0, "inode %llu take %s DATA lock\n",
1197 OCFS2_I(inode)->ip_blkno, 1196 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1198 write ? "EXMODE" : "PRMODE"); 1197 write ? "EXMODE" : "PRMODE");
1199 1198
1200 /* We'll allow faking a readonly data lock for 1199 /* We'll allow faking a readonly data lock for
@@ -1278,8 +1277,8 @@ void ocfs2_data_unlock(struct inode *inode,
1278 1277
1279 mlog_entry_void(); 1278 mlog_entry_void();
1280 1279
1281 mlog(0, "inode %"MLFu64" drop %s DATA lock\n", 1280 mlog(0, "inode %llu drop %s DATA lock\n",
1282 OCFS2_I(inode)->ip_blkno, 1281 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1283 write ? "EXMODE" : "PRMODE"); 1282 write ? "EXMODE" : "PRMODE");
1284 1283
1285 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1284 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)))
@@ -1462,9 +1461,9 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1462 1461
1463 spin_lock(&oi->ip_lock); 1462 spin_lock(&oi->ip_lock);
1464 if (oi->ip_flags & OCFS2_INODE_DELETED) { 1463 if (oi->ip_flags & OCFS2_INODE_DELETED) {
1465 mlog(0, "Orphaned inode %"MLFu64" was deleted while we " 1464 mlog(0, "Orphaned inode %llu was deleted while we "
1466 "were waiting on a lock. ip_flags = 0x%x\n", 1465 "were waiting on a lock. ip_flags = 0x%x\n",
1467 oi->ip_blkno, oi->ip_flags); 1466 (unsigned long long)oi->ip_blkno, oi->ip_flags);
1468 spin_unlock(&oi->ip_lock); 1467 spin_unlock(&oi->ip_lock);
1469 status = -ENOENT; 1468 status = -ENOENT;
1470 goto bail; 1469 goto bail;
@@ -1485,8 +1484,8 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1485 ocfs2_extent_map_trunc(inode, 0); 1484 ocfs2_extent_map_trunc(inode, 0);
1486 1485
1487 if (ocfs2_meta_lvb_is_trustable(lockres)) { 1486 if (ocfs2_meta_lvb_is_trustable(lockres)) {
1488 mlog(0, "Trusting LVB on inode %"MLFu64"\n", 1487 mlog(0, "Trusting LVB on inode %llu\n",
1489 oi->ip_blkno); 1488 (unsigned long long)oi->ip_blkno);
1490 ocfs2_refresh_inode_from_lvb(inode); 1489 ocfs2_refresh_inode_from_lvb(inode);
1491 } else { 1490 } else {
1492 /* Boo, we have to go to disk. */ 1491 /* Boo, we have to go to disk. */
@@ -1514,15 +1513,16 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1514 } 1513 }
1515 mlog_bug_on_msg(inode->i_generation != 1514 mlog_bug_on_msg(inode->i_generation !=
1516 le32_to_cpu(fe->i_generation), 1515 le32_to_cpu(fe->i_generation),
1517 "Invalid dinode %"MLFu64" disk generation: %u " 1516 "Invalid dinode %llu disk generation: %u "
1518 "inode->i_generation: %u\n", 1517 "inode->i_generation: %u\n",
1519 oi->ip_blkno, le32_to_cpu(fe->i_generation), 1518 (unsigned long long)oi->ip_blkno,
1519 le32_to_cpu(fe->i_generation),
1520 inode->i_generation); 1520 inode->i_generation);
1521 mlog_bug_on_msg(le64_to_cpu(fe->i_dtime) || 1521 mlog_bug_on_msg(le64_to_cpu(fe->i_dtime) ||
1522 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL)), 1522 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL)),
1523 "Stale dinode %"MLFu64" dtime: %"MLFu64" " 1523 "Stale dinode %llu dtime: %llu flags: 0x%x\n",
1524 "flags: 0x%x\n", oi->ip_blkno, 1524 (unsigned long long)oi->ip_blkno,
1525 le64_to_cpu(fe->i_dtime), 1525 (unsigned long long)le64_to_cpu(fe->i_dtime),
1526 le32_to_cpu(fe->i_flags)); 1526 le32_to_cpu(fe->i_flags));
1527 1527
1528 ocfs2_refresh_inode(inode, fe); 1528 ocfs2_refresh_inode(inode, fe);
@@ -1581,8 +1581,8 @@ int ocfs2_meta_lock_full(struct inode *inode,
1581 1581
1582 mlog_entry_void(); 1582 mlog_entry_void();
1583 1583
1584 mlog(0, "inode %"MLFu64", take %s META lock\n", 1584 mlog(0, "inode %llu, take %s META lock\n",
1585 OCFS2_I(inode)->ip_blkno, 1585 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1586 ex ? "EXMODE" : "PRMODE"); 1586 ex ? "EXMODE" : "PRMODE");
1587 1587
1588 status = 0; 1588 status = 0;
@@ -1716,8 +1716,8 @@ void ocfs2_meta_unlock(struct inode *inode,
1716 1716
1717 mlog_entry_void(); 1717 mlog_entry_void();
1718 1718
1719 mlog(0, "inode %"MLFu64" drop %s META lock\n", 1719 mlog(0, "inode %llu drop %s META lock\n",
1720 OCFS2_I(inode)->ip_blkno, 1720 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1721 ex ? "EXMODE" : "PRMODE"); 1721 ex ? "EXMODE" : "PRMODE");
1722 1722
1723 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1723 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)))
@@ -2686,8 +2686,8 @@ static void ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2686 mapping = inode->i_mapping; 2686 mapping = inode->i_mapping;
2687 2687
2688 if (filemap_fdatawrite(mapping)) { 2688 if (filemap_fdatawrite(mapping)) {
2689 mlog(ML_ERROR, "Could not sync inode %"MLFu64" for downconvert!", 2689 mlog(ML_ERROR, "Could not sync inode %llu for downconvert!",
2690 OCFS2_I(inode)->ip_blkno); 2690 (unsigned long long)OCFS2_I(inode)->ip_blkno);
2691 } 2691 }
2692 sync_mapping_buffers(mapping); 2692 sync_mapping_buffers(mapping);
2693 if (blocking == LKM_EXMODE) { 2693 if (blocking == LKM_EXMODE) {
@@ -2717,7 +2717,8 @@ int ocfs2_unblock_data(struct ocfs2_lock_res *lockres,
2717 inode = ocfs2_lock_res_inode(lockres); 2717 inode = ocfs2_lock_res_inode(lockres);
2718 osb = OCFS2_SB(inode->i_sb); 2718 osb = OCFS2_SB(inode->i_sb);
2719 2719
2720 mlog(0, "unblock inode %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); 2720 mlog(0, "unblock inode %llu\n",
2721 (unsigned long long)OCFS2_I(inode)->ip_blkno);
2721 2722
2722 status = ocfs2_generic_unblock_lock(osb, 2723 status = ocfs2_generic_unblock_lock(osb,
2723 lockres, 2724 lockres,
@@ -2726,8 +2727,8 @@ int ocfs2_unblock_data(struct ocfs2_lock_res *lockres,
2726 if (status < 0) 2727 if (status < 0)
2727 mlog_errno(status); 2728 mlog_errno(status);
2728 2729
2729 mlog(0, "inode %"MLFu64", requeue = %d\n", 2730 mlog(0, "inode %llu, requeue = %d\n",
2730 OCFS2_I(inode)->ip_blkno, *requeue); 2731 (unsigned long long)OCFS2_I(inode)->ip_blkno, *requeue);
2731 2732
2732 mlog_exit(status); 2733 mlog_exit(status);
2733 return status; 2734 return status;
@@ -2767,14 +2768,15 @@ int ocfs2_unblock_meta(struct ocfs2_lock_res *lockres,
2767 2768
2768 inode = ocfs2_lock_res_inode(lockres); 2769 inode = ocfs2_lock_res_inode(lockres);
2769 2770
2770 mlog(0, "unblock inode %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); 2771 mlog(0, "unblock inode %llu\n",
2772 (unsigned long long)OCFS2_I(inode)->ip_blkno);
2771 2773
2772 status = ocfs2_do_unblock_meta(inode, requeue); 2774 status = ocfs2_do_unblock_meta(inode, requeue);
2773 if (status < 0) 2775 if (status < 0)
2774 mlog_errno(status); 2776 mlog_errno(status);
2775 2777
2776 mlog(0, "inode %"MLFu64", requeue = %d\n", 2778 mlog(0, "inode %llu, requeue = %d\n",
2777 OCFS2_I(inode)->ip_blkno, *requeue); 2779 (unsigned long long)OCFS2_I(inode)->ip_blkno, *requeue);
2778 2780
2779 mlog_exit(status); 2781 mlog_exit(status);
2780 return status; 2782 return status;
@@ -2893,12 +2895,13 @@ void ocfs2_dump_meta_lvb_info(u64 level,
2893 lockres->l_name, function, line); 2895 lockres->l_name, function, line);
2894 mlog(level, "version: %u, clusters: %u\n", 2896 mlog(level, "version: %u, clusters: %u\n",
2895 be32_to_cpu(lvb->lvb_version), be32_to_cpu(lvb->lvb_iclusters)); 2897 be32_to_cpu(lvb->lvb_version), be32_to_cpu(lvb->lvb_iclusters));
2896 mlog(level, "size: %"MLFu64", uid %u, gid %u, mode 0x%x\n", 2898 mlog(level, "size: %llu, uid %u, gid %u, mode 0x%x\n",
2897 be64_to_cpu(lvb->lvb_isize), be32_to_cpu(lvb->lvb_iuid), 2899 (unsigned long long)be64_to_cpu(lvb->lvb_isize),
2898 be32_to_cpu(lvb->lvb_igid), be16_to_cpu(lvb->lvb_imode)); 2900 be32_to_cpu(lvb->lvb_iuid), be32_to_cpu(lvb->lvb_igid),
2899 mlog(level, "nlink %u, atime_packed 0x%"MLFx64", " 2901 be16_to_cpu(lvb->lvb_imode));
2900 "ctime_packed 0x%"MLFx64", mtime_packed 0x%"MLFx64"\n", 2902 mlog(level, "nlink %u, atime_packed 0x%llx, ctime_packed 0x%llx, "
2901 be16_to_cpu(lvb->lvb_inlink), be64_to_cpu(lvb->lvb_iatime_packed), 2903 "mtime_packed 0x%llx\n", be16_to_cpu(lvb->lvb_inlink),
2902 be64_to_cpu(lvb->lvb_ictime_packed), 2904 (long long)be64_to_cpu(lvb->lvb_iatime_packed),
2903 be64_to_cpu(lvb->lvb_imtime_packed)); 2905 (long long)be64_to_cpu(lvb->lvb_ictime_packed),
2906 (long long)be64_to_cpu(lvb->lvb_imtime_packed));
2904} 2907}
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index 5810160d92a8..ec55ab3c1214 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -95,8 +95,8 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
95 mlog_entry("(0x%p, '%.*s')\n", child, 95 mlog_entry("(0x%p, '%.*s')\n", child,
96 child->d_name.len, child->d_name.name); 96 child->d_name.len, child->d_name.name);
97 97
98 mlog(0, "find parent of directory %"MLFu64"\n", 98 mlog(0, "find parent of directory %llu\n",
99 OCFS2_I(dir)->ip_blkno); 99 (unsigned long long)OCFS2_I(dir)->ip_blkno);
100 100
101 status = ocfs2_meta_lock(dir, NULL, NULL, 0); 101 status = ocfs2_meta_lock(dir, NULL, NULL, 0);
102 if (status < 0) { 102 if (status < 0) {
@@ -115,7 +115,8 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
115 115
116 inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno); 116 inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno);
117 if (IS_ERR(inode)) { 117 if (IS_ERR(inode)) {
118 mlog(ML_ERROR, "Unable to create inode %"MLFu64"\n", blkno); 118 mlog(ML_ERROR, "Unable to create inode %llu\n",
119 (unsigned long long)blkno);
119 parent = ERR_PTR(-EACCES); 120 parent = ERR_PTR(-EACCES);
120 goto bail_unlock; 121 goto bail_unlock;
121 } 122 }
@@ -160,8 +161,8 @@ static int ocfs2_encode_fh(struct dentry *dentry, __be32 *fh, int *max_len,
160 blkno = OCFS2_I(inode)->ip_blkno; 161 blkno = OCFS2_I(inode)->ip_blkno;
161 generation = inode->i_generation; 162 generation = inode->i_generation;
162 163
163 mlog(0, "Encoding fh: blkno: %"MLFu64", generation: %u\n", 164 mlog(0, "Encoding fh: blkno: %llu, generation: %u\n",
164 blkno, generation); 165 (unsigned long long)blkno, generation);
165 166
166 len = 3; 167 len = 3;
167 fh[0] = cpu_to_le32((u32)(blkno >> 32)); 168 fh[0] = cpu_to_le32((u32)(blkno >> 32));
@@ -186,8 +187,8 @@ static int ocfs2_encode_fh(struct dentry *dentry, __be32 *fh, int *max_len,
186 len = 6; 187 len = 6;
187 type = 2; 188 type = 2;
188 189
189 mlog(0, "Encoding parent: blkno: %"MLFu64", generation: %u\n", 190 mlog(0, "Encoding parent: blkno: %llu, generation: %u\n",
190 blkno, generation); 191 (unsigned long long)blkno, generation);
191 } 192 }
192 193
193 *max_len = len; 194 *max_len = len;
@@ -220,16 +221,17 @@ static struct dentry *ocfs2_decode_fh(struct super_block *sb, __be32 *fh,
220 parent.ih_blkno |= (u64)le32_to_cpu(fh[4]); 221 parent.ih_blkno |= (u64)le32_to_cpu(fh[4]);
221 parent.ih_generation = le32_to_cpu(fh[5]); 222 parent.ih_generation = le32_to_cpu(fh[5]);
222 223
223 mlog(0, "Decoding parent: blkno: %"MLFu64", generation: %u\n", 224 mlog(0, "Decoding parent: blkno: %llu, generation: %u\n",
224 parent.ih_blkno, parent.ih_generation); 225 (unsigned long long)parent.ih_blkno,
226 parent.ih_generation);
225 } 227 }
226 228
227 handle.ih_blkno = (u64)le32_to_cpu(fh[0]) << 32; 229 handle.ih_blkno = (u64)le32_to_cpu(fh[0]) << 32;
228 handle.ih_blkno |= (u64)le32_to_cpu(fh[1]); 230 handle.ih_blkno |= (u64)le32_to_cpu(fh[1]);
229 handle.ih_generation = le32_to_cpu(fh[2]); 231 handle.ih_generation = le32_to_cpu(fh[2]);
230 232
231 mlog(0, "Encoding fh: blkno: %"MLFu64", generation: %u\n", 233 mlog(0, "Encoding fh: blkno: %llu, generation: %u\n",
232 handle.ih_blkno, handle.ih_generation); 234 (unsigned long long)handle.ih_blkno, handle.ih_generation);
233 235
234 ret = ocfs2_export_ops.find_exported_dentry(sb, &handle, &parent, 236 ret = ocfs2_export_ops.find_exported_dentry(sb, &handle, &parent,
235 acceptable, context); 237 acceptable, context);
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index e6f207eebab4..4601fc256f11 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -182,10 +182,10 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
182 if (rec_end > OCFS2_I(inode)->ip_clusters) { 182 if (rec_end > OCFS2_I(inode)->ip_clusters) {
183 mlog_errno(ret); 183 mlog_errno(ret);
184 ocfs2_error(inode->i_sb, 184 ocfs2_error(inode->i_sb,
185 "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n", 185 "Extent %d at e_blkno %llu of inode %llu goes past ip_clusters of %u\n",
186 i, 186 i,
187 le64_to_cpu(rec->e_blkno), 187 (unsigned long long)le64_to_cpu(rec->e_blkno),
188 OCFS2_I(inode)->ip_blkno, 188 (unsigned long long)OCFS2_I(inode)->ip_blkno,
189 OCFS2_I(inode)->ip_clusters); 189 OCFS2_I(inode)->ip_clusters);
190 goto out_free; 190 goto out_free;
191 } 191 }
@@ -233,11 +233,11 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
233 if (blkno) { 233 if (blkno) {
234 mlog_errno(ret); 234 mlog_errno(ret);
235 ocfs2_error(inode->i_sb, 235 ocfs2_error(inode->i_sb,
236 "Multiple extents for (cpos = %u, clusters = %u) on inode %"MLFu64"; e_blkno %"MLFu64" and rec %d at e_blkno %"MLFu64"\n", 236 "Multiple extents for (cpos = %u, clusters = %u) on inode %llu; e_blkno %llu and rec %d at e_blkno %llu\n",
237 cpos, clusters, 237 cpos, clusters,
238 OCFS2_I(inode)->ip_blkno, 238 (unsigned long long)OCFS2_I(inode)->ip_blkno,
239 blkno, i, 239 (unsigned long long)blkno, i,
240 le64_to_cpu(rec->e_blkno)); 240 (unsigned long long)le64_to_cpu(rec->e_blkno));
241 goto out_free; 241 goto out_free;
242 } 242 }
243 243
@@ -251,9 +251,9 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
251 ret = -EBADR; 251 ret = -EBADR;
252 if (!blkno) { 252 if (!blkno) {
253 ocfs2_error(inode->i_sb, 253 ocfs2_error(inode->i_sb,
254 "No record found for (cpos = %u, clusters = %u) on inode %"MLFu64"\n", 254 "No record found for (cpos = %u, clusters = %u) on inode %llu\n",
255 cpos, clusters, 255 cpos, clusters,
256 OCFS2_I(inode)->ip_blkno); 256 (unsigned long long)OCFS2_I(inode)->ip_blkno);
257 mlog_errno(ret); 257 mlog_errno(ret);
258 goto out_free; 258 goto out_free;
259 } 259 }
@@ -288,10 +288,10 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
288 ret = -EBADR; 288 ret = -EBADR;
289 mlog_errno(ret); 289 mlog_errno(ret);
290 ocfs2_error(inode->i_sb, 290 ocfs2_error(inode->i_sb,
291 "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n", 291 "Extent %d at e_blkno %llu of inode %llu goes past ip_clusters of %u\n",
292 i, 292 i,
293 le64_to_cpu(rec->e_blkno), 293 (unsigned long long)le64_to_cpu(rec->e_blkno),
294 OCFS2_I(inode)->ip_blkno, 294 (unsigned long long)OCFS2_I(inode)->ip_blkno,
295 OCFS2_I(inode)->ip_clusters); 295 OCFS2_I(inode)->ip_clusters);
296 return ret; 296 return ret;
297 } 297 }
@@ -557,9 +557,9 @@ static int ocfs2_extent_map_insert(struct inode *inode,
557 ret = -EBADR; 557 ret = -EBADR;
558 mlog_errno(ret); 558 mlog_errno(ret);
559 ocfs2_error(inode->i_sb, 559 ocfs2_error(inode->i_sb,
560 "Zero e_clusters on non-tail extent record at e_blkno %"MLFu64" on inode %"MLFu64"\n", 560 "Zero e_clusters on non-tail extent record at e_blkno %llu on inode %llu\n",
561 le64_to_cpu(rec->e_blkno), 561 (unsigned long long)le64_to_cpu(rec->e_blkno),
562 OCFS2_I(inode)->ip_blkno); 562 (unsigned long long)OCFS2_I(inode)->ip_blkno);
563 return ret; 563 return ret;
564 } 564 }
565 565
@@ -660,10 +660,10 @@ int ocfs2_extent_map_append(struct inode *inode,
660 mlog_bug_on_msg((le32_to_cpu(rec->e_cpos) + 660 mlog_bug_on_msg((le32_to_cpu(rec->e_cpos) +
661 le32_to_cpu(rec->e_clusters)) != 661 le32_to_cpu(rec->e_clusters)) !=
662 (em->em_clusters + new_clusters), 662 (em->em_clusters + new_clusters),
663 "Inode %"MLFu64":\n" 663 "Inode %llu:\n"
664 "rec->e_cpos = %u + rec->e_clusters = %u = %u\n" 664 "rec->e_cpos = %u + rec->e_clusters = %u = %u\n"
665 "em->em_clusters = %u + new_clusters = %u = %u\n", 665 "em->em_clusters = %u + new_clusters = %u = %u\n",
666 OCFS2_I(inode)->ip_blkno, 666 (unsigned long long)OCFS2_I(inode)->ip_blkno,
667 le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_clusters), 667 le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_clusters),
668 le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters), 668 le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters),
669 em->em_clusters, new_clusters, 669 em->em_clusters, new_clusters,
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 8a4048b55fdc..4b4cbadd5838 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -220,8 +220,9 @@ static int ocfs2_truncate_file(struct inode *inode,
220 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 220 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
221 struct ocfs2_truncate_context *tc = NULL; 221 struct ocfs2_truncate_context *tc = NULL;
222 222
223 mlog_entry("(inode = %"MLFu64", new_i_size = %"MLFu64"\n", 223 mlog_entry("(inode = %llu, new_i_size = %llu\n",
224 OCFS2_I(inode)->ip_blkno, new_i_size); 224 (unsigned long long)OCFS2_I(inode)->ip_blkno,
225 (unsigned long long)new_i_size);
225 226
226 truncate_inode_pages(inode->i_mapping, new_i_size); 227 truncate_inode_pages(inode->i_mapping, new_i_size);
227 228
@@ -233,23 +234,26 @@ static int ocfs2_truncate_file(struct inode *inode,
233 } 234 }
234 235
235 mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode), 236 mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode),
236 "Inode %"MLFu64", inode i_size = %lld != di " 237 "Inode %llu, inode i_size = %lld != di "
237 "i_size = %"MLFu64", i_flags = 0x%x\n", 238 "i_size = %llu, i_flags = 0x%x\n",
238 OCFS2_I(inode)->ip_blkno, 239 (unsigned long long)OCFS2_I(inode)->ip_blkno,
239 i_size_read(inode), 240 i_size_read(inode),
240 le64_to_cpu(fe->i_size), le32_to_cpu(fe->i_flags)); 241 (unsigned long long)le64_to_cpu(fe->i_size),
242 le32_to_cpu(fe->i_flags));
241 243
242 if (new_i_size > le64_to_cpu(fe->i_size)) { 244 if (new_i_size > le64_to_cpu(fe->i_size)) {
243 mlog(0, "asked to truncate file with size (%"MLFu64") " 245 mlog(0, "asked to truncate file with size (%llu) to size (%llu)!\n",
244 "to size (%"MLFu64")!\n", 246 (unsigned long long)le64_to_cpu(fe->i_size),
245 le64_to_cpu(fe->i_size), new_i_size); 247 (unsigned long long)new_i_size);
246 status = -EINVAL; 248 status = -EINVAL;
247 mlog_errno(status); 249 mlog_errno(status);
248 goto bail; 250 goto bail;
249 } 251 }
250 252
251 mlog(0, "inode %"MLFu64", i_size = %"MLFu64", new_i_size = %"MLFu64"\n", 253 mlog(0, "inode %llu, i_size = %llu, new_i_size = %llu\n",
252 le64_to_cpu(fe->i_blkno), le64_to_cpu(fe->i_size), new_i_size); 254 (unsigned long long)le64_to_cpu(fe->i_blkno),
255 (unsigned long long)le64_to_cpu(fe->i_size),
256 (unsigned long long)new_i_size);
253 257
254 /* lets handle the simple truncate cases before doing any more 258 /* lets handle the simple truncate cases before doing any more
255 * cluster locking. */ 259 * cluster locking. */
@@ -378,8 +382,8 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb,
378 } 382 }
379 383
380 block = ocfs2_clusters_to_blocks(osb->sb, bit_off); 384 block = ocfs2_clusters_to_blocks(osb->sb, bit_off);
381 mlog(0, "Allocating %u clusters at block %u for inode %"MLFu64"\n", 385 mlog(0, "Allocating %u clusters at block %u for inode %llu\n",
382 num_bits, bit_off, OCFS2_I(inode)->ip_blkno); 386 num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno);
383 status = ocfs2_insert_extent(osb, handle, inode, fe_bh, block, 387 status = ocfs2_insert_extent(osb, handle, inode, fe_bh, block,
384 num_bits, meta_ac); 388 num_bits, meta_ac);
385 if (status < 0) { 389 if (status < 0) {
@@ -449,9 +453,9 @@ static int ocfs2_extend_allocation(struct inode *inode,
449restart_all: 453restart_all:
450 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); 454 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters);
451 455
452 mlog(0, "extend inode %"MLFu64", i_size = %lld, fe->i_clusters = %u, " 456 mlog(0, "extend inode %llu, i_size = %lld, fe->i_clusters = %u, "
453 "clusters_to_add = %u\n", 457 "clusters_to_add = %u\n",
454 OCFS2_I(inode)->ip_blkno, i_size_read(inode), 458 (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode),
455 fe->i_clusters, clusters_to_add); 459 fe->i_clusters, clusters_to_add);
456 460
457 handle = ocfs2_alloc_handle(osb); 461 handle = ocfs2_alloc_handle(osb);
@@ -569,8 +573,8 @@ restarted_transaction:
569 } 573 }
570 } 574 }
571 575
572 mlog(0, "fe: i_clusters = %u, i_size=%"MLFu64"\n", 576 mlog(0, "fe: i_clusters = %u, i_size=%llu\n",
573 fe->i_clusters, fe->i_size); 577 fe->i_clusters, (unsigned long long)fe->i_size);
574 mlog(0, "inode: ip_clusters=%u, i_size=%lld\n", 578 mlog(0, "inode: ip_clusters=%u, i_size=%lld\n",
575 OCFS2_I(inode)->ip_clusters, i_size_read(inode)); 579 OCFS2_I(inode)->ip_clusters, i_size_read(inode));
576 580
@@ -865,8 +869,8 @@ static int ocfs2_write_remove_suid(struct inode *inode)
865 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 869 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
866 struct ocfs2_dinode *di; 870 struct ocfs2_dinode *di;
867 871
868 mlog_entry("(Inode %"MLFu64", mode 0%o)\n", oi->ip_blkno, 872 mlog_entry("(Inode %llu, mode 0%o)\n",
869 inode->i_mode); 873 (unsigned long long)oi->ip_blkno, inode->i_mode);
870 874
871 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 875 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS);
872 if (handle == NULL) { 876 if (handle == NULL) {
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 315472a5c192..327a5b7b86ed 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -95,7 +95,7 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno)
95 struct super_block *sb = osb->sb; 95 struct super_block *sb = osb->sb;
96 struct ocfs2_find_inode_args args; 96 struct ocfs2_find_inode_args args;
97 97
98 mlog_entry("(blkno = %"MLFu64")\n", blkno); 98 mlog_entry("(blkno = %llu)\n", (unsigned long long)blkno);
99 99
100 /* Ok. By now we've either got the offsets passed to us by the 100 /* Ok. By now we've either got the offsets passed to us by the
101 * caller, or we just pulled them off the bh. Lets do some 101 * caller, or we just pulled them off the bh. Lets do some
@@ -134,8 +134,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno)
134 134
135bail: 135bail:
136 if (!IS_ERR(inode)) { 136 if (!IS_ERR(inode)) {
137 mlog(0, "returning inode with number %"MLFu64"\n", 137 mlog(0, "returning inode with number %llu\n",
138 OCFS2_I(inode)->ip_blkno); 138 (unsigned long long)OCFS2_I(inode)->ip_blkno);
139 mlog_exit_ptr(inode); 139 mlog_exit_ptr(inode);
140 } else 140 } else
141 mlog_errno(PTR_ERR(inode)); 141 mlog_errno(PTR_ERR(inode));
@@ -219,7 +219,8 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
219 struct ocfs2_super *osb; 219 struct ocfs2_super *osb;
220 int status = -EINVAL; 220 int status = -EINVAL;
221 221
222 mlog_entry("(0x%p, size:%"MLFu64")\n", inode, fe->i_size); 222 mlog_entry("(0x%p, size:%llu)\n", inode,
223 (unsigned long long)fe->i_size);
223 224
224 sb = inode->i_sb; 225 sb = inode->i_sb;
225 osb = OCFS2_SB(sb); 226 osb = OCFS2_SB(sb);
@@ -228,9 +229,10 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
228 * today. change if needed. */ 229 * today. change if needed. */
229 if (!OCFS2_IS_VALID_DINODE(fe) || 230 if (!OCFS2_IS_VALID_DINODE(fe) ||
230 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { 231 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
231 mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%"MLFu64", " 232 mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%llu, "
232 "signature = %.*s, flags = 0x%x\n", 233 "signature = %.*s, flags = 0x%x\n",
233 inode->i_ino, le64_to_cpu(fe->i_blkno), 7, 234 inode->i_ino,
235 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
234 fe->i_signature, le32_to_cpu(fe->i_flags)); 236 fe->i_signature, le32_to_cpu(fe->i_flags));
235 goto bail; 237 goto bail;
236 } 238 }
@@ -268,8 +270,9 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
268 270
269 if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno)) 271 if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
270 mlog(ML_ERROR, 272 mlog(ML_ERROR,
271 "ip_blkno %"MLFu64" != i_blkno %"MLFu64"!\n", 273 "ip_blkno %llu != i_blkno %llu!\n",
272 OCFS2_I(inode)->ip_blkno, fe->i_blkno); 274 (unsigned long long)OCFS2_I(inode)->ip_blkno,
275 (unsigned long long)fe->i_blkno);
273 276
274 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); 277 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
275 OCFS2_I(inode)->ip_orphaned_slot = OCFS2_INVALID_SLOT; 278 OCFS2_I(inode)->ip_orphaned_slot = OCFS2_INVALID_SLOT;
@@ -278,8 +281,8 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
278 inode->i_ino = ino_from_blkno(inode->i_sb, 281 inode->i_ino = ino_from_blkno(inode->i_sb,
279 le64_to_cpu(fe->i_blkno)); 282 le64_to_cpu(fe->i_blkno));
280 283
281 mlog(0, "blkno = %"MLFu64", ino = %lu, create_ino = %s\n", 284 mlog(0, "blkno = %llu, ino = %lu, create_ino = %s\n",
282 fe->i_blkno, inode->i_ino, create_ino ? "true" : "false"); 285 (unsigned long long)fe->i_blkno, inode->i_ino, create_ino ? "true" : "false");
283 286
284 inode->i_nlink = le16_to_cpu(fe->i_links_count); 287 inode->i_nlink = le16_to_cpu(fe->i_links_count);
285 288
@@ -371,8 +374,8 @@ static int ocfs2_read_locked_inode(struct inode *inode,
371 374
372 fe = (struct ocfs2_dinode *) bh->b_data; 375 fe = (struct ocfs2_dinode *) bh->b_data;
373 if (!OCFS2_IS_VALID_DINODE(fe)) { 376 if (!OCFS2_IS_VALID_DINODE(fe)) {
374 mlog(ML_ERROR, "Invalid dinode #%"MLFu64": signature = %.*s\n", 377 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
375 fe->i_blkno, 7, fe->i_signature); 378 (unsigned long long)fe->i_blkno, 7, fe->i_signature);
376 make_bad_inode(inode); 379 make_bad_inode(inode);
377 goto bail; 380 goto bail;
378 } 381 }
@@ -386,8 +389,8 @@ static int ocfs2_read_locked_inode(struct inode *inode,
386 389
387 status = -EINVAL; 390 status = -EINVAL;
388 if (ocfs2_populate_inode(inode, fe, 0) < 0) { 391 if (ocfs2_populate_inode(inode, fe, 0) < 0) {
389 mlog(ML_ERROR, "populate inode failed! i_blkno=%"MLFu64", " 392 mlog(ML_ERROR, "populate failed! i_blkno=%llu, i_ino=%lu\n",
390 "i_ino=%lu\n", fe->i_blkno, inode->i_ino); 393 (unsigned long long)fe->i_blkno, inode->i_ino);
391 make_bad_inode(inode); 394 make_bad_inode(inode);
392 goto bail; 395 goto bail;
393 } 396 }
@@ -675,8 +678,8 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode)
675 * never get here as system file inodes should always have a 678 * never get here as system file inodes should always have a
676 * positive link count. */ 679 * positive link count. */
677 if (oi->ip_flags & OCFS2_INODE_SYSTEM_FILE) { 680 if (oi->ip_flags & OCFS2_INODE_SYSTEM_FILE) {
678 mlog(ML_ERROR, "Skipping delete of system file %"MLFu64".\n", 681 mlog(ML_ERROR, "Skipping delete of system file %llu\n",
679 oi->ip_blkno); 682 (unsigned long long)oi->ip_blkno);
680 goto bail_unlock; 683 goto bail_unlock;
681 } 684 }
682 685
@@ -715,16 +718,16 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
715 * ocfs2_delete_inode, another node might have asked to delete 718 * ocfs2_delete_inode, another node might have asked to delete
716 * the inode. Recheck our flags to catch this. */ 719 * the inode. Recheck our flags to catch this. */
717 if (!ocfs2_inode_is_valid_to_delete(inode)) { 720 if (!ocfs2_inode_is_valid_to_delete(inode)) {
718 mlog(0, "Skipping delete of %"MLFu64" because flags changed\n", 721 mlog(0, "Skipping delete of %llu because flags changed\n",
719 oi->ip_blkno); 722 (unsigned long long)oi->ip_blkno);
720 goto bail; 723 goto bail;
721 } 724 }
722 725
723 /* Now that we have an up to date inode, we can double check 726 /* Now that we have an up to date inode, we can double check
724 * the link count. */ 727 * the link count. */
725 if (inode->i_nlink) { 728 if (inode->i_nlink) {
726 mlog(0, "Skipping delete of %"MLFu64" because nlink = %u\n", 729 mlog(0, "Skipping delete of %llu because nlink = %u\n",
727 oi->ip_blkno, inode->i_nlink); 730 (unsigned long long)oi->ip_blkno, inode->i_nlink);
728 goto bail; 731 goto bail;
729 } 732 }
730 733
@@ -734,9 +737,11 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
734 /* for lack of a better error? */ 737 /* for lack of a better error? */
735 status = -EEXIST; 738 status = -EEXIST;
736 mlog(ML_ERROR, 739 mlog(ML_ERROR,
737 "Inode %"MLFu64" (on-disk %"MLFu64") not orphaned! " 740 "Inode %llu (on-disk %llu) not orphaned! "
738 "Disk flags 0x%x, inode flags 0x%x\n", 741 "Disk flags 0x%x, inode flags 0x%x\n",
739 oi->ip_blkno, di->i_blkno, di->i_flags, oi->ip_flags); 742 (unsigned long long)oi->ip_blkno,
743 (unsigned long long)di->i_blkno, di->i_flags,
744 oi->ip_flags);
740 goto bail; 745 goto bail;
741 } 746 }
742 747
@@ -753,8 +758,8 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
753 * disk and let them worry about deleting it. */ 758 * disk and let them worry about deleting it. */
754 if (status == -EBUSY) { 759 if (status == -EBUSY) {
755 status = 0; 760 status = 0;
756 mlog(0, "Skipping delete of %"MLFu64" because it is in use on" 761 mlog(0, "Skipping delete of %llu because it is in use on"
757 "other nodes\n", oi->ip_blkno); 762 "other nodes\n", (unsigned long long)oi->ip_blkno);
758 goto bail; 763 goto bail;
759 } 764 }
760 if (status < 0) { 765 if (status < 0) {
@@ -768,13 +773,13 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
768 * into. This may happen during node death and 773 * into. This may happen during node death and
769 * recovery knows how to clean it up so we can safely 774 * recovery knows how to clean it up so we can safely
770 * ignore this inode for now on. */ 775 * ignore this inode for now on. */
771 mlog(0, "Nobody knew where inode %"MLFu64" was orphaned!\n", 776 mlog(0, "Nobody knew where inode %llu was orphaned!\n",
772 oi->ip_blkno); 777 (unsigned long long)oi->ip_blkno);
773 } else { 778 } else {
774 *wipe = 1; 779 *wipe = 1;
775 780
776 mlog(0, "Inode %"MLFu64" is ok to wipe from orphan dir %d\n", 781 mlog(0, "Inode %llu is ok to wipe from orphan dir %d\n",
777 oi->ip_blkno, oi->ip_orphaned_slot); 782 (unsigned long long)oi->ip_blkno, oi->ip_orphaned_slot);
778 } 783 }
779 spin_unlock(&oi->ip_lock); 784 spin_unlock(&oi->ip_lock);
780 785
@@ -788,8 +793,8 @@ bail:
788static void ocfs2_cleanup_delete_inode(struct inode *inode, 793static void ocfs2_cleanup_delete_inode(struct inode *inode,
789 int sync_data) 794 int sync_data)
790{ 795{
791 mlog(0, "Cleanup inode %"MLFu64", sync = %d\n", 796 mlog(0, "Cleanup inode %llu, sync = %d\n",
792 OCFS2_I(inode)->ip_blkno, sync_data); 797 (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data);
793 if (sync_data) 798 if (sync_data)
794 write_inode_now(inode, 1); 799 write_inode_now(inode, 1);
795 truncate_inode_pages(&inode->i_data, 0); 800 truncate_inode_pages(&inode->i_data, 0);
@@ -897,8 +902,8 @@ void ocfs2_clear_inode(struct inode *inode)
897 if (!inode) 902 if (!inode)
898 goto bail; 903 goto bail;
899 904
900 mlog(0, "Clearing inode: %"MLFu64", nlink = %u\n", 905 mlog(0, "Clearing inode: %llu, nlink = %u\n",
901 OCFS2_I(inode)->ip_blkno, inode->i_nlink); 906 (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_nlink);
902 907
903 mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, 908 mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
904 "Inode=%lu\n", inode->i_ino); 909 "Inode=%lu\n", inode->i_ino);
@@ -919,8 +924,8 @@ void ocfs2_clear_inode(struct inode *inode)
919 ocfs2_checkpoint_inode(inode); 924 ocfs2_checkpoint_inode(inode);
920 925
921 mlog_bug_on_msg(!list_empty(&oi->ip_io_markers), 926 mlog_bug_on_msg(!list_empty(&oi->ip_io_markers),
922 "Clear inode of %"MLFu64", inode has io markers\n", 927 "Clear inode of %llu, inode has io markers\n",
923 oi->ip_blkno); 928 (unsigned long long)oi->ip_blkno);
924 929
925 ocfs2_extent_map_drop(inode, 0); 930 ocfs2_extent_map_drop(inode, 0);
926 ocfs2_extent_map_init(inode); 931 ocfs2_extent_map_init(inode);
@@ -936,20 +941,20 @@ void ocfs2_clear_inode(struct inode *inode)
936 ocfs2_metadata_cache_purge(inode); 941 ocfs2_metadata_cache_purge(inode);
937 942
938 mlog_bug_on_msg(oi->ip_metadata_cache.ci_num_cached, 943 mlog_bug_on_msg(oi->ip_metadata_cache.ci_num_cached,
939 "Clear inode of %"MLFu64", inode has %u cache items\n", 944 "Clear inode of %llu, inode has %u cache items\n",
940 oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached); 945 (unsigned long long)oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached);
941 946
942 mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE), 947 mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE),
943 "Clear inode of %"MLFu64", inode has a bad flag\n", 948 "Clear inode of %llu, inode has a bad flag\n",
944 oi->ip_blkno); 949 (unsigned long long)oi->ip_blkno);
945 950
946 mlog_bug_on_msg(spin_is_locked(&oi->ip_lock), 951 mlog_bug_on_msg(spin_is_locked(&oi->ip_lock),
947 "Clear inode of %"MLFu64", inode is locked\n", 952 "Clear inode of %llu, inode is locked\n",
948 oi->ip_blkno); 953 (unsigned long long)oi->ip_blkno);
949 954
950 mlog_bug_on_msg(!mutex_trylock(&oi->ip_io_mutex), 955 mlog_bug_on_msg(!mutex_trylock(&oi->ip_io_mutex),
951 "Clear inode of %"MLFu64", io_mutex is locked\n", 956 "Clear inode of %llu, io_mutex is locked\n",
952 oi->ip_blkno); 957 (unsigned long long)oi->ip_blkno);
953 mutex_unlock(&oi->ip_io_mutex); 958 mutex_unlock(&oi->ip_io_mutex);
954 959
955 /* 960 /*
@@ -957,19 +962,19 @@ void ocfs2_clear_inode(struct inode *inode)
957 * kernel 1, world 0 962 * kernel 1, world 0
958 */ 963 */
959 mlog_bug_on_msg(!down_write_trylock(&oi->ip_alloc_sem), 964 mlog_bug_on_msg(!down_write_trylock(&oi->ip_alloc_sem),
960 "Clear inode of %"MLFu64", alloc_sem is locked\n", 965 "Clear inode of %llu, alloc_sem is locked\n",
961 oi->ip_blkno); 966 (unsigned long long)oi->ip_blkno);
962 up_write(&oi->ip_alloc_sem); 967 up_write(&oi->ip_alloc_sem);
963 968
964 mlog_bug_on_msg(oi->ip_open_count, 969 mlog_bug_on_msg(oi->ip_open_count,
965 "Clear inode of %"MLFu64" has open count %d\n", 970 "Clear inode of %llu has open count %d\n",
966 oi->ip_blkno, oi->ip_open_count); 971 (unsigned long long)oi->ip_blkno, oi->ip_open_count);
967 mlog_bug_on_msg(!list_empty(&oi->ip_handle_list), 972 mlog_bug_on_msg(!list_empty(&oi->ip_handle_list),
968 "Clear inode of %"MLFu64" has non empty handle list\n", 973 "Clear inode of %llu has non empty handle list\n",
969 oi->ip_blkno); 974 (unsigned long long)oi->ip_blkno);
970 mlog_bug_on_msg(oi->ip_handle, 975 mlog_bug_on_msg(oi->ip_handle,
971 "Clear inode of %"MLFu64" has non empty handle pointer\n", 976 "Clear inode of %llu has non empty handle pointer\n",
972 oi->ip_blkno); 977 (unsigned long long)oi->ip_blkno);
973 978
974 /* Clear all other flags. */ 979 /* Clear all other flags. */
975 oi->ip_flags = OCFS2_INODE_CACHE_INLINE; 980 oi->ip_flags = OCFS2_INODE_CACHE_INLINE;
@@ -991,8 +996,8 @@ void ocfs2_drop_inode(struct inode *inode)
991 996
992 mlog_entry_void(); 997 mlog_entry_void();
993 998
994 mlog(0, "Drop inode %"MLFu64", nlink = %u, ip_flags = 0x%x\n", 999 mlog(0, "Drop inode %llu, nlink = %u, ip_flags = 0x%x\n",
995 oi->ip_blkno, inode->i_nlink, oi->ip_flags); 1000 (unsigned long long)oi->ip_blkno, inode->i_nlink, oi->ip_flags);
996 1001
997 /* Testing ip_orphaned_slot here wouldn't work because we may 1002 /* Testing ip_orphaned_slot here wouldn't work because we may
998 * not have gotten a delete_inode vote from any other nodes 1003 * not have gotten a delete_inode vote from any other nodes
@@ -1069,8 +1074,8 @@ int ocfs2_inode_revalidate(struct dentry *dentry)
1069 struct inode *inode = dentry->d_inode; 1074 struct inode *inode = dentry->d_inode;
1070 int status = 0; 1075 int status = 0;
1071 1076
1072 mlog_entry("(inode = 0x%p, ino = %"MLFu64")\n", inode, 1077 mlog_entry("(inode = 0x%p, ino = %llu)\n", inode,
1073 inode ? OCFS2_I(inode)->ip_blkno : 0ULL); 1078 inode ? (unsigned long long)OCFS2_I(inode)->ip_blkno : 0ULL);
1074 1079
1075 if (!inode) { 1080 if (!inode) {
1076 mlog(0, "eep, no inode!\n"); 1081 mlog(0, "eep, no inode!\n");
@@ -1114,7 +1119,8 @@ int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle,
1114 int status; 1119 int status;
1115 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; 1120 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
1116 1121
1117 mlog_entry("(inode %"MLFu64")\n", OCFS2_I(inode)->ip_blkno); 1122 mlog_entry("(inode %llu)\n",
1123 (unsigned long long)OCFS2_I(inode)->ip_blkno);
1118 1124
1119 status = ocfs2_journal_access(handle, inode, bh, 1125 status = ocfs2_journal_access(handle, inode, bh,
1120 OCFS2_JOURNAL_ACCESS_WRITE); 1126 OCFS2_JOURNAL_ACCESS_WRITE);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4be801f4559b..ae3440ca083c 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -503,8 +503,8 @@ static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
503 ocfs2_meta_unlock(inode, 1); 503 ocfs2_meta_unlock(inode, 1);
504 if (atomic_read(&inode->i_count) == 1) 504 if (atomic_read(&inode->i_count) == 1)
505 mlog(ML_ERROR, 505 mlog(ML_ERROR,
506 "Inode %"MLFu64", I'm doing a last iput for!", 506 "Inode %llu, I'm doing a last iput for!",
507 OCFS2_I(inode)->ip_blkno); 507 (unsigned long long)OCFS2_I(inode)->ip_blkno);
508 iput(inode); 508 iput(inode);
509 kmem_cache_free(ocfs2_lock_cache, lock); 509 kmem_cache_free(ocfs2_lock_cache, lock);
510 } 510 }
@@ -640,8 +640,9 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
640 /* This is called from startup/shutdown which will 640 /* This is called from startup/shutdown which will
641 * handle the errors in a specific manner, so no need 641 * handle the errors in a specific manner, so no need
642 * to call ocfs2_error() here. */ 642 * to call ocfs2_error() here. */
643 mlog(ML_ERROR, "Journal dinode %"MLFu64" has invalid " 643 mlog(ML_ERROR, "Journal dinode %llu has invalid "
644 "signature: %.*s", fe->i_blkno, 7, fe->i_signature); 644 "signature: %.*s", (unsigned long long)fe->i_blkno, 7,
645 fe->i_signature);
645 status = -EIO; 646 status = -EIO;
646 goto out; 647 goto out;
647 } 648 }
@@ -934,8 +935,8 @@ void ocfs2_complete_recovery(void *data)
934 935
935 la_dinode = item->lri_la_dinode; 936 la_dinode = item->lri_la_dinode;
936 if (la_dinode) { 937 if (la_dinode) {
937 mlog(0, "Clean up local alloc %"MLFu64"\n", 938 mlog(0, "Clean up local alloc %llu\n",
938 la_dinode->i_blkno); 939 (unsigned long long)la_dinode->i_blkno);
939 940
940 ret = ocfs2_complete_local_alloc_recovery(osb, 941 ret = ocfs2_complete_local_alloc_recovery(osb,
941 la_dinode); 942 la_dinode);
@@ -947,8 +948,8 @@ void ocfs2_complete_recovery(void *data)
947 948
948 tl_dinode = item->lri_tl_dinode; 949 tl_dinode = item->lri_tl_dinode;
949 if (tl_dinode) { 950 if (tl_dinode) {
950 mlog(0, "Clean up truncate log %"MLFu64"\n", 951 mlog(0, "Clean up truncate log %llu\n",
951 tl_dinode->i_blkno); 952 (unsigned long long)tl_dinode->i_blkno);
952 953
953 ret = ocfs2_complete_truncate_log_recovery(osb, 954 ret = ocfs2_complete_truncate_log_recovery(osb,
954 tl_dinode); 955 tl_dinode);
@@ -1473,11 +1474,11 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
1473 if (de->file_type > OCFS2_FT_MAX) { 1474 if (de->file_type > OCFS2_FT_MAX) {
1474 mlog(ML_ERROR, 1475 mlog(ML_ERROR,
1475 "block %llu contains invalid de: " 1476 "block %llu contains invalid de: "
1476 "inode = %"MLFu64", rec_len = %u, " 1477 "inode = %llu, rec_len = %u, "
1477 "name_len = %u, file_type = %u, " 1478 "name_len = %u, file_type = %u, "
1478 "name='%.*s'\n", 1479 "name='%.*s'\n",
1479 (unsigned long long)bh->b_blocknr, 1480 (unsigned long long)bh->b_blocknr,
1480 le64_to_cpu(de->inode), 1481 (unsigned long long)le64_to_cpu(de->inode),
1481 le16_to_cpu(de->rec_len), 1482 le16_to_cpu(de->rec_len),
1482 de->name_len, 1483 de->name_len,
1483 de->file_type, 1484 de->file_type,
@@ -1494,8 +1495,8 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
1494 if (IS_ERR(iter)) 1495 if (IS_ERR(iter))
1495 continue; 1496 continue;
1496 1497
1497 mlog(0, "queue orphan %"MLFu64"\n", 1498 mlog(0, "queue orphan %llu\n",
1498 OCFS2_I(iter)->ip_blkno); 1499 (unsigned long long)OCFS2_I(iter)->ip_blkno);
1499 /* No locking is required for the next_orphan 1500 /* No locking is required for the next_orphan
1500 * queue as there is only ever a single 1501 * queue as there is only ever a single
1501 * process doing orphan recovery. */ 1502 * process doing orphan recovery. */
@@ -1588,7 +1589,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1588 1589
1589 while (inode) { 1590 while (inode) {
1590 oi = OCFS2_I(inode); 1591 oi = OCFS2_I(inode);
1591 mlog(0, "iput orphan %"MLFu64"\n", oi->ip_blkno); 1592 mlog(0, "iput orphan %llu\n", (unsigned long long)oi->ip_blkno);
1592 1593
1593 iter = oi->ip_next_orphan; 1594 iter = oi->ip_next_orphan;
1594 1595
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 149b35181666..0d1973ea32b0 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -143,8 +143,8 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
143 143
144 if (!(le32_to_cpu(alloc->i_flags) & 144 if (!(le32_to_cpu(alloc->i_flags) &
145 (OCFS2_LOCAL_ALLOC_FL|OCFS2_BITMAP_FL))) { 145 (OCFS2_LOCAL_ALLOC_FL|OCFS2_BITMAP_FL))) {
146 mlog(ML_ERROR, "Invalid local alloc inode, %"MLFu64"\n", 146 mlog(ML_ERROR, "Invalid local alloc inode, %llu\n",
147 OCFS2_I(inode)->ip_blkno); 147 (unsigned long long)OCFS2_I(inode)->ip_blkno);
148 status = -EINVAL; 148 status = -EINVAL;
149 goto bail; 149 goto bail;
150 } 150 }
@@ -493,9 +493,9 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
493 493
494 if (le32_to_cpu(alloc->id1.bitmap1.i_used) != 494 if (le32_to_cpu(alloc->id1.bitmap1.i_used) !=
495 ocfs2_local_alloc_count_bits(alloc)) { 495 ocfs2_local_alloc_count_bits(alloc)) {
496 ocfs2_error(osb->sb, "local alloc inode %"MLFu64" says it has " 496 ocfs2_error(osb->sb, "local alloc inode %llu says it has "
497 "%u free bits, but a count shows %u", 497 "%u free bits, but a count shows %u",
498 le64_to_cpu(alloc->i_blkno), 498 (unsigned long long)le64_to_cpu(alloc->i_blkno),
499 le32_to_cpu(alloc->id1.bitmap1.i_used), 499 le32_to_cpu(alloc->id1.bitmap1.i_used),
500 ocfs2_local_alloc_count_bits(alloc)); 500 ocfs2_local_alloc_count_bits(alloc));
501 status = -EIO; 501 status = -EIO;
@@ -753,10 +753,11 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
753 ocfs2_clusters_to_blocks(osb->sb, 753 ocfs2_clusters_to_blocks(osb->sb,
754 start - count); 754 start - count);
755 755
756 mlog(0, "freeing %u bits starting at local " 756 mlog(0, "freeing %u bits starting at local alloc bit "
757 "alloc bit %u (la_start_blk = %"MLFu64", " 757 "%u (la_start_blk = %llu, blkno = %llu)\n",
758 "blkno = %"MLFu64")\n", count, start - count, 758 count, start - count,
759 la_start_blk, blkno); 759 (unsigned long long)la_start_blk,
760 (unsigned long long)blkno);
760 761
761 status = ocfs2_free_clusters(handle, main_bm_inode, 762 status = ocfs2_free_clusters(handle, main_bm_inode,
762 main_bm_bh, blkno, count); 763 main_bm_bh, blkno, count);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index f6b77ff1d2bf..274f61d0cda9 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -161,8 +161,8 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
161 goto bail; 161 goto bail;
162 } 162 }
163 163
164 mlog(0, "find name %.*s in directory %"MLFu64"\n", dentry->d_name.len, 164 mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len,
165 dentry->d_name.name, OCFS2_I(dir)->ip_blkno); 165 dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno);
166 166
167 status = ocfs2_meta_lock(dir, NULL, NULL, 0); 167 status = ocfs2_meta_lock(dir, NULL, NULL, 0);
168 if (status < 0) { 168 if (status < 0) {
@@ -180,7 +180,8 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
180 180
181 inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno); 181 inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno);
182 if (IS_ERR(inode)) { 182 if (IS_ERR(inode)) {
183 mlog(ML_ERROR, "Unable to create inode %"MLFu64"\n", blkno); 183 mlog(ML_ERROR, "Unable to create inode %llu\n",
184 (unsigned long long)blkno);
184 ret = ERR_PTR(-EACCES); 185 ret = ERR_PTR(-EACCES);
185 goto bail_unlock; 186 goto bail_unlock;
186 } 187 }
@@ -310,8 +311,8 @@ static int ocfs2_mknod(struct inode *dir,
310 osb = OCFS2_SB(dir->i_sb); 311 osb = OCFS2_SB(dir->i_sb);
311 312
312 if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) { 313 if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) {
313 mlog(ML_ERROR, "inode %"MLFu64" has i_nlink of %u\n", 314 mlog(ML_ERROR, "inode %llu has i_nlink of %u\n",
314 OCFS2_I(dir)->ip_blkno, dir->i_nlink); 315 (unsigned long long)OCFS2_I(dir)->ip_blkno, dir->i_nlink);
315 status = -EMLINK; 316 status = -EMLINK;
316 goto leave; 317 goto leave;
317 } 318 }
@@ -562,9 +563,9 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
562 563
563 if (ocfs2_populate_inode(inode, fe, 1) < 0) { 564 if (ocfs2_populate_inode(inode, fe, 1) < 0) {
564 mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, " 565 mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, "
565 "i_blkno=%"MLFu64", i_ino=%lu\n", 566 "i_blkno=%llu, i_ino=%lu\n",
566 (unsigned long long) (*new_fe_bh)->b_blocknr, 567 (unsigned long long) (*new_fe_bh)->b_blocknr,
567 fe->i_blkno, inode->i_ino); 568 (unsigned long long)fe->i_blkno, inode->i_ino);
568 BUG(); 569 BUG();
569 } 570 }
570 571
@@ -765,7 +766,7 @@ static int ocfs2_unlink(struct inode *dir,
765 766
766 BUG_ON(dentry->d_parent->d_inode != dir); 767 BUG_ON(dentry->d_parent->d_inode != dir);
767 768
768 mlog(0, "ino = %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); 769 mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno);
769 770
770 if (inode == osb->root_inode) { 771 if (inode == osb->root_inode) {
771 mlog(0, "Cannot delete the root directory\n"); 772 mlog(0, "Cannot delete the root directory\n");
@@ -799,9 +800,9 @@ static int ocfs2_unlink(struct inode *dir,
799 if (OCFS2_I(inode)->ip_blkno != blkno) { 800 if (OCFS2_I(inode)->ip_blkno != blkno) {
800 status = -ENOENT; 801 status = -ENOENT;
801 802
802 mlog(0, "ip_blkno (%"MLFu64") != dirent blkno (%"MLFu64") " 803 mlog(0, "ip_blkno %llu != dirent blkno %llu ip_flags = %x\n",
803 "ip_flags = %x\n", OCFS2_I(inode)->ip_blkno, blkno, 804 (unsigned long long)OCFS2_I(inode)->ip_blkno,
804 OCFS2_I(inode)->ip_flags); 805 (unsigned long long)blkno, OCFS2_I(inode)->ip_flags);
805 goto leave; 806 goto leave;
806 } 807 }
807 808
@@ -946,8 +947,9 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
946 struct buffer_head **tmpbh; 947 struct buffer_head **tmpbh;
947 struct inode *tmpinode; 948 struct inode *tmpinode;
948 949
949 mlog_entry("(inode1 = %"MLFu64", inode2 = %"MLFu64")\n", 950 mlog_entry("(inode1 = %llu, inode2 = %llu)\n",
950 oi1->ip_blkno, oi2->ip_blkno); 951 (unsigned long long)oi1->ip_blkno,
952 (unsigned long long)oi2->ip_blkno);
951 953
952 BUG_ON(!handle); 954 BUG_ON(!handle);
953 955
@@ -1187,9 +1189,9 @@ static int ocfs2_rename(struct inode *old_dir,
1187 if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) { 1189 if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) {
1188 status = -EACCES; 1190 status = -EACCES;
1189 1191
1190 mlog(0, "Inode blkno (%"MLFu64") and dir (%"MLFu64") " 1192 mlog(0, "Inode %llu and dir %llu disagree. flags = %x\n",
1191 "disagree. ip_flags = %x\n", 1193 (unsigned long long)OCFS2_I(new_inode)->ip_blkno,
1192 OCFS2_I(new_inode)->ip_blkno, newfe_blkno, 1194 (unsigned long long)newfe_blkno,
1193 OCFS2_I(new_inode)->ip_flags); 1195 OCFS2_I(new_inode)->ip_flags);
1194 goto bail; 1196 goto bail;
1195 } 1197 }
@@ -1215,9 +1217,9 @@ static int ocfs2_rename(struct inode *old_dir,
1215 1217
1216 newfe = (struct ocfs2_dinode *) newfe_bh->b_data; 1218 newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
1217 1219
1218 mlog(0, "aha rename over existing... new_de=%p " 1220 mlog(0, "aha rename over existing... new_de=%p new_blkno=%llu "
1219 "new_blkno=%"MLFu64" newfebh=%p bhblocknr=%llu\n", 1221 "newfebh=%p bhblocknr=%llu\n", new_de,
1220 new_de, newfe_blkno, newfe_bh, newfe_bh ? 1222 (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
1221 (unsigned long long)newfe_bh->b_blocknr : 0ULL); 1223 (unsigned long long)newfe_bh->b_blocknr : 0ULL);
1222 1224
1223 if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { 1225 if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) {
@@ -1354,8 +1356,8 @@ static int ocfs2_rename(struct inode *old_dir,
1354 if (new_dir_nlink != new_dir->i_nlink) { 1356 if (new_dir_nlink != new_dir->i_nlink) {
1355 if (!new_dir_bh) { 1357 if (!new_dir_bh) {
1356 mlog(ML_ERROR, "need to change nlink for new " 1358 mlog(ML_ERROR, "need to change nlink for new "
1357 "dir %"MLFu64" from %d to %d but bh is " 1359 "dir %llu from %d to %d but bh is NULL\n",
1358 "NULL\n", OCFS2_I(new_dir)->ip_blkno, 1360 (unsigned long long)OCFS2_I(new_dir)->ip_blkno,
1359 (int)new_dir_nlink, new_dir->i_nlink); 1361 (int)new_dir_nlink, new_dir->i_nlink);
1360 } else { 1362 } else {
1361 struct ocfs2_dinode *fe; 1363 struct ocfs2_dinode *fe;
@@ -1372,10 +1374,9 @@ static int ocfs2_rename(struct inode *old_dir,
1372 if (old_dir_nlink != old_dir->i_nlink) { 1374 if (old_dir_nlink != old_dir->i_nlink) {
1373 if (!old_dir_bh) { 1375 if (!old_dir_bh) {
1374 mlog(ML_ERROR, "need to change nlink for old dir " 1376 mlog(ML_ERROR, "need to change nlink for old dir "
1375 "%"MLFu64" from %d to %d but bh is NULL!\n", 1377 "%llu from %d to %d but bh is NULL!\n",
1376 OCFS2_I(old_dir)->ip_blkno, 1378 (unsigned long long)OCFS2_I(old_dir)->ip_blkno,
1377 (int)old_dir_nlink, 1379 (int)old_dir_nlink, old_dir->i_nlink);
1378 old_dir->i_nlink);
1379 } else { 1380 } else {
1380 struct ocfs2_dinode *fe; 1381 struct ocfs2_dinode *fe;
1381 status = ocfs2_journal_access(handle, old_dir, 1382 status = ocfs2_journal_access(handle, old_dir,
@@ -1634,9 +1635,9 @@ static int ocfs2_symlink(struct inode *dir,
1634 NULL); 1635 NULL);
1635 if (status < 0) { 1636 if (status < 0) {
1636 if (status != -ENOSPC && status != -EINTR) { 1637 if (status != -ENOSPC && status != -EINTR) {
1637 mlog(ML_ERROR, "Failed to extend file to " 1638 mlog(ML_ERROR,
1638 "%"MLFu64"\n", 1639 "Failed to extend file to %llu\n",
1639 newsize); 1640 (unsigned long long)newsize);
1640 mlog_errno(status); 1641 mlog_errno(status);
1641 status = -ENOSPC; 1642 status = -ENOSPC;
1642 } 1643 }
@@ -1716,10 +1717,11 @@ int ocfs2_check_dir_entry(struct inode * dir,
1716 error_msg = "directory entry across blocks"; 1717 error_msg = "directory entry across blocks";
1717 1718
1718 if (error_msg != NULL) 1719 if (error_msg != NULL)
1719 mlog(ML_ERROR, "bad entry in directory #%"MLFu64": %s - " 1720 mlog(ML_ERROR, "bad entry in directory #%llu: %s - "
1720 "offset=%lu, inode=%"MLFu64", rec_len=%d, name_len=%d\n", 1721 "offset=%lu, inode=%llu, rec_len=%d, name_len=%d\n",
1721 OCFS2_I(dir)->ip_blkno, error_msg, offset, 1722 (unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg,
1722 le64_to_cpu(de->inode), rlen, de->name_len); 1723 offset, (unsigned long long)le64_to_cpu(de->inode), rlen,
1724 de->name_len);
1723 return error_msg == NULL ? 1 : 0; 1725 return error_msg == NULL ? 1 : 0;
1724} 1726}
1725 1727
@@ -2021,8 +2023,8 @@ static int ocfs2_blkno_stringify(u64 blkno, char *name)
2021 2023
2022 mlog_entry_void(); 2024 mlog_entry_void();
2023 2025
2024 namelen = snprintf(name, OCFS2_ORPHAN_NAMELEN + 1, "%016"MLFx64, 2026 namelen = snprintf(name, OCFS2_ORPHAN_NAMELEN + 1, "%016llx",
2025 blkno); 2027 (long long)blkno);
2026 if (namelen <= 0) { 2028 if (namelen <= 0) {
2027 if (namelen) 2029 if (namelen)
2028 status = namelen; 2030 status = namelen;
@@ -2167,8 +2169,8 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
2167 OCFS2_I(inode)->ip_orphaned_slot = osb->slot_num; 2169 OCFS2_I(inode)->ip_orphaned_slot = osb->slot_num;
2168 spin_unlock(&OCFS2_I(inode)->ip_lock); 2170 spin_unlock(&OCFS2_I(inode)->ip_lock);
2169 2171
2170 mlog(0, "Inode %"MLFu64" orphaned in slot %d\n", 2172 mlog(0, "Inode %llu orphaned in slot %d\n",
2171 OCFS2_I(inode)->ip_blkno, osb->slot_num); 2173 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
2172 2174
2173leave: 2175leave:
2174 if (orphan_dir_inode) 2176 if (orphan_dir_inode)
@@ -2202,8 +2204,9 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
2202 goto leave; 2204 goto leave;
2203 } 2205 }
2204 2206
2205 mlog(0, "removing '%s' from orphan dir %"MLFu64" (namelen=%d)\n", 2207 mlog(0, "removing '%s' from orphan dir %llu (namelen=%d)\n",
2206 name, OCFS2_I(orphan_dir_inode)->ip_blkno, OCFS2_ORPHAN_NAMELEN); 2208 name, (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno,
2209 OCFS2_ORPHAN_NAMELEN);
2207 2210
2208 /* find it's spot in the orphan directory */ 2211 /* find it's spot in the orphan directory */
2209 target_de_bh = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, 2212 target_de_bh = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN,
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e89de9b6e491..da1093039c01 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -357,8 +357,8 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb)
357#define OCFS2_RO_ON_INVALID_DINODE(__sb, __di) do { \ 357#define OCFS2_RO_ON_INVALID_DINODE(__sb, __di) do { \
358 typeof(__di) ____di = (__di); \ 358 typeof(__di) ____di = (__di); \
359 ocfs2_error((__sb), \ 359 ocfs2_error((__sb), \
360 "Dinode # %"MLFu64" has bad signature %.*s", \ 360 "Dinode # %llu has bad signature %.*s", \
361 (____di)->i_blkno, 7, \ 361 (unsigned long long)(____di)->i_blkno, 7, \
362 (____di)->i_signature); \ 362 (____di)->i_signature); \
363} while (0); 363} while (0);
364 364
@@ -368,8 +368,8 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb)
368#define OCFS2_RO_ON_INVALID_EXTENT_BLOCK(__sb, __eb) do { \ 368#define OCFS2_RO_ON_INVALID_EXTENT_BLOCK(__sb, __eb) do { \
369 typeof(__eb) ____eb = (__eb); \ 369 typeof(__eb) ____eb = (__eb); \
370 ocfs2_error((__sb), \ 370 ocfs2_error((__sb), \
371 "Extent Block # %"MLFu64" has bad signature %.*s", \ 371 "Extent Block # %llu has bad signature %.*s", \
372 (____eb)->h_blkno, 7, \ 372 (unsigned long long)(____eb)->h_blkno, 7, \
373 (____eb)->h_signature); \ 373 (____eb)->h_signature); \
374} while (0); 374} while (0);
375 375
@@ -379,8 +379,8 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb)
379#define OCFS2_RO_ON_INVALID_GROUP_DESC(__sb, __gd) do { \ 379#define OCFS2_RO_ON_INVALID_GROUP_DESC(__sb, __gd) do { \
380 typeof(__gd) ____gd = (__gd); \ 380 typeof(__gd) ____gd = (__gd); \
381 ocfs2_error((__sb), \ 381 ocfs2_error((__sb), \
382 "Group Descriptor # %"MLFu64" has bad signature %.*s", \ 382 "Group Descriptor # %llu has bad signature %.*s", \
383 (____gd)->bg_blkno, 7, \ 383 (unsigned long long)(____gd)->bg_blkno, 7, \
384 (____gd)->bg_signature); \ 384 (____gd)->bg_signature); \
385} while (0); 385} while (0);
386 386
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index c46c164aefbb..195523090c87 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -157,8 +157,9 @@ static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle,
157 mlog_entry_void(); 157 mlog_entry_void();
158 158
159 if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) { 159 if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) {
160 ocfs2_error(alloc_inode->i_sb, "group block (%"MLFu64") " 160 ocfs2_error(alloc_inode->i_sb, "group block (%llu) != "
161 "!= b_blocknr (%llu)", group_blkno, 161 "b_blocknr (%llu)",
162 (unsigned long long)group_blkno,
162 (unsigned long long) bg_bh->b_blocknr); 163 (unsigned long long) bg_bh->b_blocknr);
163 status = -EIO; 164 status = -EIO;
164 goto bail; 165 goto bail;
@@ -280,8 +281,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
280 281
281 /* setup the group */ 282 /* setup the group */
282 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); 283 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
283 mlog(0, "new descriptor, record %u, at block %"MLFu64"\n", 284 mlog(0, "new descriptor, record %u, at block %llu\n",
284 alloc_rec, bg_blkno); 285 alloc_rec, (unsigned long long)bg_blkno);
285 286
286 bg_bh = sb_getblk(osb->sb, bg_blkno); 287 bg_bh = sb_getblk(osb->sb, bg_blkno);
287 if (!bg_bh) { 288 if (!bg_bh) {
@@ -382,8 +383,8 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
382 goto bail; 383 goto bail;
383 } 384 }
384 if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) { 385 if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) {
385 ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator " 386 ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu",
386 "# %"MLFu64, le64_to_cpu(fe->i_blkno)); 387 (unsigned long long)le64_to_cpu(fe->i_blkno));
387 status = -EIO; 388 status = -EIO;
388 goto bail; 389 goto bail;
389 } 390 }
@@ -829,9 +830,10 @@ static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle,
829 goto out; 830 goto out;
830 } 831 }
831 832
832 mlog(0, "In suballoc %"MLFu64", chain %u, move group %"MLFu64" to " 833 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n",
833 "top, prev = %"MLFu64"\n", 834 (unsigned long long)fe->i_blkno, chain,
834 fe->i_blkno, chain, bg->bg_blkno, prev_bg->bg_blkno); 835 (unsigned long long)bg->bg_blkno,
836 (unsigned long long)prev_bg->bg_blkno);
835 837
836 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); 838 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno);
837 bg_ptr = le64_to_cpu(bg->bg_next_group); 839 bg_ptr = le64_to_cpu(bg->bg_next_group);
@@ -974,8 +976,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
974 struct ocfs2_group_desc *bg; 976 struct ocfs2_group_desc *bg;
975 977
976 chain = ac->ac_chain; 978 chain = ac->ac_chain;
977 mlog(0, "trying to alloc %u bits from chain %u, inode %"MLFu64"\n", 979 mlog(0, "trying to alloc %u bits from chain %u, inode %llu\n",
978 bits_wanted, chain, OCFS2_I(alloc_inode)->ip_blkno); 980 bits_wanted, chain,
981 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno);
979 982
980 status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), 983 status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb),
981 le64_to_cpu(cl->cl_recs[chain].c_blkno), 984 le64_to_cpu(cl->cl_recs[chain].c_blkno),
@@ -1027,8 +1030,8 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1027 goto bail; 1030 goto bail;
1028 } 1031 }
1029 1032
1030 mlog(0, "alloc succeeds: we give %u bits from block group %"MLFu64"\n", 1033 mlog(0, "alloc succeeds: we give %u bits from block group %llu\n",
1031 tmp_bits, bg->bg_blkno); 1034 tmp_bits, (unsigned long long)bg->bg_blkno);
1032 1035
1033 *num_bits = tmp_bits; 1036 *num_bits = tmp_bits;
1034 1037
@@ -1092,8 +1095,8 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1092 goto bail; 1095 goto bail;
1093 } 1096 }
1094 1097
1095 mlog(0, "Allocated %u bits from suballocator %"MLFu64"\n", 1098 mlog(0, "Allocated %u bits from suballocator %llu\n", *num_bits,
1096 *num_bits, fe->i_blkno); 1099 (unsigned long long)fe->i_blkno);
1097 1100
1098 *bg_blkno = le64_to_cpu(bg->bg_blkno); 1101 *bg_blkno = le64_to_cpu(bg->bg_blkno);
1099bail: 1102bail:
@@ -1134,9 +1137,9 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1134 } 1137 }
1135 if (le32_to_cpu(fe->id1.bitmap1.i_used) >= 1138 if (le32_to_cpu(fe->id1.bitmap1.i_used) >=
1136 le32_to_cpu(fe->id1.bitmap1.i_total)) { 1139 le32_to_cpu(fe->id1.bitmap1.i_total)) {
1137 ocfs2_error(osb->sb, "Chain allocator dinode %"MLFu64" has %u" 1140 ocfs2_error(osb->sb, "Chain allocator dinode %llu has %u used "
1138 "used bits but only %u total.", 1141 "bits but only %u total.",
1139 le64_to_cpu(fe->i_blkno), 1142 (unsigned long long)le64_to_cpu(fe->i_blkno),
1140 le32_to_cpu(fe->id1.bitmap1.i_used), 1143 le32_to_cpu(fe->id1.bitmap1.i_used),
1141 le32_to_cpu(fe->id1.bitmap1.i_total)); 1144 le32_to_cpu(fe->id1.bitmap1.i_total));
1142 status = -EIO; 1145 status = -EIO;
@@ -1479,10 +1482,9 @@ static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle,
1479 } 1482 }
1480 BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); 1483 BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl));
1481 1484
1482 mlog(0, "suballocator %"MLFu64": freeing %u bits from group %"MLFu64 1485 mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n",
1483 ", starting at %u\n", 1486 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count,
1484 OCFS2_I(alloc_inode)->ip_blkno, count, bg_blkno, 1487 (unsigned long long)bg_blkno, start_bit);
1485 start_bit);
1486 1488
1487 status = ocfs2_read_block(osb, bg_blkno, &group_bh, OCFS2_BH_CACHED, 1489 status = ocfs2_read_block(osb, bg_blkno, &group_bh, OCFS2_BH_CACHED,
1488 alloc_inode); 1490 alloc_inode);
@@ -1592,10 +1594,10 @@ int ocfs2_free_clusters(struct ocfs2_journal_handle *handle,
1592 ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno, 1594 ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno,
1593 &bg_start_bit); 1595 &bg_start_bit);
1594 1596
1595 mlog(0, "want to free %u clusters starting at block %"MLFu64"\n", 1597 mlog(0, "want to free %u clusters starting at block %llu\n",
1596 num_clusters, start_blk); 1598 num_clusters, (unsigned long long)start_blk);
1597 mlog(0, "bg_blkno = %"MLFu64", bg_start_bit = %u\n", 1599 mlog(0, "bg_blkno = %llu, bg_start_bit = %u\n",
1598 bg_blkno, bg_start_bit); 1600 (unsigned long long)bg_blkno, bg_start_bit);
1599 1601
1600 status = ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh, 1602 status = ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh,
1601 bg_start_bit, bg_blkno, 1603 bg_start_bit, bg_blkno,
@@ -1616,18 +1618,22 @@ static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg)
1616 printk("bg_free_bits_count: %u\n", bg->bg_free_bits_count); 1618 printk("bg_free_bits_count: %u\n", bg->bg_free_bits_count);
1617 printk("bg_chain: %u\n", bg->bg_chain); 1619 printk("bg_chain: %u\n", bg->bg_chain);
1618 printk("bg_generation: %u\n", le32_to_cpu(bg->bg_generation)); 1620 printk("bg_generation: %u\n", le32_to_cpu(bg->bg_generation));
1619 printk("bg_next_group: %"MLFu64"\n", bg->bg_next_group); 1621 printk("bg_next_group: %llu\n",
1620 printk("bg_parent_dinode: %"MLFu64"\n", bg->bg_parent_dinode); 1622 (unsigned long long)bg->bg_next_group);
1621 printk("bg_blkno: %"MLFu64"\n", bg->bg_blkno); 1623 printk("bg_parent_dinode: %llu\n",
1624 (unsigned long long)bg->bg_parent_dinode);
1625 printk("bg_blkno: %llu\n",
1626 (unsigned long long)bg->bg_blkno);
1622} 1627}
1623 1628
1624static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe) 1629static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe)
1625{ 1630{
1626 int i; 1631 int i;
1627 1632
1628 printk("Suballoc Inode %"MLFu64":\n", fe->i_blkno); 1633 printk("Suballoc Inode %llu:\n", (unsigned long long)fe->i_blkno);
1629 printk("i_signature: %s\n", fe->i_signature); 1634 printk("i_signature: %s\n", fe->i_signature);
1630 printk("i_size: %"MLFu64"\n", fe->i_size); 1635 printk("i_size: %llu\n",
1636 (unsigned long long)fe->i_size);
1631 printk("i_clusters: %u\n", fe->i_clusters); 1637 printk("i_clusters: %u\n", fe->i_clusters);
1632 printk("i_generation: %u\n", 1638 printk("i_generation: %u\n",
1633 le32_to_cpu(fe->i_generation)); 1639 le32_to_cpu(fe->i_generation));
@@ -1645,7 +1651,7 @@ static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe)
1645 fe->id2.i_chain.cl_recs[i].c_free); 1651 fe->id2.i_chain.cl_recs[i].c_free);
1646 printk("fe->id2.i_chain.cl_recs[%d].c_total: %u\n", i, 1652 printk("fe->id2.i_chain.cl_recs[%d].c_total: %u\n", i,
1647 fe->id2.i_chain.cl_recs[i].c_total); 1653 fe->id2.i_chain.cl_recs[i].c_total);
1648 printk("fe->id2.i_chain.cl_recs[%d].c_blkno: %"MLFu64"\n", i, 1654 printk("fe->id2.i_chain.cl_recs[%d].c_blkno: %llu\n", i,
1649 fe->id2.i_chain.cl_recs[i].c_blkno); 1655 (unsigned long long)fe->id2.i_chain.cl_recs[i].c_blkno);
1650 } 1656 }
1651} 1657}
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 09e1c57a86a0..949b3dac30f1 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -950,9 +950,11 @@ static void ocfs2_inode_init_once(void *data,
950static int ocfs2_initialize_mem_caches(void) 950static int ocfs2_initialize_mem_caches(void)
951{ 951{
952 ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache", 952 ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache",
953 sizeof(struct ocfs2_inode_info), 953 sizeof(struct ocfs2_inode_info),
954 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 954 0,
955 ocfs2_inode_init_once, NULL); 955 (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
956 SLAB_MEM_SPREAD),
957 ocfs2_inode_init_once, NULL);
956 if (!ocfs2_inode_cachep) 958 if (!ocfs2_inode_cachep)
957 return -ENOMEM; 959 return -ENOMEM;
958 960
@@ -1426,8 +1428,9 @@ static int ocfs2_initialize_super(struct super_block *sb,
1426 osb->fs_generation = le32_to_cpu(di->i_fs_generation); 1428 osb->fs_generation = le32_to_cpu(di->i_fs_generation);
1427 mlog(0, "vol_label: %s\n", osb->vol_label); 1429 mlog(0, "vol_label: %s\n", osb->vol_label);
1428 mlog(0, "uuid: %s\n", osb->uuid_str); 1430 mlog(0, "uuid: %s\n", osb->uuid_str);
1429 mlog(0, "root_blkno=%"MLFu64", system_dir_blkno=%"MLFu64"\n", 1431 mlog(0, "root_blkno=%llu, system_dir_blkno=%llu\n",
1430 osb->root_blkno, osb->system_dir_blkno); 1432 (unsigned long long)osb->root_blkno,
1433 (unsigned long long)osb->system_dir_blkno);
1431 1434
1432 osb->osb_dlm_debug = ocfs2_new_dlm_debug(); 1435 osb->osb_dlm_debug = ocfs2_new_dlm_debug();
1433 if (!osb->osb_dlm_debug) { 1436 if (!osb->osb_dlm_debug) {
@@ -1470,8 +1473,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
1470 osb->bitmap_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg); 1473 osb->bitmap_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg);
1471 osb->num_clusters = le32_to_cpu(di->id1.bitmap1.i_total); 1474 osb->num_clusters = le32_to_cpu(di->id1.bitmap1.i_total);
1472 brelse(bitmap_bh); 1475 brelse(bitmap_bh);
1473 mlog(0, "cluster bitmap inode: %"MLFu64", clusters per group: %u\n", 1476 mlog(0, "cluster bitmap inode: %llu, clusters per group: %u\n",
1474 osb->bitmap_blkno, osb->bitmap_cpg); 1477 (unsigned long long)osb->bitmap_blkno, osb->bitmap_cpg);
1475 1478
1476 status = ocfs2_init_slot_info(osb); 1479 status = ocfs2_init_slot_info(osb);
1477 if (status < 0) { 1480 if (status < 0) {
@@ -1529,8 +1532,9 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di,
1529 OCFS2_MINOR_REV_LEVEL); 1532 OCFS2_MINOR_REV_LEVEL);
1530 } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) { 1533 } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) {
1531 mlog(ML_ERROR, "bad block number on superblock: " 1534 mlog(ML_ERROR, "bad block number on superblock: "
1532 "found %"MLFu64", should be %llu\n", 1535 "found %llu, should be %llu\n",
1533 di->i_blkno, (unsigned long long)bh->b_blocknr); 1536 (unsigned long long)di->i_blkno,
1537 (unsigned long long)bh->b_blocknr);
1534 } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 || 1538 } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 ||
1535 le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) { 1539 le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) {
1536 mlog(ML_ERROR, "bad cluster size found: %u\n", 1540 mlog(ML_ERROR, "bad cluster size found: %u\n",
diff --git a/fs/ocfs2/super.h b/fs/ocfs2/super.h
index c564177dfbdc..783f5270f2a1 100644
--- a/fs/ocfs2/super.h
+++ b/fs/ocfs2/super.h
@@ -33,12 +33,16 @@ int ocfs2_publish_get_mount_state(struct ocfs2_super *osb,
33 33
34void __ocfs2_error(struct super_block *sb, 34void __ocfs2_error(struct super_block *sb,
35 const char *function, 35 const char *function,
36 const char *fmt, ...); 36 const char *fmt, ...)
37 __attribute__ ((format (printf, 3, 4)));
38
37#define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args) 39#define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args)
38 40
39void __ocfs2_abort(struct super_block *sb, 41void __ocfs2_abort(struct super_block *sb,
40 const char *function, 42 const char *function,
41 const char *fmt, ...); 43 const char *fmt, ...)
44 __attribute__ ((format (printf, 3, 4)));
45
42#define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args) 46#define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args)
43 47
44#endif /* OCFS2_SUPER_H */ 48#endif /* OCFS2_SUPER_H */
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index 300b5bedfb21..04a684dfdd96 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -119,8 +119,8 @@ void ocfs2_metadata_cache_purge(struct inode *inode)
119 tree = !(oi->ip_flags & OCFS2_INODE_CACHE_INLINE); 119 tree = !(oi->ip_flags & OCFS2_INODE_CACHE_INLINE);
120 to_purge = ci->ci_num_cached; 120 to_purge = ci->ci_num_cached;
121 121
122 mlog(0, "Purge %u %s items from Inode %"MLFu64"\n", to_purge, 122 mlog(0, "Purge %u %s items from Inode %llu\n", to_purge,
123 tree ? "array" : "tree", oi->ip_blkno); 123 tree ? "array" : "tree", (unsigned long long)oi->ip_blkno);
124 124
125 /* If we're a tree, save off the root so that we can safely 125 /* If we're a tree, save off the root so that we can safely
126 * initialize the cache. We do the work to free tree members 126 * initialize the cache. We do the work to free tree members
@@ -136,8 +136,8 @@ void ocfs2_metadata_cache_purge(struct inode *inode)
136 * easily detect counting errors. Unfortunately, this is only 136 * easily detect counting errors. Unfortunately, this is only
137 * meaningful for trees. */ 137 * meaningful for trees. */
138 if (tree && purged != to_purge) 138 if (tree && purged != to_purge)
139 mlog(ML_ERROR, "Inode %"MLFu64", count = %u, purged = %u\n", 139 mlog(ML_ERROR, "Inode %llu, count = %u, purged = %u\n",
140 oi->ip_blkno, to_purge, purged); 140 (unsigned long long)oi->ip_blkno, to_purge, purged);
141} 141}
142 142
143/* Returns the index in the cache array, -1 if not found. 143/* Returns the index in the cache array, -1 if not found.
@@ -186,8 +186,9 @@ static int ocfs2_buffer_cached(struct ocfs2_inode_info *oi,
186 186
187 spin_lock(&oi->ip_lock); 187 spin_lock(&oi->ip_lock);
188 188
189 mlog(0, "Inode %"MLFu64", query block %llu (inline = %u)\n", 189 mlog(0, "Inode %llu, query block %llu (inline = %u)\n",
190 oi->ip_blkno, (unsigned long long) bh->b_blocknr, 190 (unsigned long long)oi->ip_blkno,
191 (unsigned long long) bh->b_blocknr,
191 !!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE)); 192 !!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE));
192 193
193 if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) 194 if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE)
@@ -293,12 +294,12 @@ static void ocfs2_expand_cache(struct ocfs2_inode_info *oi,
293 struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; 294 struct ocfs2_caching_info *ci = &oi->ip_metadata_cache;
294 295
295 mlog_bug_on_msg(ci->ci_num_cached != OCFS2_INODE_MAX_CACHE_ARRAY, 296 mlog_bug_on_msg(ci->ci_num_cached != OCFS2_INODE_MAX_CACHE_ARRAY,
296 "Inode %"MLFu64", num cached = %u, should be %u\n", 297 "Inode %llu, num cached = %u, should be %u\n",
297 oi->ip_blkno, ci->ci_num_cached, 298 (unsigned long long)oi->ip_blkno, ci->ci_num_cached,
298 OCFS2_INODE_MAX_CACHE_ARRAY); 299 OCFS2_INODE_MAX_CACHE_ARRAY);
299 mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE), 300 mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE),
300 "Inode %"MLFu64" not marked as inline anymore!\n", 301 "Inode %llu not marked as inline anymore!\n",
301 oi->ip_blkno); 302 (unsigned long long)oi->ip_blkno);
302 assert_spin_locked(&oi->ip_lock); 303 assert_spin_locked(&oi->ip_lock);
303 304
304 /* Be careful to initialize the tree members *first* because 305 /* Be careful to initialize the tree members *first* because
@@ -316,8 +317,8 @@ static void ocfs2_expand_cache(struct ocfs2_inode_info *oi,
316 tree[i] = NULL; 317 tree[i] = NULL;
317 } 318 }
318 319
319 mlog(0, "Expanded %"MLFu64" to a tree cache: flags 0x%x, num = %u\n", 320 mlog(0, "Expanded %llu to a tree cache: flags 0x%x, num = %u\n",
320 oi->ip_blkno, oi->ip_flags, ci->ci_num_cached); 321 (unsigned long long)oi->ip_blkno, oi->ip_flags, ci->ci_num_cached);
321} 322}
322 323
323/* Slow path function - memory allocation is necessary. See the 324/* Slow path function - memory allocation is necessary. See the
@@ -332,8 +333,9 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi,
332 struct ocfs2_meta_cache_item *tree[OCFS2_INODE_MAX_CACHE_ARRAY] = 333 struct ocfs2_meta_cache_item *tree[OCFS2_INODE_MAX_CACHE_ARRAY] =
333 { NULL, }; 334 { NULL, };
334 335
335 mlog(0, "Inode %"MLFu64", block %llu, expand = %d\n", 336 mlog(0, "Inode %llu, block %llu, expand = %d\n",
336 oi->ip_blkno, (unsigned long long) block, expand_tree); 337 (unsigned long long)oi->ip_blkno,
338 (unsigned long long)block, expand_tree);
337 339
338 new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_KERNEL); 340 new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_KERNEL);
339 if (!new) { 341 if (!new) {
@@ -414,8 +416,9 @@ void ocfs2_set_buffer_uptodate(struct inode *inode,
414 if (ocfs2_buffer_cached(oi, bh)) 416 if (ocfs2_buffer_cached(oi, bh))
415 return; 417 return;
416 418
417 mlog(0, "Inode %"MLFu64", inserting block %llu\n", oi->ip_blkno, 419 mlog(0, "Inode %llu, inserting block %llu\n",
418 (unsigned long long) bh->b_blocknr); 420 (unsigned long long)oi->ip_blkno,
421 (unsigned long long)bh->b_blocknr);
419 422
420 /* No need to recheck under spinlock - insertion is guarded by 423 /* No need to recheck under spinlock - insertion is guarded by
421 * ip_io_mutex */ 424 * ip_io_mutex */
@@ -504,8 +507,9 @@ void ocfs2_remove_from_cache(struct inode *inode,
504 struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; 507 struct ocfs2_caching_info *ci = &oi->ip_metadata_cache;
505 508
506 spin_lock(&oi->ip_lock); 509 spin_lock(&oi->ip_lock);
507 mlog(0, "Inode %"MLFu64", remove %llu, items = %u, array = %u\n", 510 mlog(0, "Inode %llu, remove %llu, items = %u, array = %u\n",
508 oi->ip_blkno, (unsigned long long) block, ci->ci_num_cached, 511 (unsigned long long)oi->ip_blkno,
512 (unsigned long long) block, ci->ci_num_cached,
509 oi->ip_flags & OCFS2_INODE_CACHE_INLINE); 513 oi->ip_flags & OCFS2_INODE_CACHE_INLINE);
510 514
511 if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) { 515 if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) {
diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c
index 021978e0576b..53049a204197 100644
--- a/fs/ocfs2/vote.c
+++ b/fs/ocfs2/vote.c
@@ -190,20 +190,21 @@ static int ocfs2_process_delete_request(struct inode *inode,
190 OCFS2_INVALID_SLOT && 190 OCFS2_INVALID_SLOT &&
191 OCFS2_I(inode)->ip_orphaned_slot != 191 OCFS2_I(inode)->ip_orphaned_slot !=
192 (*orphaned_slot), 192 (*orphaned_slot),
193 "Inode %"MLFu64": This node thinks it's " 193 "Inode %llu: This node thinks it's "
194 "orphaned in slot %d, messaged it's in %d\n", 194 "orphaned in slot %d, messaged it's in %d\n",
195 OCFS2_I(inode)->ip_blkno, 195 (unsigned long long)OCFS2_I(inode)->ip_blkno,
196 OCFS2_I(inode)->ip_orphaned_slot, 196 OCFS2_I(inode)->ip_orphaned_slot,
197 *orphaned_slot); 197 *orphaned_slot);
198 198
199 mlog(0, "Setting orphaned slot for inode %"MLFu64" to %d\n", 199 mlog(0, "Setting orphaned slot for inode %llu to %d\n",
200 OCFS2_I(inode)->ip_blkno, *orphaned_slot); 200 (unsigned long long)OCFS2_I(inode)->ip_blkno,
201 *orphaned_slot);
201 202
202 OCFS2_I(inode)->ip_orphaned_slot = *orphaned_slot; 203 OCFS2_I(inode)->ip_orphaned_slot = *orphaned_slot;
203 } else { 204 } else {
204 mlog(0, "Sending back orphaned slot %d for inode %"MLFu64"\n", 205 mlog(0, "Sending back orphaned slot %d for inode %llu\n",
205 OCFS2_I(inode)->ip_orphaned_slot, 206 OCFS2_I(inode)->ip_orphaned_slot,
206 OCFS2_I(inode)->ip_blkno); 207 (unsigned long long)OCFS2_I(inode)->ip_blkno);
207 208
208 *orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; 209 *orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot;
209 } 210 }
@@ -226,8 +227,8 @@ static int ocfs2_process_delete_request(struct inode *inode,
226 } 227 }
227 228
228 if (filemap_fdatawrite(inode->i_mapping)) { 229 if (filemap_fdatawrite(inode->i_mapping)) {
229 mlog(ML_ERROR, "Could not sync inode %"MLFu64" for delete!\n", 230 mlog(ML_ERROR, "Could not sync inode %llu for delete!\n",
230 OCFS2_I(inode)->ip_blkno); 231 (unsigned long long)OCFS2_I(inode)->ip_blkno);
231 goto done; 232 goto done;
232 } 233 }
233 sync_mapping_buffers(inode->i_mapping); 234 sync_mapping_buffers(inode->i_mapping);
@@ -302,8 +303,8 @@ static void ocfs2_process_dentry_request(struct inode *inode,
302 struct list_head *p; 303 struct list_head *p;
303 struct ocfs2_inode_info *oi = OCFS2_I(inode); 304 struct ocfs2_inode_info *oi = OCFS2_I(inode);
304 305
305 mlog(0, "parent %"MLFu64", namelen = %u, name = %.*s\n", parent_blkno, 306 mlog(0, "parent %llu, namelen = %u, name = %.*s\n",
306 namelen, namelen, name); 307 (unsigned long long)parent_blkno, namelen, namelen, name);
307 308
308 spin_lock(&dcache_lock); 309 spin_lock(&dcache_lock);
309 310
@@ -370,9 +371,10 @@ static void ocfs2_process_vote(struct ocfs2_super *osb,
370 if (request == OCFS2_VOTE_REQ_DELETE) 371 if (request == OCFS2_VOTE_REQ_DELETE)
371 orphaned_slot = be32_to_cpu(msg->md1.v_orphaned_slot); 372 orphaned_slot = be32_to_cpu(msg->md1.v_orphaned_slot);
372 373
373 mlog(0, "processing vote: request = %u, blkno = %"MLFu64", " 374 mlog(0, "processing vote: request = %u, blkno = %llu, "
374 "generation = %u, node_num = %u, priv1 = %u\n", request, 375 "generation = %u, node_num = %u, priv1 = %u\n", request,
375 blkno, generation, node_num, be32_to_cpu(msg->md1.v_generic1)); 376 (unsigned long long)blkno, generation, node_num,
377 be32_to_cpu(msg->md1.v_generic1));
376 378
377 if (!ocfs2_is_valid_vote_request(request)) { 379 if (!ocfs2_is_valid_vote_request(request)) {
378 mlog(ML_ERROR, "Invalid vote request %d from node %u\n", 380 mlog(ML_ERROR, "Invalid vote request %d from node %u\n",
@@ -419,11 +421,12 @@ static void ocfs2_process_vote(struct ocfs2_super *osb,
419 * we had not found an inode in the first place. */ 421 * we had not found an inode in the first place. */
420 if (inode->i_generation != generation) { 422 if (inode->i_generation != generation) {
421 mlog(0, "generation passed %u != inode generation = %u, " 423 mlog(0, "generation passed %u != inode generation = %u, "
422 "ip_flags = %x, ip_blkno = %"MLFu64", msg %"MLFu64", " 424 "ip_flags = %x, ip_blkno = %llu, msg %llu, i_count = %u, "
423 "i_count = %u, message type = %u\n", 425 "message type = %u\n", generation, inode->i_generation,
424 generation, inode->i_generation, OCFS2_I(inode)->ip_flags, 426 OCFS2_I(inode)->ip_flags,
425 OCFS2_I(inode)->ip_blkno, blkno, 427 (unsigned long long)OCFS2_I(inode)->ip_blkno,
426 atomic_read(&inode->i_count), request); 428 (unsigned long long)blkno, atomic_read(&inode->i_count),
429 request);
427 iput(inode); 430 iput(inode);
428 inode = NULL; 431 inode = NULL;
429 goto respond; 432 goto respond;
@@ -830,8 +833,9 @@ static void ocfs2_delete_response_cb(void *priv,
830 833
831 orphaned_slot = be32_to_cpu(resp->r_orphaned_slot); 834 orphaned_slot = be32_to_cpu(resp->r_orphaned_slot);
832 node = be32_to_cpu(resp->r_hdr.h_node_num); 835 node = be32_to_cpu(resp->r_hdr.h_node_num);
833 mlog(0, "node %d tells us that inode %"MLFu64" is orphaned in slot " 836 mlog(0, "node %d tells us that inode %llu is orphaned in slot %d\n",
834 "%d\n", node, OCFS2_I(inode)->ip_blkno, orphaned_slot); 837 node, (unsigned long long)OCFS2_I(inode)->ip_blkno,
838 orphaned_slot);
835 839
836 /* The other node may not actually know which slot the inode 840 /* The other node may not actually know which slot the inode
837 * is orphaned in. */ 841 * is orphaned in. */
@@ -845,9 +849,9 @@ static void ocfs2_delete_response_cb(void *priv,
845 spin_lock(&OCFS2_I(inode)->ip_lock); 849 spin_lock(&OCFS2_I(inode)->ip_lock);
846 mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != orphaned_slot && 850 mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != orphaned_slot &&
847 OCFS2_I(inode)->ip_orphaned_slot 851 OCFS2_I(inode)->ip_orphaned_slot
848 != OCFS2_INVALID_SLOT, "Inode %"MLFu64": Node %d " 852 != OCFS2_INVALID_SLOT, "Inode %llu: Node %d says it's "
849 "says it's orphaned in slot %d, we think it's in %d\n", 853 "orphaned in slot %d, we think it's in %d\n",
850 OCFS2_I(inode)->ip_blkno, 854 (unsigned long long)OCFS2_I(inode)->ip_blkno,
851 be32_to_cpu(resp->r_hdr.h_node_num), 855 be32_to_cpu(resp->r_hdr.h_node_num),
852 orphaned_slot, OCFS2_I(inode)->ip_orphaned_slot); 856 orphaned_slot, OCFS2_I(inode)->ip_orphaned_slot);
853 857
@@ -869,8 +873,8 @@ int ocfs2_request_delete_vote(struct inode *inode)
869 delete_cb.rc_cb = ocfs2_delete_response_cb; 873 delete_cb.rc_cb = ocfs2_delete_response_cb;
870 delete_cb.rc_priv = inode; 874 delete_cb.rc_priv = inode;
871 875
872 mlog(0, "Inode %"MLFu64", we start thinking orphaned slot is %d\n", 876 mlog(0, "Inode %llu, we start thinking orphaned slot is %d\n",
873 OCFS2_I(inode)->ip_blkno, orphaned_slot); 877 (unsigned long long)OCFS2_I(inode)->ip_blkno, orphaned_slot);
874 878
875 status = -ENOMEM; 879 status = -ENOMEM;
876 request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, 880 request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno,
@@ -895,8 +899,8 @@ static void ocfs2_setup_unlink_vote(struct ocfs2_vote_msg *request,
895 * d_delete against it. Parent directory block and full name 899 * d_delete against it. Parent directory block and full name
896 * should suffice. */ 900 * should suffice. */
897 901
898 mlog(0, "unlink/rename request: parent: %"MLFu64" name: %.*s\n", 902 mlog(0, "unlink/rename request: parent: %llu name: %.*s\n",
899 OCFS2_I(parent)->ip_blkno, dentry->d_name.len, 903 (unsigned long long)OCFS2_I(parent)->ip_blkno, dentry->d_name.len,
900 dentry->d_name.name); 904 dentry->d_name.name);
901 905
902 request->v_unlink_parent = cpu_to_be64(OCFS2_I(parent)->ip_blkno); 906 request->v_unlink_parent = cpu_to_be64(OCFS2_I(parent)->ip_blkno);
@@ -1082,7 +1086,8 @@ static int ocfs2_handle_response_message(struct o2net_msg *msg,
1082 mlog(0, "received response message:\n"); 1086 mlog(0, "received response message:\n");
1083 mlog(0, "h_response_id = %u\n", response_id); 1087 mlog(0, "h_response_id = %u\n", response_id);
1084 mlog(0, "h_request = %u\n", be32_to_cpu(resp->r_hdr.h_request)); 1088 mlog(0, "h_request = %u\n", be32_to_cpu(resp->r_hdr.h_request));
1085 mlog(0, "h_blkno = %"MLFu64"\n", be64_to_cpu(resp->r_hdr.h_blkno)); 1089 mlog(0, "h_blkno = %llu\n",
1090 (unsigned long long)be64_to_cpu(resp->r_hdr.h_blkno));
1086 mlog(0, "h_generation = %u\n", be32_to_cpu(resp->r_hdr.h_generation)); 1091 mlog(0, "h_generation = %u\n", be32_to_cpu(resp->r_hdr.h_generation));
1087 mlog(0, "h_node_num = %u\n", node_num); 1092 mlog(0, "h_node_num = %u\n", node_num);
1088 mlog(0, "r_response = %d\n", response_status); 1093 mlog(0, "r_response = %d\n", response_status);
@@ -1138,8 +1143,8 @@ static int ocfs2_handle_vote_message(struct o2net_msg *msg,
1138 mlog(0, "h_response_id = %u\n", 1143 mlog(0, "h_response_id = %u\n",
1139 be32_to_cpu(work->w_msg.v_hdr.h_response_id)); 1144 be32_to_cpu(work->w_msg.v_hdr.h_response_id));
1140 mlog(0, "h_request = %u\n", be32_to_cpu(work->w_msg.v_hdr.h_request)); 1145 mlog(0, "h_request = %u\n", be32_to_cpu(work->w_msg.v_hdr.h_request));
1141 mlog(0, "h_blkno = %"MLFu64"\n", 1146 mlog(0, "h_blkno = %llu\n",
1142 be64_to_cpu(work->w_msg.v_hdr.h_blkno)); 1147 (unsigned long long)be64_to_cpu(work->w_msg.v_hdr.h_blkno));
1143 mlog(0, "h_generation = %u\n", 1148 mlog(0, "h_generation = %u\n",
1144 be32_to_cpu(work->w_msg.v_hdr.h_generation)); 1149 be32_to_cpu(work->w_msg.v_hdr.h_generation));
1145 mlog(0, "h_node_num = %u\n", 1150 mlog(0, "h_node_num = %u\n",
diff --git a/fs/open.c b/fs/open.c
index 1091dadd6c38..7d02d19bd0a2 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -890,6 +890,10 @@ EXPORT_SYMBOL(filp_open);
890 * a fully instantiated struct file to the caller. 890 * a fully instantiated struct file to the caller.
891 * This function is meant to be called from within a filesystem's 891 * This function is meant to be called from within a filesystem's
892 * lookup method. 892 * lookup method.
893 * Beware of calling it for non-regular files! Those ->open methods might block
894 * (e.g. in fifo_open), leaving you with parent locked (and in case of fifo,
895 * leading to a deadlock, as nobody can open that fifo anymore, because
896 * another process to open fifo will block on locked parent when doing lookup).
893 * Note that in case of error, nd->intent.open.file is destroyed, but the 897 * Note that in case of error, nd->intent.open.file is destroyed, but the
894 * path information remains valid. 898 * path information remains valid.
895 * If the open callback is set to NULL, then the standard f_op->open() 899 * If the open callback is set to NULL, then the standard f_op->open()
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c
index 1e4a93835fed..830c55d86ab1 100644
--- a/fs/partitions/ibm.c
+++ b/fs/partitions/ibm.c
@@ -1,15 +1,9 @@
1/* 1/*
2 * File...........: linux/fs/partitions/ibm.c 2 * File...........: linux/fs/partitions/ibm.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Volker Sameske <sameske@de.ibm.com> 4 * Volker Sameske <sameske@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
7
8 * History of changes (starts July 2000)
9 * 07/10/00 Fixed detection of CMS formatted disks
10 * 02/13/00 VTOC partition support added
11 * 12/27/01 fixed PL030593 (CMS reserved minidisk not detected on 64 bit)
12 * 07/24/03 no longer using contents of freed page for CMS label recognition (BZ3611)
13 */ 7 */
14 8
15#include <linux/config.h> 9#include <linux/config.h>
@@ -25,7 +19,7 @@
25#include "ibm.h" 19#include "ibm.h"
26 20
27/* 21/*
28 * compute the block number from a 22 * compute the block number from a
29 * cyl-cyl-head-head structure 23 * cyl-cyl-head-head structure
30 */ 24 */
31static inline int 25static inline int
@@ -34,9 +28,8 @@ cchh2blk (struct vtoc_cchh *ptr, struct hd_geometry *geo) {
34 ptr->hh * geo->sectors; 28 ptr->hh * geo->sectors;
35} 29}
36 30
37
38/* 31/*
39 * compute the block number from a 32 * compute the block number from a
40 * cyl-cyl-head-head-block structure 33 * cyl-cyl-head-head-block structure
41 */ 34 */
42static inline int 35static inline int
@@ -48,7 +41,7 @@ cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) {
48 41
49/* 42/*
50 */ 43 */
51int 44int
52ibm_partition(struct parsed_partitions *state, struct block_device *bdev) 45ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
53{ 46{
54 int blocksize, offset, size; 47 int blocksize, offset, size;
@@ -77,7 +70,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
77 goto out_nogeo; 70 goto out_nogeo;
78 if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL) 71 if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL)
79 goto out_nolab; 72 goto out_nolab;
80 73
81 if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || 74 if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 ||
82 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) 75 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0)
83 goto out_noioctl; 76 goto out_noioctl;
@@ -154,13 +147,13 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
154 147
155 /* OK, we got valid partition data */ 148 /* OK, we got valid partition data */
156 offset = cchh2blk(&f1.DS1EXT1.llimit, geo); 149 offset = cchh2blk(&f1.DS1EXT1.llimit, geo);
157 size = cchh2blk(&f1.DS1EXT1.ulimit, geo) - 150 size = cchh2blk(&f1.DS1EXT1.ulimit, geo) -
158 offset + geo->sectors; 151 offset + geo->sectors;
159 if (counter >= state->limit) 152 if (counter >= state->limit)
160 break; 153 break;
161 put_partition(state, counter + 1, 154 put_partition(state, counter + 1,
162 offset * (blocksize >> 9), 155 offset * (blocksize >> 9),
163 size * (blocksize >> 9)); 156 size * (blocksize >> 9));
164 counter++; 157 counter++;
165 blk++; 158 blk++;
166 } 159 }
@@ -175,7 +168,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
175 offset = (info->label_block + 1); 168 offset = (info->label_block + 1);
176 size = i_size >> 9; 169 size = i_size >> 9;
177 put_partition(state, 1, offset*(blocksize >> 9), 170 put_partition(state, 1, offset*(blocksize >> 9),
178 size-offset*(blocksize >> 9)); 171 size-offset*(blocksize >> 9));
179 } 172 }
180 173
181 printk("\n"); 174 printk("\n");
@@ -183,7 +176,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
183 kfree(geo); 176 kfree(geo);
184 kfree(info); 177 kfree(info);
185 return 1; 178 return 1;
186 179
187out_readerr: 180out_readerr:
188out_noioctl: 181out_noioctl:
189 kfree(label); 182 kfree(label);
diff --git a/fs/pipe.c b/fs/pipe.c
index 8aada8e426f4..d976866a115b 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -662,10 +662,9 @@ struct inode* pipe_new(struct inode* inode)
662{ 662{
663 struct pipe_inode_info *info; 663 struct pipe_inode_info *info;
664 664
665 info = kmalloc(sizeof(struct pipe_inode_info), GFP_KERNEL); 665 info = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
666 if (!info) 666 if (!info)
667 goto fail_page; 667 goto fail_page;
668 memset(info, 0, sizeof(*info));
669 inode->i_pipe = info; 668 inode->i_pipe = info;
670 669
671 init_waitqueue_head(PIPE_WAIT(*inode)); 670 init_waitqueue_head(PIPE_WAIT(*inode));
diff --git a/fs/pnode.c b/fs/pnode.c
index f1871f773f64..37b568ed0e05 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -130,7 +130,7 @@ static struct vfsmount *get_source(struct vfsmount *dest,
130{ 130{
131 struct vfsmount *p_last_src = NULL; 131 struct vfsmount *p_last_src = NULL;
132 struct vfsmount *p_last_dest = NULL; 132 struct vfsmount *p_last_dest = NULL;
133 *type = CL_PROPAGATION;; 133 *type = CL_PROPAGATION;
134 134
135 if (IS_MNT_SHARED(dest)) 135 if (IS_MNT_SHARED(dest))
136 *type |= CL_MAKE_SHARED; 136 *type |= CL_MAKE_SHARED;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 075d3e945602..722b9c463111 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -121,7 +121,8 @@ int __init proc_init_inodecache(void)
121{ 121{
122 proc_inode_cachep = kmem_cache_create("proc_inode_cache", 122 proc_inode_cachep = kmem_cache_create("proc_inode_cache",
123 sizeof(struct proc_inode), 123 sizeof(struct proc_inode),
124 0, SLAB_RECLAIM_ACCOUNT, 124 0, (SLAB_RECLAIM_ACCOUNT|
125 SLAB_MEM_SPREAD),
125 init_once, NULL); 126 init_once, NULL);
126 if (proc_inode_cachep == NULL) 127 if (proc_inode_cachep == NULL)
127 return -ENOMEM; 128 return -ENOMEM;
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 826c131994c3..1e9ea37d457e 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -485,6 +485,40 @@ static struct file_operations proc_slabinfo_operations = {
485 .llseek = seq_lseek, 485 .llseek = seq_lseek,
486 .release = seq_release, 486 .release = seq_release,
487}; 487};
488
489#ifdef CONFIG_DEBUG_SLAB_LEAK
490extern struct seq_operations slabstats_op;
491static int slabstats_open(struct inode *inode, struct file *file)
492{
493 unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
494 int ret = -ENOMEM;
495 if (n) {
496 ret = seq_open(file, &slabstats_op);
497 if (!ret) {
498 struct seq_file *m = file->private_data;
499 *n = PAGE_SIZE / (2 * sizeof(unsigned long));
500 m->private = n;
501 n = NULL;
502 }
503 kfree(n);
504 }
505 return ret;
506}
507
508static int slabstats_release(struct inode *inode, struct file *file)
509{
510 struct seq_file *m = file->private_data;
511 kfree(m->private);
512 return seq_release(inode, file);
513}
514
515static struct file_operations proc_slabstats_operations = {
516 .open = slabstats_open,
517 .read = seq_read,
518 .llseek = seq_lseek,
519 .release = slabstats_release,
520};
521#endif
488#endif 522#endif
489 523
490static int show_stat(struct seq_file *p, void *v) 524static int show_stat(struct seq_file *p, void *v)
@@ -744,6 +778,9 @@ void __init proc_misc_init(void)
744 create_seq_entry("interrupts", 0, &proc_interrupts_operations); 778 create_seq_entry("interrupts", 0, &proc_interrupts_operations);
745#ifdef CONFIG_SLAB 779#ifdef CONFIG_SLAB
746 create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations); 780 create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
781#ifdef CONFIG_DEBUG_SLAB_LEAK
782 create_seq_entry("slab_allocators", 0 ,&proc_slabstats_operations);
783#endif
747#endif 784#endif
748 create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations); 785 create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
749 create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations); 786 create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 80f32911c0cb..2ecd46f85e9f 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -546,7 +546,8 @@ static int init_inodecache(void)
546{ 546{
547 qnx4_inode_cachep = kmem_cache_create("qnx4_inode_cache", 547 qnx4_inode_cachep = kmem_cache_create("qnx4_inode_cache",
548 sizeof(struct qnx4_inode_info), 548 sizeof(struct qnx4_inode_info),
549 0, SLAB_RECLAIM_ACCOUNT, 549 0, (SLAB_RECLAIM_ACCOUNT|
550 SLAB_MEM_SPREAD),
550 init_once, NULL); 551 init_once, NULL);
551 if (qnx4_inode_cachep == NULL) 552 if (qnx4_inode_cachep == NULL)
552 return -ENOMEM; 553 return -ENOMEM;
diff --git a/fs/read_write.c b/fs/read_write.c
index 3f7a1a62165f..34b1bf259efd 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,
470 * verify all the pointers 470 * verify all the pointers
471 */ 471 */
472 ret = -EINVAL; 472 ret = -EINVAL;
473 if ((nr_segs > UIO_MAXIOV) || (nr_segs <= 0)) 473 if (nr_segs > UIO_MAXIOV)
474 goto out; 474 goto out;
475 if (!file->f_op) 475 if (!file->f_op)
476 goto out; 476 goto out;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index be12879bb179..d0c1e865963e 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
1532 buf += write_bytes; 1532 buf += write_bytes;
1533 *ppos = pos += write_bytes; 1533 *ppos = pos += write_bytes;
1534 count -= write_bytes; 1534 count -= write_bytes;
1535 balance_dirty_pages_ratelimited(inode->i_mapping); 1535 balance_dirty_pages_ratelimited_nr(inode->i_mapping, num_pages);
1536 } 1536 }
1537 1537
1538 /* this is only true on error */ 1538 /* 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
1546 } 1546 }
1547 } 1547 }
1548 1548
1549 if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) 1549 if (likely(res >= 0) &&
1550 res = 1550 (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode))))
1551 generic_osync_inode(inode, file->f_mapping, 1551 res = generic_osync_inode(inode, file->f_mapping,
1552 OSYNC_METADATA | OSYNC_DATA); 1552 OSYNC_METADATA | OSYNC_DATA);
1553 1553
1554 mutex_unlock(&inode->i_mutex); 1554 mutex_unlock(&inode->i_mutex);
1555 reiserfs_async_progress_wait(inode->i_sb); 1555 reiserfs_async_progress_wait(inode->i_sb);
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
index aa22588019ec..5600d3d60cf7 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)
191 "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c", 191 "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c",
192 key, vn->vn_affected_item_num, 192 key, vn->vn_affected_item_num,
193 vn->vn_mode, M_DELETE); 193 vn->vn_mode, M_DELETE);
194 } else 194 }
195 /* we can delete directory item, that has only one directory entry in it */
196 ;
197 } 195 }
198#endif 196#endif
199 197
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index e237cd668e5b..7a88adbceef6 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)
275 int j; 275 int j;
276 __le32 *unp; 276 __le32 *unp;
277 __u32 prev = INT_MAX; 277 __u32 prev = INT_MAX;
278 int num; 278 int num = 0;
279 279
280 unp = (__le32 *) item; 280 unp = (__le32 *) item;
281 281
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 5a9d2722fa0a..1b73529b8099 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,
2227 journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); 2227 journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb);
2228 journal->j_last_flush_trans_id = trans_id; 2228 journal->j_last_flush_trans_id = trans_id;
2229 journal->j_trans_id = trans_id + 1; 2229 journal->j_trans_id = trans_id + 1;
2230 /* check for trans_id overflow */
2231 if (journal->j_trans_id == 0)
2232 journal->j_trans_id = 10;
2230 brelse(c_bh); 2233 brelse(c_bh);
2231 brelse(d_bh); 2234 brelse(d_bh);
2232 kfree(log_blocks); 2235 kfree(log_blocks);
@@ -2450,6 +2453,9 @@ static int journal_read(struct super_block *p_s_sb)
2450 journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset); 2453 journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset);
2451 journal->j_trans_id = 2454 journal->j_trans_id =
2452 le32_to_cpu(jh->j_last_flush_trans_id) + 1; 2455 le32_to_cpu(jh->j_last_flush_trans_id) + 1;
2456 /* check for trans_id overflow */
2457 if (journal->j_trans_id == 0)
2458 journal->j_trans_id = 10;
2453 journal->j_last_flush_trans_id = 2459 journal->j_last_flush_trans_id =
2454 le32_to_cpu(jh->j_last_flush_trans_id); 2460 le32_to_cpu(jh->j_last_flush_trans_id);
2455 journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1; 2461 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,
3873 int cur_write_start = 0; /* start index of current log write */ 3879 int cur_write_start = 0; /* start index of current log write */
3874 int old_start; 3880 int old_start;
3875 int i; 3881 int i;
3876 int flush = flags & FLUSH_ALL; 3882 int flush;
3877 int wait_on_commit = flags & WAIT; 3883 int wait_on_commit;
3878 struct reiserfs_journal_list *jl, *temp_jl; 3884 struct reiserfs_journal_list *jl, *temp_jl;
3879 struct list_head *entry, *safe; 3885 struct list_head *entry, *safe;
3880 unsigned long jindex; 3886 unsigned long jindex;
@@ -3884,6 +3890,13 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
3884 BUG_ON(th->t_refcount > 1); 3890 BUG_ON(th->t_refcount > 1);
3885 BUG_ON(!th->t_trans_id); 3891 BUG_ON(!th->t_trans_id);
3886 3892
3893 /* protect flush_older_commits from doing mistakes if the
3894 transaction ID counter gets overflowed. */
3895 if (th->t_trans_id == ~0UL)
3896 flags |= FLUSH_ALL | COMMIT_NOW | WAIT;
3897 flush = flags & FLUSH_ALL;
3898 wait_on_commit = flags & WAIT;
3899
3887 put_fs_excl(); 3900 put_fs_excl();
3888 current->journal_info = th->t_handle_save; 3901 current->journal_info = th->t_handle_save;
3889 reiserfs_check_lock_depth(p_s_sb, "journal end"); 3902 reiserfs_check_lock_depth(p_s_sb, "journal end");
@@ -4105,7 +4118,9 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
4105 journal->j_first = NULL; 4118 journal->j_first = NULL;
4106 journal->j_len = 0; 4119 journal->j_len = 0;
4107 journal->j_trans_start_time = 0; 4120 journal->j_trans_start_time = 0;
4108 journal->j_trans_id++; 4121 /* check for trans_id overflow */
4122 if (++journal->j_trans_id == 0)
4123 journal->j_trans_id = 10;
4109 journal->j_current_jl->j_trans_id = journal->j_trans_id; 4124 journal->j_current_jl->j_trans_id = journal->j_trans_id;
4110 journal->j_must_wait = 0; 4125 journal->j_must_wait = 0;
4111 journal->j_len_alloc = 0; 4126 journal->j_len_alloc = 0;
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index d55e164bd5c2..78b40621b88b 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -601,8 +601,7 @@ void store_print_tb(struct tree_balance *tb)
601 tb->tb_mode, PATH_LAST_POSITION(tb->tb_path), 601 tb->tb_mode, PATH_LAST_POSITION(tb->tb_path),
602 tb->tb_path->pos_in_item); 602 tb->tb_path->pos_in_item);
603 603
604 for (h = 0; h < sizeof(tb->insert_size) / sizeof(tb->insert_size[0]); 604 for (h = 0; h < ARRAY_SIZE(tb->insert_size); h++) {
605 h++) {
606 if (PATH_H_PATH_OFFSET(tb->tb_path, h) <= 605 if (PATH_H_PATH_OFFSET(tb->tb_path, h) <=
607 tb->tb_path->path_length 606 tb->tb_path->path_length
608 && PATH_H_PATH_OFFSET(tb->tb_path, 607 && PATH_H_PATH_OFFSET(tb->tb_path,
@@ -658,15 +657,13 @@ void store_print_tb(struct tree_balance *tb)
658 657
659 /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */ 658 /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */
660 h = 0; 659 h = 0;
661 for (i = 0; i < sizeof(tb->FEB) / sizeof(tb->FEB[0]); i++) 660 for (i = 0; i < ARRAY_SIZE(tb->FEB); i++)
662 sprintf(print_tb_buf + strlen(print_tb_buf), 661 sprintf(print_tb_buf + strlen(print_tb_buf),
663 "%p (%llu %d)%s", tb->FEB[i], 662 "%p (%llu %d)%s", tb->FEB[i],
664 tb->FEB[i] ? (unsigned long long)tb->FEB[i]-> 663 tb->FEB[i] ? (unsigned long long)tb->FEB[i]->
665 b_blocknr : 0ULL, 664 b_blocknr : 0ULL,
666 tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0, 665 tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0,
667 (i == 666 (i == ARRAY_SIZE(tb->FEB) - 1) ? "\n" : ", ");
668 sizeof(tb->FEB) / sizeof(tb->FEB[0]) -
669 1) ? "\n" : ", ");
670 667
671 sprintf(print_tb_buf + strlen(print_tb_buf), 668 sprintf(print_tb_buf + strlen(print_tb_buf),
672 "======================== the end ====================================\n"); 669 "======================== the end ====================================\n");
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index e2d08d7bcffc..d2b25e1ba6e9 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,
981 return M_CUT; 981 return M_CUT;
982} 982}
983 983
984#define JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD (2 * JOURNAL_PER_BALANCE_CNT + 1)
985
984/* If the path points to a directory or direct item, calculate mode and the size cut, for balance. 986/* If the path points to a directory or direct item, calculate mode and the size cut, for balance.
985 If the path points to an indirect item, remove some number of its unformatted nodes. 987 If the path points to an indirect item, remove some number of its unformatted nodes.
986 In case of file truncate calculate whether this item must be deleted/truncated or last 988 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
1020 1022
1021 /* Case of an indirect item. */ 1023 /* Case of an indirect item. */
1022 { 1024 {
1023 int n_unfm_number, /* Number of the item unformatted nodes. */ 1025 int blk_size = p_s_sb->s_blocksize;
1024 n_counter, n_blk_size; 1026 struct item_head s_ih;
1025 __le32 *p_n_unfm_pointer; /* Pointer to the unformatted node number. */ 1027 int need_re_search;
1026 __u32 tmp; 1028 int delete = 0;
1027 struct item_head s_ih; /* Item header. */ 1029 int result = M_CUT;
1028 char c_mode; /* Returned mode of the balance. */ 1030 int pos = 0;
1029 int need_research; 1031
1030 1032 if ( n_new_file_length == max_reiserfs_offset (inode) ) {
1031 n_blk_size = p_s_sb->s_blocksize; 1033 /* prepare_for_delete_or_cut() is called by
1032 1034 * reiserfs_delete_item() */
1033 /* Search for the needed object indirect item until there are no unformatted nodes to be removed. */ 1035 n_new_file_length = 0;
1034 do { 1036 delete = 1;
1035 need_research = 0; 1037 }
1036 p_s_bh = PATH_PLAST_BUFFER(p_s_path); 1038
1037 /* Copy indirect item header to a temp variable. */ 1039 do {
1038 copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path)); 1040 need_re_search = 0;
1039 /* Calculate number of unformatted nodes in this item. */ 1041 *p_n_cut_size = 0;
1040 n_unfm_number = I_UNFM_NUM(&s_ih); 1042 p_s_bh = PATH_PLAST_BUFFER(p_s_path);
1041 1043 copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
1042 RFALSE(!is_indirect_le_ih(&s_ih) || !n_unfm_number || 1044 pos = I_UNFM_NUM(&s_ih);
1043 pos_in_item(p_s_path) + 1 != n_unfm_number,
1044 "PAP-5240: invalid item %h "
1045 "n_unfm_number = %d *p_n_pos_in_item = %d",
1046 &s_ih, n_unfm_number, pos_in_item(p_s_path));
1047
1048 /* Calculate balance mode and position in the item to remove unformatted nodes. */
1049 if (n_new_file_length == max_reiserfs_offset(inode)) { /* Case of delete. */
1050 pos_in_item(p_s_path) = 0;
1051 *p_n_cut_size = -(IH_SIZE + ih_item_len(&s_ih));
1052 c_mode = M_DELETE;
1053 } else { /* Case of truncate. */
1054 if (n_new_file_length < le_ih_k_offset(&s_ih)) {
1055 pos_in_item(p_s_path) = 0;
1056 *p_n_cut_size =
1057 -(IH_SIZE + ih_item_len(&s_ih));
1058 c_mode = M_DELETE; /* Delete this item. */
1059 } else {
1060 /* indirect item must be truncated starting from *p_n_pos_in_item-th position */
1061 pos_in_item(p_s_path) =
1062 (n_new_file_length + n_blk_size -
1063 le_ih_k_offset(&s_ih)) >> p_s_sb->
1064 s_blocksize_bits;
1065
1066 RFALSE(pos_in_item(p_s_path) >
1067 n_unfm_number,
1068 "PAP-5250: invalid position in the item");
1069
1070 /* Either convert last unformatted node of indirect item to direct item or increase
1071 its free space. */
1072 if (pos_in_item(p_s_path) ==
1073 n_unfm_number) {
1074 *p_n_cut_size = 0; /* Nothing to cut. */
1075 return M_CONVERT; /* Maybe convert last unformatted node to the direct item. */
1076 }
1077 /* Calculate size to cut. */
1078 *p_n_cut_size =
1079 -(ih_item_len(&s_ih) -
1080 pos_in_item(p_s_path) *
1081 UNFM_P_SIZE);
1082
1083 c_mode = M_CUT; /* Cut from this indirect item. */
1084 }
1085 }
1086 1045
1087 RFALSE(n_unfm_number <= pos_in_item(p_s_path), 1046 while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) {
1088 "PAP-5260: invalid position in the indirect item"); 1047 __u32 *unfm, block;
1089
1090 /* pointers to be cut */
1091 n_unfm_number -= pos_in_item(p_s_path);
1092 /* Set pointer to the last unformatted node pointer that is to be cut. */
1093 p_n_unfm_pointer =
1094 (__le32 *) B_I_PITEM(p_s_bh,
1095 &s_ih) + I_UNFM_NUM(&s_ih) -
1096 1 - *p_n_removed;
1097
1098 /* We go through the unformatted nodes pointers of the indirect
1099 item and look for the unformatted nodes in the cache. If we
1100 found some of them we free it, zero corresponding indirect item
1101 entry and log buffer containing that indirect item. For this we
1102 need to prepare last path element for logging. If some
1103 unformatted node has b_count > 1 we must not free this
1104 unformatted node since it is in use. */
1105 reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
1106 // note: path could be changed, first line in for loop takes care
1107 // of it
1108 1048
1109 for (n_counter = *p_n_removed; 1049 /* Each unformatted block deletion may involve one additional
1110 n_counter < n_unfm_number; 1050 * bitmap block into the transaction, thereby the initial
1111 n_counter++, p_n_unfm_pointer--) { 1051 * journal space reservation might not be enough. */
1052 if (!delete && (*p_n_cut_size) != 0 &&
1053 reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
1054 break;
1055 }
1112 1056
1113 cond_resched(); 1057 unfm = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1;
1114 if (item_moved(&s_ih, p_s_path)) { 1058 block = get_block_num(unfm, 0);
1115 need_research = 1;
1116 break;
1117 }
1118 RFALSE(p_n_unfm_pointer <
1119 (__le32 *) B_I_PITEM(p_s_bh, &s_ih)
1120 || p_n_unfm_pointer >
1121 (__le32 *) B_I_PITEM(p_s_bh,
1122 &s_ih) +
1123 I_UNFM_NUM(&s_ih) - 1,
1124 "vs-5265: pointer out of range");
1125
1126 /* Hole, nothing to remove. */
1127 if (!get_block_num(p_n_unfm_pointer, 0)) {
1128 (*p_n_removed)++;
1129 continue;
1130 }
1131 1059
1132 (*p_n_removed)++; 1060 if (block != 0) {
1061 reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
1062 put_block_num(unfm, 0, 0);
1063 journal_mark_dirty (th, p_s_sb, p_s_bh);
1064 reiserfs_free_block(th, inode, block, 1);
1065 }
1133 1066
1134 tmp = get_block_num(p_n_unfm_pointer, 0); 1067 cond_resched();
1135 put_block_num(p_n_unfm_pointer, 0, 0);
1136 journal_mark_dirty(th, p_s_sb, p_s_bh);
1137 reiserfs_free_block(th, inode, tmp, 1);
1138 if (item_moved(&s_ih, p_s_path)) {
1139 need_research = 1;
1140 break;
1141 }
1142 }
1143 1068
1144 /* a trick. If the buffer has been logged, this 1069 if (item_moved (&s_ih, p_s_path)) {
1145 ** will do nothing. If we've broken the loop without 1070 need_re_search = 1;
1146 ** logging it, it will restore the buffer 1071 break;
1147 ** 1072 }
1148 */ 1073
1149 reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh); 1074 pos --;
1150 1075 (*p_n_removed) ++;
1151 /* This loop can be optimized. */ 1076 (*p_n_cut_size) -= UNFM_P_SIZE;
1152 } while ((*p_n_removed < n_unfm_number || need_research) && 1077
1153 search_for_position_by_key(p_s_sb, p_s_item_key, 1078 if (pos == 0) {
1154 p_s_path) == 1079 (*p_n_cut_size) -= IH_SIZE;
1155 POSITION_FOUND); 1080 result = M_DELETE;
1156 1081 break;
1157 RFALSE(*p_n_removed < n_unfm_number, 1082 }
1158 "PAP-5310: indirect item is not found"); 1083 }
1159 RFALSE(item_moved(&s_ih, p_s_path), 1084 /* a trick. If the buffer has been logged, this will do nothing. If
1160 "after while, comp failed, retry"); 1085 ** we've broken the loop without logging it, it will restore the
1161 1086 ** buffer */
1162 if (c_mode == M_CUT) 1087 reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh);
1163 pos_in_item(p_s_path) *= UNFM_P_SIZE; 1088 } while (need_re_search &&
1164 return c_mode; 1089 search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND);
1090 pos_in_item(p_s_path) = pos * UNFM_P_SIZE;
1091
1092 if (*p_n_cut_size == 0) {
1093 /* Nothing were cut. maybe convert last unformatted node to the
1094 * direct item? */
1095 result = M_CONVERT;
1096 }
1097 return result;
1165 } 1098 }
1166} 1099}
1167 1100
@@ -1948,7 +1881,8 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p
1948 ** sure the file is consistent before ending the current trans 1881 ** sure the file is consistent before ending the current trans
1949 ** and starting a new one 1882 ** and starting a new one
1950 */ 1883 */
1951 if (journal_transaction_should_end(th, th->t_blocks_allocated)) { 1884 if (journal_transaction_should_end(th, 0) ||
1885 reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
1952 int orig_len_alloc = th->t_blocks_allocated; 1886 int orig_len_alloc = th->t_blocks_allocated;
1953 decrement_counters_in_path(&s_search_path); 1887 decrement_counters_in_path(&s_search_path);
1954 1888
@@ -1962,7 +1896,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p
1962 if (err) 1896 if (err)
1963 goto out; 1897 goto out;
1964 err = journal_begin(th, p_s_inode->i_sb, 1898 err = journal_begin(th, p_s_inode->i_sb,
1965 JOURNAL_PER_BALANCE_CNT * 6); 1899 JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD + JOURNAL_PER_BALANCE_CNT * 4) ;
1966 if (err) 1900 if (err)
1967 goto out; 1901 goto out;
1968 reiserfs_update_inode_transaction(p_s_inode); 1902 reiserfs_update_inode_transaction(p_s_inode);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index d63da756eb49..cae2abbc0c71 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -521,7 +521,8 @@ static int init_inodecache(void)
521 reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache", 521 reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
522 sizeof(struct 522 sizeof(struct
523 reiserfs_inode_info), 523 reiserfs_inode_info),
524 0, SLAB_RECLAIM_ACCOUNT, 524 0, (SLAB_RECLAIM_ACCOUNT|
525 SLAB_MEM_SPREAD),
525 init_once, NULL); 526 init_once, NULL);
526 if (reiserfs_inode_cachep == NULL) 527 if (reiserfs_inode_cachep == NULL)
527 return -ENOMEM; 528 return -ENOMEM;
@@ -684,14 +685,14 @@ static const arg_desc_t logging_mode[] = {
684 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)}, 685 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)},
685 {"writeback", 1 << REISERFS_DATA_WRITEBACK, 686 {"writeback", 1 << REISERFS_DATA_WRITEBACK,
686 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)}, 687 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)},
687 {NULL, 0} 688 {.value = NULL}
688}; 689};
689 690
690/* possible values for -o barrier= */ 691/* possible values for -o barrier= */
691static const arg_desc_t barrier_mode[] = { 692static const arg_desc_t barrier_mode[] = {
692 {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH}, 693 {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH},
693 {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE}, 694 {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE},
694 {NULL, 0} 695 {.value = NULL}
695}; 696};
696 697
697/* possible values for "-o block-allocator=" and bits which are to be set in 698/* 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
889 {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT}, 890 {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
890 {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT}, 891 {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
891#endif 892#endif
892 {"nolog",}, /* This is unsupported */ 893 {.option_name = "nolog"},
893 {"replayonly",.setmask = 1 << REPLAYONLY}, 894 {"replayonly",.setmask = 1 << REPLAYONLY},
894 {"block-allocator",.arg_required = 'a',.values = balloc}, 895 {"block-allocator",.arg_required = 'a',.values = balloc},
895 {"data",.arg_required = 'd',.values = logging_mode}, 896 {"data",.arg_required = 'd',.values = logging_mode},
@@ -907,7 +908,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
907 {"grpjquota",.arg_required = 908 {"grpjquota",.arg_required =
908 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, 909 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
909 {"jqfmt",.arg_required = 'f',.values = NULL}, 910 {"jqfmt",.arg_required = 'f',.values = NULL},
910 {NULL,} 911 {.option_name = NULL}
911 }; 912 };
912 913
913 *blocks = 0; 914 *blocks = 0;
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index ab8894c3b9e5..58c418fbca2c 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)
182{ 182{
183 char *name, *value; 183 char *name, *value;
184 struct posix_acl *acl, **p_acl; 184 struct posix_acl *acl, **p_acl;
185 size_t size; 185 int size;
186 int retval; 186 int retval;
187 struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); 187 struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
188 188
@@ -206,7 +206,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
206 return posix_acl_dup(*p_acl); 206 return posix_acl_dup(*p_acl);
207 207
208 size = reiserfs_xattr_get(inode, name, NULL, 0); 208 size = reiserfs_xattr_get(inode, name, NULL, 0);
209 if ((int)size < 0) { 209 if (size < 0) {
210 if (size == -ENODATA || size == -ENOSYS) { 210 if (size == -ENODATA || size == -ENOSYS) {
211 *p_acl = ERR_PTR(-ENODATA); 211 *p_acl = ERR_PTR(-ENODATA);
212 return NULL; 212 return NULL;
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 0a13859fd57b..c2fc424d7d5c 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -579,7 +579,8 @@ static int init_inodecache(void)
579{ 579{
580 romfs_inode_cachep = kmem_cache_create("romfs_inode_cache", 580 romfs_inode_cachep = kmem_cache_create("romfs_inode_cache",
581 sizeof(struct romfs_inode_info), 581 sizeof(struct romfs_inode_info),
582 0, SLAB_RECLAIM_ACCOUNT, 582 0, (SLAB_RECLAIM_ACCOUNT|
583 SLAB_MEM_SPREAD),
583 init_once, NULL); 584 init_once, NULL);
584 if (romfs_inode_cachep == NULL) 585 if (romfs_inode_cachep == NULL)
585 return -ENOMEM; 586 return -ENOMEM;
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 02e3e82d465c..fdeabc0a34f7 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -80,7 +80,8 @@ static int init_inodecache(void)
80{ 80{
81 smb_inode_cachep = kmem_cache_create("smb_inode_cache", 81 smb_inode_cachep = kmem_cache_create("smb_inode_cache",
82 sizeof(struct smb_inode_info), 82 sizeof(struct smb_inode_info),
83 0, SLAB_RECLAIM_ACCOUNT, 83 0, (SLAB_RECLAIM_ACCOUNT|
84 SLAB_MEM_SPREAD),
84 init_once, NULL); 85 init_once, NULL);
85 if (smb_inode_cachep == NULL) 86 if (smb_inode_cachep == NULL)
86 return -ENOMEM; 87 return -ENOMEM;
@@ -216,7 +217,7 @@ smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr)
216 if (inode->i_mtime.tv_sec != last_time || inode->i_size != last_sz) { 217 if (inode->i_mtime.tv_sec != last_time || inode->i_size != last_sz) {
217 VERBOSE("%ld changed, old=%ld, new=%ld, oz=%ld, nz=%ld\n", 218 VERBOSE("%ld changed, old=%ld, new=%ld, oz=%ld, nz=%ld\n",
218 inode->i_ino, 219 inode->i_ino,
219 (long) last_time, (long) inode->i_mtime, 220 (long) last_time, (long) inode->i_mtime.tv_sec,
220 (long) last_sz, (long) inode->i_size); 221 (long) last_sz, (long) inode->i_size);
221 222
222 if (!S_ISDIR(inode->i_mode)) 223 if (!S_ISDIR(inode->i_mode))
diff --git a/fs/super.c b/fs/super.c
index 425861cb1caa..8743e9bbb297 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -55,11 +55,10 @@ DEFINE_SPINLOCK(sb_lock);
55 */ 55 */
56static struct super_block *alloc_super(void) 56static struct super_block *alloc_super(void)
57{ 57{
58 struct super_block *s = kmalloc(sizeof(struct super_block), GFP_USER); 58 struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER);
59 static struct super_operations default_op; 59 static struct super_operations default_op;
60 60
61 if (s) { 61 if (s) {
62 memset(s, 0, sizeof(struct super_block));
63 if (security_sb_alloc(s)) { 62 if (security_sb_alloc(s)) {
64 kfree(s); 63 kfree(s);
65 s = NULL; 64 s = NULL;
@@ -712,7 +711,7 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
712 s->s_flags = flags; 711 s->s_flags = flags;
713 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); 712 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id));
714 sb_set_blocksize(s, block_size(bdev)); 713 sb_set_blocksize(s, block_size(bdev));
715 error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); 714 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
716 if (error) { 715 if (error) {
717 up_write(&s->s_umount); 716 up_write(&s->s_umount);
718 deactivate_super(s); 717 deactivate_super(s);
@@ -756,7 +755,7 @@ struct super_block *get_sb_nodev(struct file_system_type *fs_type,
756 755
757 s->s_flags = flags; 756 s->s_flags = flags;
758 757
759 error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); 758 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
760 if (error) { 759 if (error) {
761 up_write(&s->s_umount); 760 up_write(&s->s_umount);
762 deactivate_super(s); 761 deactivate_super(s);
@@ -785,7 +784,7 @@ struct super_block *get_sb_single(struct file_system_type *fs_type,
785 return s; 784 return s;
786 if (!s->s_root) { 785 if (!s->s_root) {
787 s->s_flags = flags; 786 s->s_flags = flags;
788 error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); 787 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
789 if (error) { 788 if (error) {
790 up_write(&s->s_umount); 789 up_write(&s->s_umount);
791 deactivate_super(s); 790 deactivate_super(s);
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index fa33eceb0011..3ff89cc5833a 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -342,7 +342,7 @@ int __init sysv_init_icache(void)
342{ 342{
343 sysv_inode_cachep = kmem_cache_create("sysv_inode_cache", 343 sysv_inode_cachep = kmem_cache_create("sysv_inode_cache",
344 sizeof(struct sysv_inode_info), 0, 344 sizeof(struct sysv_inode_info), 0,
345 SLAB_RECLAIM_ACCOUNT, 345 SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
346 init_once, NULL); 346 init_once, NULL);
347 if (!sysv_inode_cachep) 347 if (!sysv_inode_cachep)
348 return -ENOMEM; 348 return -ENOMEM;
diff --git a/fs/sysv/super.c b/fs/sysv/super.c
index 59e76b51142b..e92b991e6dda 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)
377 sbi->s_sb = sb; 377 sbi->s_sb = sb;
378 sbi->s_block_base = 0; 378 sbi->s_block_base = 0;
379 sb->s_fs_info = sbi; 379 sb->s_fs_info = sbi;
380 380
381 sb_set_blocksize(sb, BLOCK_SIZE); 381 sb_set_blocksize(sb, BLOCK_SIZE);
382 382
383 for (i = 0; i < sizeof(flavours)/sizeof(flavours[0]) && !size; i++) { 383 for (i = 0; i < ARRAY_SIZE(flavours) && !size; i++) {
384 brelse(bh); 384 brelse(bh);
385 bh = sb_bread(sb, flavours[i].block); 385 bh = sb_bread(sb, flavours[i].block);
386 if (!bh) 386 if (!bh)
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index d04cff2273b6..81e0e8459af1 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1341,13 +1341,11 @@ udf_update_inode(struct inode *inode, int do_sync)
1341 1341
1342 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) 1342 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
1343 fe->uid = cpu_to_le32(-1); 1343 fe->uid = cpu_to_le32(-1);
1344 else if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid) 1344 else fe->uid = cpu_to_le32(inode->i_uid);
1345 fe->uid = cpu_to_le32(inode->i_uid);
1346 1345
1347 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) 1346 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
1348 fe->gid = cpu_to_le32(-1); 1347 fe->gid = cpu_to_le32(-1);
1349 else if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid) 1348 else fe->gid = cpu_to_le32(inode->i_gid);
1350 fe->gid = cpu_to_le32(inode->i_gid);
1351 1349
1352 udfperms = ((inode->i_mode & S_IRWXO) ) | 1350 udfperms = ((inode->i_mode & S_IRWXO) ) |
1353 ((inode->i_mode & S_IRWXG) << 2) | 1351 ((inode->i_mode & S_IRWXG) << 2) |
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 9303c50c5d55..e45789fe38e8 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -140,7 +140,8 @@ static int init_inodecache(void)
140{ 140{
141 udf_inode_cachep = kmem_cache_create("udf_inode_cache", 141 udf_inode_cachep = kmem_cache_create("udf_inode_cache",
142 sizeof(struct udf_inode_info), 142 sizeof(struct udf_inode_info),
143 0, SLAB_RECLAIM_ACCOUNT, 143 0, (SLAB_RECLAIM_ACCOUNT|
144 SLAB_MEM_SPREAD),
144 init_once, NULL); 145 init_once, NULL);
145 if (udf_inode_cachep == NULL) 146 if (udf_inode_cachep == NULL)
146 return -ENOMEM; 147 return -ENOMEM;
@@ -660,8 +661,7 @@ udf_find_anchor(struct super_block *sb)
660 * lastblock 661 * lastblock
661 * however, if the disc isn't closed, it could be 512 */ 662 * however, if the disc isn't closed, it could be 512 */
662 663
663 for (i=0; (!lastblock && i<sizeof(last)/sizeof(int)); i++) 664 for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) {
664 {
665 if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) 665 if (last[i] < 0 || !(bh = sb_bread(sb, last[i])))
666 { 666 {
667 ident = location = 0; 667 ident = location = 0;
@@ -672,7 +672,7 @@ udf_find_anchor(struct super_block *sb)
672 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation); 672 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
673 udf_release_data(bh); 673 udf_release_data(bh);
674 } 674 }
675 675
676 if (ident == TAG_IDENT_AVDP) 676 if (ident == TAG_IDENT_AVDP)
677 { 677 {
678 if (location == last[i] - UDF_SB_SESSION(sb)) 678 if (location == last[i] - UDF_SB_SESSION(sb))
@@ -753,8 +753,7 @@ udf_find_anchor(struct super_block *sb)
753 } 753 }
754 } 754 }
755 755
756 for (i=0; i<sizeof(UDF_SB_ANCHOR(sb))/sizeof(int); i++) 756 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
757 {
758 if (UDF_SB_ANCHOR(sb)[i]) 757 if (UDF_SB_ANCHOR(sb)[i])
759 { 758 {
760 if (!(bh = udf_read_tagged(sb, 759 if (!(bh = udf_read_tagged(sb,
@@ -1313,8 +1312,7 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1313 if (!sb) 1312 if (!sb)
1314 return 1; 1313 return 1;
1315 1314
1316 for (i=0; i<sizeof(UDF_SB_ANCHOR(sb))/sizeof(int); i++) 1315 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
1317 {
1318 if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb, 1316 if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb,
1319 UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident))) 1317 UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident)))
1320 { 1318 {
@@ -1325,7 +1323,7 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1325 main_e = le32_to_cpu( anchor->mainVolDescSeqExt.extLength ); 1323 main_e = le32_to_cpu( anchor->mainVolDescSeqExt.extLength );
1326 main_e = main_e >> sb->s_blocksize_bits; 1324 main_e = main_e >> sb->s_blocksize_bits;
1327 main_e += main_s; 1325 main_e += main_s;
1328 1326
1329 /* Locate the reserve sequence */ 1327 /* Locate the reserve sequence */
1330 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation); 1328 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
1331 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); 1329 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
@@ -1344,12 +1342,10 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1344 } 1342 }
1345 } 1343 }
1346 1344
1347 if (i == sizeof(UDF_SB_ANCHOR(sb))/sizeof(int)) 1345 if (i == ARRAY_SIZE(UDF_SB_ANCHOR(sb))) {
1348 {
1349 udf_debug("No Anchor block found\n"); 1346 udf_debug("No Anchor block found\n");
1350 return 1; 1347 return 1;
1351 } 1348 } else
1352 else
1353 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); 1349 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
1354 1350
1355 for (i=0; i<UDF_SB_NUMPARTS(sb); i++) 1351 for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index e9055ef7f5ac..db98a4c71e63 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)
575 if (!silent) 575 if (!silent)
576 printk("You didn't specify the type of your ufs filesystem\n\n" 576 printk("You didn't specify the type of your ufs filesystem\n\n"
577 "mount -t ufs -o ufstype=" 577 "mount -t ufs -o ufstype="
578 "sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|netxstep-cd|openstep ...\n\n" 578 "sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...\n\n"
579 ">>>WARNING<<< Wrong ufstype may corrupt your filesystem, " 579 ">>>WARNING<<< Wrong ufstype may corrupt your filesystem, "
580 "default is ufstype=old\n"); 580 "default is ufstype=old\n");
581 ufs_set_opt (sbi->s_mount_opt, UFSTYPE_OLD); 581 ufs_set_opt (sbi->s_mount_opt, UFSTYPE_OLD);
@@ -1184,7 +1184,8 @@ static int init_inodecache(void)
1184{ 1184{
1185 ufs_inode_cachep = kmem_cache_create("ufs_inode_cache", 1185 ufs_inode_cachep = kmem_cache_create("ufs_inode_cache",
1186 sizeof(struct ufs_inode_info), 1186 sizeof(struct ufs_inode_info),
1187 0, SLAB_RECLAIM_ACCOUNT, 1187 0, (SLAB_RECLAIM_ACCOUNT|
1188 SLAB_MEM_SPREAD),
1188 init_once, NULL); 1189 init_once, NULL);
1189 if (ufs_inode_cachep == NULL) 1190 if (ufs_inode_cachep == NULL)
1190 return -ENOMEM; 1191 return -ENOMEM;
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index f0268a84e6fd..2cfd33d4d8aa 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -100,7 +100,7 @@ extern void kmem_free(void *, size_t);
100 100
101#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN 101#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN
102#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT 102#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT
103#define KM_ZONE_SPREAD 0 103#define KM_ZONE_SPREAD SLAB_MEM_SPREAD
104 104
105#define kmem_zone kmem_cache 105#define kmem_zone kmem_cache
106#define kmem_zone_t struct kmem_cache 106#define kmem_zone_t struct kmem_cache
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
index 713e6a7505d0..1f0589a05eca 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -56,7 +56,7 @@ xfs_read_xfsstats(
56 }; 56 };
57 57
58 /* Loop over all stats groups */ 58 /* Loop over all stats groups */
59 for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) { 59 for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
60 len += sprintf(buffer + len, xstats[i].desc); 60 len += sprintf(buffer + len, xstats[i].desc);
61 /* inner loop does each group */ 61 /* inner loop does each group */
62 while (j < xstats[i].endpoint) { 62 while (j < xstats[i].endpoint) {
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index a478f42e63ff..0f0a64e81db9 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -1335,7 +1335,7 @@ xfs_inactive_symlink_rmt(
1335 */ 1335 */
1336 done = 0; 1336 done = 0;
1337 XFS_BMAP_INIT(&free_list, &first_block); 1337 XFS_BMAP_INIT(&free_list, &first_block);
1338 nmaps = sizeof(mval) / sizeof(mval[0]); 1338 nmaps = ARRAY_SIZE(mval);
1339 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), 1339 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size),
1340 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, 1340 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps,
1341 &free_list))) 1341 &free_list)))
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index e496fac860ac..6dca3d542080 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -269,7 +269,7 @@ struct acpi_device_wakeup_state {
269 269
270struct acpi_device_wakeup { 270struct acpi_device_wakeup {
271 acpi_handle gpe_device; 271 acpi_handle gpe_device;
272 acpi_integer gpe_number;; 272 acpi_integer gpe_number;
273 acpi_integer sleep_state; 273 acpi_integer sleep_state;
274 struct acpi_handle_list resources; 274 struct acpi_handle_list resources;
275 struct acpi_device_wakeup_state state; 275 struct acpi_device_wakeup_state state;
diff --git a/include/asm-alpha/io.h b/include/asm-alpha/io.h
index 871dd7ad909d..3ebbeee753e9 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);
534#define eth_io_copy_and_sum(skb,src,len,unused) \ 534#define eth_io_copy_and_sum(skb,src,len,unused) \
535 memcpy_fromio((skb)->data,src,len) 535 memcpy_fromio((skb)->data,src,len)
536 536
537#define isa_eth_io_copy_and_sum(skb,src,len,unused) \
538 isa_memcpy_fromio((skb)->data,src,len)
539
540static inline int 537static inline int
541check_signature(const volatile void __iomem *io_addr, 538check_signature(const volatile void __iomem *io_addr,
542 const unsigned char *signature, int length) 539 const unsigned char *signature, int length)
@@ -550,87 +547,6 @@ check_signature(const volatile void __iomem *io_addr,
550 return 1; 547 return 1;
551} 548}
552 549
553
554/*
555 * ISA space is mapped to some machine-specific location on Alpha.
556 * Call into the existing hooks to get the address translated.
557 */
558
559static inline u8
560isa_readb(unsigned long offset)
561{
562 void __iomem *addr = ioremap(offset, 1);
563 u8 ret = readb(addr);
564 iounmap(addr);
565 return ret;
566}
567
568static inline u16
569isa_readw(unsigned long offset)
570{
571 void __iomem *addr = ioremap(offset, 2);
572 u16 ret = readw(addr);
573 iounmap(addr);
574 return ret;
575}
576
577static inline u32
578isa_readl(unsigned long offset)
579{
580 void __iomem *addr = ioremap(offset, 2);
581 u32 ret = readl(addr);
582 iounmap(addr);
583 return ret;
584}
585
586static inline void
587isa_writeb(u8 b, unsigned long offset)
588{
589 void __iomem *addr = ioremap(offset, 2);
590 writeb(b, addr);
591 iounmap(addr);
592}
593
594static inline void
595isa_writew(u16 w, unsigned long offset)
596{
597 void __iomem *addr = ioremap(offset, 2);
598 writew(w, addr);
599 iounmap(addr);
600}
601
602static inline void
603isa_writel(u32 l, unsigned long offset)
604{
605 void __iomem *addr = ioremap(offset, 2);
606 writel(l, addr);
607 iounmap(addr);
608}
609
610static inline void
611isa_memset_io(unsigned long offset, u8 val, long n)
612{
613 void __iomem *addr = ioremap(offset, n);
614 memset_io(addr, val, n);
615 iounmap(addr);
616}
617
618static inline void
619isa_memcpy_fromio(void *dest, unsigned long offset, long n)
620{
621 void __iomem *addr = ioremap(offset, n);
622 memcpy_fromio(dest, addr, n);
623 iounmap(addr);
624}
625
626static inline void
627isa_memcpy_toio(unsigned long offset, const void *src, long n)
628{
629 void __iomem *addr = ioremap(offset, n);
630 memcpy_toio(addr, src, n);
631 iounmap(addr);
632}
633
634/* 550/*
635 * The Alpha Jensen hardware for some rather strange reason puts 551 * The Alpha Jensen hardware for some rather strange reason puts
636 * the RTC clock at 0x170 instead of 0x70. Probably due to some 552 * the RTC clock at 0x170 instead of 0x70. Probably due to some
diff --git a/include/asm-alpha/poll.h b/include/asm-alpha/poll.h
index 34f333b762a0..95707182b3ed 100644
--- a/include/asm-alpha/poll.h
+++ b/include/asm-alpha/poll.h
@@ -13,6 +13,8 @@
13#define POLLWRBAND (1 << 9) 13#define POLLWRBAND (1 << 9)
14#define POLLMSG (1 << 10) 14#define POLLMSG (1 << 10)
15#define POLLREMOVE (1 << 11) 15#define POLLREMOVE (1 << 11)
16#define POLLRDHUP (1 << 12)
17
16 18
17struct pollfd { 19struct pollfd {
18 int fd; 20 int fd;
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 000000000000..fbc091e61e2f
--- /dev/null
+++ b/include/asm-arm/arch-at91rm9200/at91rm9200_emac.h
@@ -0,0 +1,138 @@
1/*
2 * include/asm-arm/arch-at91rm9200/at91rm9200_emac.h
3 *
4 * Copyright (C) 2005 Ivan Kokshaysky
5 * Copyright (C) SAN People
6 *
7 * Ethernet MAC registers.
8 * Based on AT91RM9200 datasheet revision E.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91RM9200_EMAC_H
17#define AT91RM9200_EMAC_H
18
19#define AT91_EMAC_CTL 0x00 /* Control Register */
20#define AT91_EMAC_LB (1 << 0) /* Loopback */
21#define AT91_EMAC_LBL (1 << 1) /* Loopback Local */
22#define AT91_EMAC_RE (1 << 2) /* Receive Enable */
23#define AT91_EMAC_TE (1 << 3) /* Transmit Enable */
24#define AT91_EMAC_MPE (1 << 4) /* Management Port Enable */
25#define AT91_EMAC_CSR (1 << 5) /* Clear Statistics Registers */
26#define AT91_EMAC_INCSTAT (1 << 6) /* Increment Statistics Registers */
27#define AT91_EMAC_WES (1 << 7) /* Write Enable for Statistics Registers */
28#define AT91_EMAC_BP (1 << 8) /* Back Pressure */
29
30#define AT91_EMAC_CFG 0x04 /* Configuration Register */
31#define AT91_EMAC_SPD (1 << 0) /* Speed */
32#define AT91_EMAC_FD (1 << 1) /* Full Duplex */
33#define AT91_EMAC_BR (1 << 2) /* Bit Rate */
34#define AT91_EMAC_CAF (1 << 4) /* Copy All Frames */
35#define AT91_EMAC_NBC (1 << 5) /* No Broadcast */
36#define AT91_EMAC_MTI (1 << 6) /* Multicast Hash Enable */
37#define AT91_EMAC_UNI (1 << 7) /* Unicast Hash Enable */
38#define AT91_EMAC_BIG (1 << 8) /* Receive 1522 Bytes */
39#define AT91_EMAC_EAE (1 << 9) /* External Address Match Enable */
40#define AT91_EMAC_CLK (3 << 10) /* MDC Clock Divisor */
41#define AT91_EMAC_CLK_DIV8 (0 << 10)
42#define AT91_EMAC_CLK_DIV16 (1 << 10)
43#define AT91_EMAC_CLK_DIV32 (2 << 10)
44#define AT91_EMAC_CLK_DIV64 (3 << 10)
45#define AT91_EMAC_RTY (1 << 12) /* Retry Test */
46#define AT91_EMAC_RMII (1 << 13) /* Reduce MII (RMII) */
47
48#define AT91_EMAC_SR 0x08 /* Status Register */
49#define AT91_EMAC_SR_LINK (1 << 0) /* Link */
50#define AT91_EMAC_SR_MDIO (1 << 1) /* MDIO pin */
51#define AT91_EMAC_SR_IDLE (1 << 2) /* PHY idle */
52
53#define AT91_EMAC_TAR 0x0c /* Transmit Address Register */
54
55#define AT91_EMAC_TCR 0x10 /* Transmit Control Register */
56#define AT91_EMAC_LEN (0x7ff << 0) /* Transmit Frame Length */
57#define AT91_EMAC_NCRC (1 << 15) /* No CRC */
58
59#define AT91_EMAC_TSR 0x14 /* Transmit Status Register */
60#define AT91_EMAC_TSR_OVR (1 << 0) /* Transmit Buffer Overrun */
61#define AT91_EMAC_TSR_COL (1 << 1) /* Collision Occurred */
62#define AT91_EMAC_TSR_RLE (1 << 2) /* Retry Limit Exceeded */
63#define AT91_EMAC_TSR_IDLE (1 << 3) /* Transmitter Idle */
64#define AT91_EMAC_TSR_BNQ (1 << 4) /* Transmit Buffer not Queued */
65#define AT91_EMAC_TSR_COMP (1 << 5) /* Transmit Complete */
66#define AT91_EMAC_TSR_UND (1 << 6) /* Transmit Underrun */
67
68#define AT91_EMAC_RBQP 0x18 /* Receive Buffer Queue Pointer */
69
70#define AT91_EMAC_RSR 0x20 /* Receive Status Register */
71#define AT91_EMAC_RSR_BNA (1 << 0) /* Buffer Not Available */
72#define AT91_EMAC_RSR_REC (1 << 1) /* Frame Received */
73#define AT91_EMAC_RSR_OVR (1 << 2) /* RX Overrun */
74
75#define AT91_EMAC_ISR 0x24 /* Interrupt Status Register */
76#define AT91_EMAC_DONE (1 << 0) /* Management Done */
77#define AT91_EMAC_RCOM (1 << 1) /* Receive Complete */
78#define AT91_EMAC_RBNA (1 << 2) /* Receive Buffer Not Available */
79#define AT91_EMAC_TOVR (1 << 3) /* Transmit Buffer Overrun */
80#define AT91_EMAC_TUND (1 << 4) /* Transmit Buffer Underrun */
81#define AT91_EMAC_RTRY (1 << 5) /* Retry Limit */
82#define AT91_EMAC_TBRE (1 << 6) /* Transmit Buffer Register Empty */
83#define AT91_EMAC_TCOM (1 << 7) /* Transmit Complete */
84#define AT91_EMAC_TIDLE (1 << 8) /* Transmit Idle */
85#define AT91_EMAC_LINK (1 << 9) /* Link */
86#define AT91_EMAC_ROVR (1 << 10) /* RX Overrun */
87#define AT91_EMAC_ABT (1 << 11) /* Abort */
88
89#define AT91_EMAC_IER 0x28 /* Interrupt Enable Register */
90#define AT91_EMAC_IDR 0x2c /* Interrupt Disable Register */
91#define AT91_EMAC_IMR 0x30 /* Interrupt Mask Register */
92
93#define AT91_EMAC_MAN 0x34 /* PHY Maintenance Register */
94#define AT91_EMAC_DATA (0xffff << 0) /* MDIO Data */
95#define AT91_EMAC_REGA (0x1f << 18) /* MDIO Register */
96#define AT91_EMAC_PHYA (0x1f << 23) /* MDIO PHY Address */
97#define AT91_EMAC_RW (3 << 28) /* Read/Write operation */
98#define AT91_EMAC_RW_W (1 << 28)
99#define AT91_EMAC_RW_R (2 << 28)
100#define AT91_EMAC_MAN_802_3 0x40020000 /* IEEE 802.3 value */
101
102/*
103 * Statistics Registers.
104 */
105#define AT91_EMAC_FRA 0x40 /* Frames Transmitted OK */
106#define AT91_EMAC_SCOL 0x44 /* Single Collision Frame */
107#define AT91_EMAC_MCOL 0x48 /* Multiple Collision Frame */
108#define AT91_EMAC_OK 0x4c /* Frames Received OK */
109#define AT91_EMAC_SEQE 0x50 /* Frame Check Sequence Error */
110#define AT91_EMAC_ALE 0x54 /* Alignmemt Error */
111#define AT91_EMAC_DTE 0x58 /* Deffered Transmission Frame */
112#define AT91_EMAC_LCOL 0x5c /* Late Collision */
113#define AT91_EMAC_ECOL 0x60 /* Excessive Collision */
114#define AT91_EMAC_TUE 0x64 /* Transmit Underrun Error */
115#define AT91_EMAC_CSE 0x68 /* Carrier Sense Error */
116#define AT91_EMAC_DRFC 0x6c /* Discard RX Frame */
117#define AT91_EMAC_ROV 0x70 /* Receive Overrun */
118#define AT91_EMAC_CDE 0x74 /* Code Error */
119#define AT91_EMAC_ELR 0x78 /* Excessive Length Error */
120#define AT91_EMAC_RJB 0x7c /* Receive Jabber */
121#define AT91_EMAC_USF 0x80 /* Undersize Frame */
122#define AT91_EMAC_SQEE 0x84 /* SQE Test Error */
123
124/*
125 * Address Registers.
126 */
127#define AT91_EMAC_HSL 0x90 /* Hash Address Low [31:0] */
128#define AT91_EMAC_HSH 0x94 /* Hash Address High [63:32] */
129#define AT91_EMAC_SA1L 0x98 /* Specific Address 1 Low, bytes 0-3 */
130#define AT91_EMAC_SA1H 0x9c /* Specific Address 1 High, bytes 4-5 */
131#define AT91_EMAC_SA2L 0xa0 /* Specific Address 2 Low, bytes 0-3 */
132#define AT91_EMAC_SA2H 0xa4 /* Specific Address 2 High, bytes 4-5 */
133#define AT91_EMAC_SA3L 0xa8 /* Specific Address 3 Low, bytes 0-3 */
134#define AT91_EMAC_SA3H 0xac /* Specific Address 3 High, bytes 4-5 */
135#define AT91_EMAC_SA4L 0xb0 /* Specific Address 4 Low, bytes 0-3 */
136#define AT91_EMAC_SA4H 0xb4 /* Specific Address 4 High, bytes 4-5 */
137
138#endif
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index fd0147e52dbb..b3479fc1cc8f 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -226,42 +226,6 @@ out:
226#endif /* __mem_pci */ 226#endif /* __mem_pci */
227 227
228/* 228/*
229 * If this architecture has ISA IO, then define the isa_read/isa_write
230 * macros.
231 */
232#ifdef __mem_isa
233
234#define isa_readb(addr) __raw_readb(__mem_isa(addr))
235#define isa_readw(addr) __raw_readw(__mem_isa(addr))
236#define isa_readl(addr) __raw_readl(__mem_isa(addr))
237#define isa_writeb(val,addr) __raw_writeb(val,__mem_isa(addr))
238#define isa_writew(val,addr) __raw_writew(val,__mem_isa(addr))
239#define isa_writel(val,addr) __raw_writel(val,__mem_isa(addr))
240#define isa_memset_io(a,b,c) _memset_io(__mem_isa(a),(b),(c))
241#define isa_memcpy_fromio(a,b,c) _memcpy_fromio((a),__mem_isa(b),(c))
242#define isa_memcpy_toio(a,b,c) _memcpy_toio(__mem_isa((a)),(b),(c))
243
244#define isa_eth_io_copy_and_sum(a,b,c,d) \
245 eth_copy_and_sum((a),__mem_isa(b),(c),(d))
246
247#else /* __mem_isa */
248
249#define isa_readb(addr) (__readwrite_bug("isa_readb"),0)
250#define isa_readw(addr) (__readwrite_bug("isa_readw"),0)
251#define isa_readl(addr) (__readwrite_bug("isa_readl"),0)
252#define isa_writeb(val,addr) __readwrite_bug("isa_writeb")
253#define isa_writew(val,addr) __readwrite_bug("isa_writew")
254#define isa_writel(val,addr) __readwrite_bug("isa_writel")
255#define isa_memset_io(a,b,c) __readwrite_bug("isa_memset_io")
256#define isa_memcpy_fromio(a,b,c) __readwrite_bug("isa_memcpy_fromio")
257#define isa_memcpy_toio(a,b,c) __readwrite_bug("isa_memcpy_toio")
258
259#define isa_eth_io_copy_and_sum(a,b,c,d) \
260 __readwrite_bug("isa_eth_io_copy_and_sum")
261
262#endif /* __mem_isa */
263
264/*
265 * ioremap and friends. 229 * ioremap and friends.
266 * 230 *
267 * ioremap takes a PCI memory address, as specified in 231 * ioremap takes a PCI memory address, as specified in
diff --git a/include/asm-arm/poll.h b/include/asm-arm/poll.h
index 2744ca831f5d..5030b2b232a3 100644
--- a/include/asm-arm/poll.h
+++ b/include/asm-arm/poll.h
@@ -16,6 +16,7 @@
16#define POLLWRBAND 0x0200 16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400 17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000 18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
19 20
20struct pollfd { 21struct pollfd {
21 int fd; 22 int fd;
diff --git a/include/asm-arm26/poll.h b/include/asm-arm26/poll.h
index fdfdab064a65..9ccb7f4190ca 100644
--- a/include/asm-arm26/poll.h
+++ b/include/asm-arm26/poll.h
@@ -15,6 +15,7 @@
15#define POLLWRNORM 0x0100 15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200 16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400 17#define POLLMSG 0x0400
18#define POLLRDHUP 0x2000
18 19
19struct pollfd { 20struct pollfd {
20 int fd; 21 int fd;
diff --git a/include/asm-cris/poll.h b/include/asm-cris/poll.h
index 1c0efc3e4be7..1b25d4cf498c 100644
--- a/include/asm-cris/poll.h
+++ b/include/asm-cris/poll.h
@@ -15,6 +15,7 @@
15#define POLLWRBAND 512 15#define POLLWRBAND 512
16#define POLLMSG 1024 16#define POLLMSG 1024
17#define POLLREMOVE 4096 17#define POLLREMOVE 4096
18#define POLLRDHUP 8192
18 19
19struct pollfd { 20struct pollfd {
20 int fd; 21 int fd;
diff --git a/include/asm-cris/system.h b/include/asm-cris/system.h
index d48670107a85..1d63c2aa8ec2 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
71 71
72#define arch_align_stack(x) (x) 72#define arch_align_stack(x) (x)
73 73
74void default_idle(void);
75
74#endif 76#endif
diff --git a/include/asm-frv/poll.h b/include/asm-frv/poll.h
index 8cbcd60e334f..c8fe8801d075 100644
--- a/include/asm-frv/poll.h
+++ b/include/asm-frv/poll.h
@@ -12,6 +12,7 @@
12#define POLLRDBAND 128 12#define POLLRDBAND 128
13#define POLLWRBAND 256 13#define POLLWRBAND 256
14#define POLLMSG 0x0400 14#define POLLMSG 0x0400
15#define POLLRDHUP 0x2000
15 16
16struct pollfd { 17struct pollfd {
17 int fd; 18 int fd;
diff --git a/include/asm-h8300/poll.h b/include/asm-h8300/poll.h
index bf49ab8ad6da..fc52103b276a 100644
--- a/include/asm-h8300/poll.h
+++ b/include/asm-h8300/poll.h
@@ -12,6 +12,7 @@
12#define POLLRDBAND 128 12#define POLLRDBAND 128
13#define POLLWRBAND 256 13#define POLLWRBAND 256
14#define POLLMSG 0x0400 14#define POLLMSG 0x0400
15#define POLLRDHUP 0x2000
15 16
16struct pollfd { 17struct pollfd {
17 int fd; 18 int fd;
diff --git a/include/asm-i386/dmi.h b/include/asm-i386/dmi.h
new file mode 100644
index 000000000000..38d4eeb7fc7e
--- /dev/null
+++ b/include/asm-i386/dmi.h
@@ -0,0 +1,11 @@
1#ifndef _ASM_DMI_H
2#define _ASM_DMI_H 1
3
4#include <asm/io.h>
5
6/* Use early IO mappings for DMI because it's initialized early */
7#define dmi_ioremap bt_ioremap
8#define dmi_iounmap bt_iounmap
9#define dmi_alloc alloc_bootmem
10
11#endif
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index 03233c2ab820..79670bb4b0c7 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
219 */ 219 */
220#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) 220#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
221 221
222#define isa_readb(a) readb(__ISA_IO_base + (a))
223#define isa_readw(a) readw(__ISA_IO_base + (a))
224#define isa_readl(a) readl(__ISA_IO_base + (a))
225#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
226#define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
227#define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
228#define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
229#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
230#define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
231
232
233/* 222/*
234 * Again, i386 does not require mem IO specific function. 223 * Again, i386 does not require mem IO specific function.
235 */ 224 */
236 225
237#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d)) 226#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d))
238#define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(__ISA_IO_base + (b)),(c),(d))
239 227
240/** 228/**
241 * check_signature - find BIOS signatures 229 * check_signature - find BIOS signatures
diff --git a/include/asm-i386/poll.h b/include/asm-i386/poll.h
index aecc80a15d36..2cd4929abd40 100644
--- a/include/asm-i386/poll.h
+++ b/include/asm-i386/poll.h
@@ -16,6 +16,7 @@
16#define POLLWRBAND 0x0200 16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400 17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000 18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
19 20
20struct pollfd { 21struct pollfd {
21 int fd; 22 int fd;
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index d0d8d7448d88..19cc79c9a35d 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -499,4 +499,6 @@ static inline void sched_cacheflush(void)
499extern unsigned long arch_align_stack(unsigned long sp); 499extern unsigned long arch_align_stack(unsigned long sp);
500extern void free_init_pages(char *what, unsigned long begin, unsigned long end); 500extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
501 501
502void default_idle(void);
503
502#endif 504#endif
diff --git a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h
index f7a517654308..d734585a23cf 100644
--- a/include/asm-ia64/acpi.h
+++ b/include/asm-ia64/acpi.h
@@ -111,7 +111,11 @@ extern int additional_cpus;
111 111
112#ifdef CONFIG_ACPI_NUMA 112#ifdef CONFIG_ACPI_NUMA
113/* Proximity bitmap length; _PXM is at most 255 (8 bit)*/ 113/* Proximity bitmap length; _PXM is at most 255 (8 bit)*/
114#ifdef CONFIG_IA64_NR_NODES
115#define MAX_PXM_DOMAINS CONFIG_IA64_NR_NODES
116#else
114#define MAX_PXM_DOMAINS (256) 117#define MAX_PXM_DOMAINS (256)
118#endif
115extern int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS]; 119extern int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS];
116extern int __initdata nid_to_pxm_map[MAX_NUMNODES]; 120extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
117#endif 121#endif
diff --git a/include/asm-ia64/asmmacro.h b/include/asm-ia64/asmmacro.h
index 77af457f4ad7..d4cec32083d8 100644
--- a/include/asm-ia64/asmmacro.h
+++ b/include/asm-ia64/asmmacro.h
@@ -51,6 +51,17 @@ name:
51 [99:] x 51 [99:] x
52 52
53/* 53/*
54 * Tag MCA recoverable instruction ranges.
55 */
56
57 .section "__mca_table", "a" // declare section & section attributes
58 .previous
59
60# define MCA_RECOVER_RANGE(y) \
61 .xdata4 "__mca_table", y-., 99f-.; \
62 [99:]
63
64/*
54 * Mark instructions that need a load of a virtual address patched to be 65 * Mark instructions that need a load of a virtual address patched to be
55 * a load of a physical address. We use this either in critical performance 66 * a load of a physical address. We use this either in critical performance
56 * path (ivt.S - TLB miss processing) or in places where it might not be 67 * path (ivt.S - TLB miss processing) or in places where it might not be
diff --git a/include/asm-ia64/linkage.h b/include/asm-ia64/linkage.h
index 14cd72cd8007..ef22a45c1890 100644
--- a/include/asm-ia64/linkage.h
+++ b/include/asm-ia64/linkage.h
@@ -1,6 +1,14 @@
1#ifndef __ASM_LINKAGE_H 1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H 2#define __ASM_LINKAGE_H
3 3
4#ifndef __ASSEMBLY__
5
4#define asmlinkage CPP_ASMLINKAGE __attribute__((syscall_linkage)) 6#define asmlinkage CPP_ASMLINKAGE __attribute__((syscall_linkage))
5 7
8#else
9
10#include <asm/asmmacro.h>
11
12#endif
13
6#endif 14#endif
diff --git a/include/asm-ia64/machvec_dig.h b/include/asm-ia64/machvec_dig.h
index 4dc8522c974f..8a0752f40987 100644
--- a/include/asm-ia64/machvec_dig.h
+++ b/include/asm-ia64/machvec_dig.h
@@ -2,7 +2,6 @@
2#define _ASM_IA64_MACHVEC_DIG_h 2#define _ASM_IA64_MACHVEC_DIG_h
3 3
4extern ia64_mv_setup_t dig_setup; 4extern ia64_mv_setup_t dig_setup;
5extern ia64_mv_irq_init_t dig_irq_init;
6 5
7/* 6/*
8 * This stuff has dual use! 7 * This stuff has dual use!
@@ -13,6 +12,5 @@ extern ia64_mv_irq_init_t dig_irq_init;
13 */ 12 */
14#define platform_name "dig" 13#define platform_name "dig"
15#define platform_setup dig_setup 14#define platform_setup dig_setup
16#define platform_irq_init dig_irq_init
17 15
18#endif /* _ASM_IA64_MACHVEC_DIG_h */ 16#endif /* _ASM_IA64_MACHVEC_DIG_h */
diff --git a/include/asm-ia64/numa.h b/include/asm-ia64/numa.h
index 3ae128fe0823..dae6aeb7b119 100644
--- a/include/asm-ia64/numa.h
+++ b/include/asm-ia64/numa.h
@@ -23,7 +23,7 @@
23 23
24#include <asm/mmzone.h> 24#include <asm/mmzone.h>
25 25
26extern u8 cpu_to_node_map[NR_CPUS] __cacheline_aligned; 26extern u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
27extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned; 27extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
28 28
29/* Stuff below this line could be architecture independent */ 29/* Stuff below this line could be architecture independent */
diff --git a/include/asm-ia64/numnodes.h b/include/asm-ia64/numnodes.h
index 21cff4da5485..e9d356f549d9 100644
--- a/include/asm-ia64/numnodes.h
+++ b/include/asm-ia64/numnodes.h
@@ -3,13 +3,18 @@
3 3
4#ifdef CONFIG_IA64_DIG 4#ifdef CONFIG_IA64_DIG
5/* Max 8 Nodes */ 5/* Max 8 Nodes */
6#define NODES_SHIFT 3 6# define NODES_SHIFT 3
7#elif defined(CONFIG_IA64_HP_ZX1) || defined(CONFIG_IA64_HP_ZX1_SWIOTLB) 7#elif defined(CONFIG_IA64_HP_ZX1) || defined(CONFIG_IA64_HP_ZX1_SWIOTLB)
8/* Max 32 Nodes */ 8/* Max 32 Nodes */
9#define NODES_SHIFT 5 9# define NODES_SHIFT 5
10#elif defined(CONFIG_IA64_SGI_SN2) || defined(CONFIG_IA64_GENERIC) 10#elif defined(CONFIG_IA64_SGI_SN2) || defined(CONFIG_IA64_GENERIC)
11/* Max 256 Nodes */ 11# if CONFIG_IA64_NR_NODES == 256
12#define NODES_SHIFT 8 12# define NODES_SHIFT 8
13# elif CONFIG_IA64_NR_NODES <= 512
14# define NODES_SHIFT 9
15# elif CONFIG_IA64_NR_NODES <= 1024
16# define NODES_SHIFT 10
17# endif
13#endif 18#endif
14 19
15#endif /* _ASM_MAX_NUMNODES_H */ 20#endif /* _ASM_MAX_NUMNODES_H */
diff --git a/include/asm-ia64/page.h b/include/asm-ia64/page.h
index 3ab27333dae4..6e9aa23250c4 100644
--- a/include/asm-ia64/page.h
+++ b/include/asm-ia64/page.h
@@ -149,7 +149,7 @@ typedef union ia64_va {
149 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT))) 149 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
150# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 150# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
151# define is_hugepage_only_range(mm, addr, len) \ 151# define is_hugepage_only_range(mm, addr, len) \
152 (REGION_NUMBER(addr) == RGN_HPAGE && \ 152 (REGION_NUMBER(addr) == RGN_HPAGE || \
153 REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE) 153 REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
154extern unsigned int hpage_shift; 154extern unsigned int hpage_shift;
155#endif 155#endif
diff --git a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
index 7708ec669a33..4e7e6f23b08c 100644
--- a/include/asm-ia64/pal.h
+++ b/include/asm-ia64/pal.h
@@ -1640,8 +1640,7 @@ ia64_pal_logical_to_phys(u64 proc_number, pal_logical_to_physical_t *mapping)
1640 1640
1641 if (iprv.status == PAL_STATUS_SUCCESS) 1641 if (iprv.status == PAL_STATUS_SUCCESS)
1642 { 1642 {
1643 if (proc_number == 0) 1643 mapping->overview.overview_data = iprv.v0;
1644 mapping->overview.overview_data = iprv.v0;
1645 mapping->ppli1.ppli1_data = iprv.v1; 1644 mapping->ppli1.ppli1_data = iprv.v1;
1646 mapping->ppli2.ppli2_data = iprv.v2; 1645 mapping->ppli2.ppli2_data = iprv.v2;
1647 } 1646 }
diff --git a/include/asm-ia64/poll.h b/include/asm-ia64/poll.h
index 160258a0528d..bcaf9f140242 100644
--- a/include/asm-ia64/poll.h
+++ b/include/asm-ia64/poll.h
@@ -21,6 +21,7 @@
21#define POLLWRBAND 0x0200 21#define POLLWRBAND 0x0200
22#define POLLMSG 0x0400 22#define POLLMSG 0x0400
23#define POLLREMOVE 0x1000 23#define POLLREMOVE 0x1000
24#define POLLRDHUP 0x2000
24 25
25struct pollfd { 26struct pollfd {
26 int fd; 27 int fd;
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 128fefd8056f..b3bd58e80690 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -181,7 +181,6 @@ DECLARE_PER_CPU(struct cpuinfo_ia64, cpu_info);
181#define local_cpu_data (&__ia64_per_cpu_var(cpu_info)) 181#define local_cpu_data (&__ia64_per_cpu_var(cpu_info))
182#define cpu_data(cpu) (&per_cpu(cpu_info, cpu)) 182#define cpu_data(cpu) (&per_cpu(cpu_info, cpu))
183 183
184extern void identify_cpu (struct cpuinfo_ia64 *);
185extern void print_cpu_info (struct cpuinfo_ia64 *); 184extern void print_cpu_info (struct cpuinfo_ia64 *);
186 185
187typedef struct { 186typedef struct {
diff --git a/include/asm-ia64/sn/l1.h b/include/asm-ia64/sn/l1.h
index e3b819110d47..344bf44bb356 100644
--- a/include/asm-ia64/sn/l1.h
+++ b/include/asm-ia64/sn/l1.h
@@ -34,6 +34,8 @@
34#define L1_BRICKTYPE_IA 0x6b /* k */ 34#define L1_BRICKTYPE_IA 0x6b /* k */
35#define L1_BRICKTYPE_ATHENA 0x2b /* + */ 35#define L1_BRICKTYPE_ATHENA 0x2b /* + */
36#define L1_BRICKTYPE_DAYTONA 0x7a /* z */ 36#define L1_BRICKTYPE_DAYTONA 0x7a /* z */
37#define L1_BRICKTYPE_1932 0x2c /* . */
38#define L1_BRICKTYPE_191010 0x2e /* , */
37 39
38/* board type response codes */ 40/* board type response codes */
39#define L1_BOARDTYPE_IP69 0x0100 /* CA */ 41#define L1_BOARDTYPE_IP69 0x0100 /* CA */
@@ -46,5 +48,4 @@
46#define L1_BOARDTYPE_DAYTONA 0x0800 /* AD */ 48#define L1_BOARDTYPE_DAYTONA 0x0800 /* AD */
47#define L1_BOARDTYPE_INVAL (-1) /* invalid brick type */ 49#define L1_BOARDTYPE_INVAL (-1) /* invalid brick type */
48 50
49
50#endif /* _ASM_IA64_SN_L1_H */ 51#endif /* _ASM_IA64_SN_L1_H */
diff --git a/include/asm-ia64/sn/pcibr_provider.h b/include/asm-ia64/sn/pcibr_provider.h
index a601d3af39b6..51260ab70d91 100644
--- a/include/asm-ia64/sn/pcibr_provider.h
+++ b/include/asm-ia64/sn/pcibr_provider.h
@@ -144,4 +144,5 @@ extern int sal_pcibr_slot_enable(struct pcibus_info *soft, int device,
144 void *resp); 144 void *resp);
145extern int sal_pcibr_slot_disable(struct pcibus_info *soft, int device, 145extern int sal_pcibr_slot_disable(struct pcibus_info *soft, int device,
146 int action, void *resp); 146 int action, void *resp);
147extern u16 sn_ioboard_to_pci_bus(struct pci_bus *pci_bus);
147#endif 148#endif
diff --git a/include/asm-ia64/sn/pcidev.h b/include/asm-ia64/sn/pcidev.h
index 38cdffbc4c7b..eac3561574be 100644
--- a/include/asm-ia64/sn/pcidev.h
+++ b/include/asm-ia64/sn/pcidev.h
@@ -76,6 +76,7 @@ extern void sn_pci_controller_fixup(int segment, int busnum,
76 struct pci_bus *bus); 76 struct pci_bus *bus);
77extern void sn_bus_store_sysdata(struct pci_dev *dev); 77extern void sn_bus_store_sysdata(struct pci_dev *dev);
78extern void sn_bus_free_sysdata(void); 78extern void sn_bus_free_sysdata(void);
79extern void sn_generate_path(struct pci_bus *pci_bus, char *address);
79extern void sn_pci_fixup_slot(struct pci_dev *dev); 80extern void sn_pci_fixup_slot(struct pci_dev *dev);
80extern void sn_pci_unfixup_slot(struct pci_dev *dev); 81extern void sn_pci_unfixup_slot(struct pci_dev *dev);
81extern void sn_irq_lh_init(void); 82extern void sn_irq_lh_init(void);
diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h
index ff33e3bd3f8e..30dcfa442e53 100644
--- a/include/asm-ia64/sn/sn_feature_sets.h
+++ b/include/asm-ia64/sn/sn_feature_sets.h
@@ -30,8 +30,7 @@ extern int sn_prom_feature_available(int id);
30 30
31#define PRF_PAL_CACHE_FLUSH_SAFE 0 31#define PRF_PAL_CACHE_FLUSH_SAFE 0
32#define PRF_DEVICE_FLUSH_LIST 1 32#define PRF_DEVICE_FLUSH_LIST 1
33 33#define PRF_HOTPLUG_SUPPORT 2
34
35 34
36/* --------------------- OS Features -------------------------------*/ 35/* --------------------- OS Features -------------------------------*/
37 36
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
index e77f0c9b7d3d..244449df7411 100644
--- a/include/asm-ia64/sn/sn_sal.h
+++ b/include/asm-ia64/sn/sn_sal.h
@@ -907,18 +907,22 @@ ia64_sn_sysctl_tio_clock_reset(nasid_t nasid)
907/* 907/*
908 * Get the associated ioboard type for a given nasid. 908 * Get the associated ioboard type for a given nasid.
909 */ 909 */
910static inline int 910static inline s64
911ia64_sn_sysctl_ioboard_get(nasid_t nasid) 911ia64_sn_sysctl_ioboard_get(nasid_t nasid, u16 *ioboard)
912{ 912{
913 struct ia64_sal_retval rv; 913 struct ia64_sal_retval isrv;
914 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD, 914 SAL_CALL_REENTRANT(isrv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD,
915 nasid, 0, 0, 0, 0, 0); 915 nasid, 0, 0, 0, 0, 0);
916 if (rv.v0 != 0) 916 if (isrv.v0 != 0) {
917 return (int)rv.v0; 917 *ioboard = isrv.v0;
918 if (rv.v1 != 0) 918 return isrv.status;
919 return (int)rv.v1; 919 }
920 920 if (isrv.v1 != 0) {
921 return 0; 921 *ioboard = isrv.v1;
922 return isrv.status;
923 }
924
925 return isrv.status;
922} 926}
923 927
924/** 928/**
@@ -1037,7 +1041,7 @@ ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift,
1037 1041
1038/***** BEGIN HACK - temp til old proms no longer supported ********/ 1042/***** BEGIN HACK - temp til old proms no longer supported ********/
1039 if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) { 1043 if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
1040 int nasid = get_sapicid() & 0xfff;; 1044 int nasid = get_sapicid() & 0xfff;
1041#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL 1045#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL
1042#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48 1046#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48
1043 if (shubtype) *shubtype = 0; 1047 if (shubtype) *shubtype = 0;
diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h
index cd4233d66f15..2f3620593687 100644
--- a/include/asm-ia64/system.h
+++ b/include/asm-ia64/system.h
@@ -265,6 +265,8 @@ void sched_cacheflush(void);
265 265
266#define arch_align_stack(x) (x) 266#define arch_align_stack(x) (x)
267 267
268void default_idle(void);
269
268#endif /* __KERNEL__ */ 270#endif /* __KERNEL__ */
269 271
270#endif /* __ASSEMBLY__ */ 272#endif /* __ASSEMBLY__ */
diff --git a/include/asm-m32r/poll.h b/include/asm-m32r/poll.h
index 43b7acf732d5..9e0e700e727c 100644
--- a/include/asm-m32r/poll.h
+++ b/include/asm-m32r/poll.h
@@ -21,6 +21,7 @@
21#define POLLWRBAND 0x0200 21#define POLLWRBAND 0x0200
22#define POLLMSG 0x0400 22#define POLLMSG 0x0400
23#define POLLREMOVE 0x1000 23#define POLLREMOVE 0x1000
24#define POLLRDHUP 0x2000
24 25
25struct pollfd { 26struct pollfd {
26 int fd; 27 int fd;
diff --git a/include/asm-m68k/poll.h b/include/asm-m68k/poll.h
index c4b69c4a87e1..0fb8843647f8 100644
--- a/include/asm-m68k/poll.h
+++ b/include/asm-m68k/poll.h
@@ -13,6 +13,7 @@
13#define POLLWRBAND 256 13#define POLLWRBAND 256
14#define POLLMSG 0x0400 14#define POLLMSG 0x0400
15#define POLLREMOVE 0x1000 15#define POLLREMOVE 0x1000
16#define POLLRDHUP 0x2000
16 17
17struct pollfd { 18struct pollfd {
18 int fd; 19 int fd;
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index 546a17e56a9b..6b17eb9d79a5 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 *);
556 */ 556 */
557#define __ISA_IO_base ((char *)(isa_slot_offset)) 557#define __ISA_IO_base ((char *)(isa_slot_offset))
558 558
559#define isa_readb(a) readb(__ISA_IO_base + (a))
560#define isa_readw(a) readw(__ISA_IO_base + (a))
561#define isa_readl(a) readl(__ISA_IO_base + (a))
562#define isa_readq(a) readq(__ISA_IO_base + (a))
563#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
564#define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
565#define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
566#define isa_writeq(q,a) writeq(q,__ISA_IO_base + (a))
567#define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
568#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
569#define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
570
571/* 559/*
572 * We don't have csum_partial_copy_fromio() yet, so we cheat here and 560 * We don't have csum_partial_copy_fromio() yet, so we cheat here and
573 * just copy it. The net code will then do the checksum later. 561 * just copy it. The net code will then do the checksum later.
574 */ 562 */
575#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len)) 563#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
576#define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(b),(c),(d))
577 564
578/* 565/*
579 * check_signature - find BIOS signatures 566 * check_signature - find BIOS signatures
diff --git a/include/asm-mips/linkage.h b/include/asm-mips/linkage.h
index 291c2d01c44f..b6185d3cfe68 100644
--- a/include/asm-mips/linkage.h
+++ b/include/asm-mips/linkage.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_LINKAGE_H 1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H 2#define __ASM_LINKAGE_H
3 3
4/* Nothing to see here... */ 4#ifdef __ASSEMBLY__
5#include <asm/asm.h>
6#endif
5 7
6#endif 8#endif
diff --git a/include/asm-mips/poll.h b/include/asm-mips/poll.h
index a000f1f789e3..70881f8c5c50 100644
--- a/include/asm-mips/poll.h
+++ b/include/asm-mips/poll.h
@@ -17,6 +17,7 @@
17/* These seem to be more or less nonstandard ... */ 17/* These seem to be more or less nonstandard ... */
18#define POLLMSG 0x0400 18#define POLLMSG 0x0400
19#define POLLREMOVE 0x1000 19#define POLLREMOVE 0x1000
20#define POLLRDHUP 0x2000
20 21
21struct pollfd { 22struct pollfd {
22 int fd; 23 int fd;
diff --git a/include/asm-parisc/io.h b/include/asm-parisc/io.h
index 0db00adc942a..be0c7234a6da 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);
294void memcpy_fromio(void *dst, const volatile void __iomem *src, int count); 294void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
295void memcpy_toio(volatile void __iomem *dst, const void *src, int count); 295void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
296 296
297/* Support old drivers which don't ioremap.
298 * NB this interface is scheduled to disappear in 2.5
299 */
300
301#define __isa_addr(x) (void __iomem *)(F_EXTEND(0xfc000000) | (x))
302#define isa_readb(a) readb(__isa_addr(a))
303#define isa_readw(a) readw(__isa_addr(a))
304#define isa_readl(a) readl(__isa_addr(a))
305#define isa_writeb(b,a) writeb((b), __isa_addr(a))
306#define isa_writew(b,a) writew((b), __isa_addr(a))
307#define isa_writel(b,a) writel((b), __isa_addr(a))
308#define isa_memset_io(a,b,c) memset_io(__isa_addr(a), (b), (c))
309#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a), __isa_addr(b), (c))
310#define isa_memcpy_toio(a,b,c) memcpy_toio(__isa_addr(a), (b), (c))
311
312
313/* 297/*
314 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and 298 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
315 * just copy it. The net code will then do the checksum later. Presently 299 * 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);
318 302
319#define eth_io_copy_and_sum(skb,src,len,unused) \ 303#define eth_io_copy_and_sum(skb,src,len,unused) \
320 memcpy_fromio((skb)->data,(src),(len)) 304 memcpy_fromio((skb)->data,(src),(len))
321#define isa_eth_io_copy_and_sum(skb,src,len,unused) \
322 isa_memcpy_fromio((skb)->data,(src),(len))
323 305
324/* Port-space IO */ 306/* Port-space IO */
325 307
diff --git a/include/asm-parisc/poll.h b/include/asm-parisc/poll.h
index 1c1da86934cf..20e4d03c74cb 100644
--- a/include/asm-parisc/poll.h
+++ b/include/asm-parisc/poll.h
@@ -16,6 +16,7 @@
16#define POLLWRBAND 0x0200 16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400 17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000 18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
19 20
20struct pollfd { 21struct pollfd {
21 int fd; 22 int fd;
diff --git a/include/asm-powerpc/poll.h b/include/asm-powerpc/poll.h
index edd2054da86b..9c7d12631033 100644
--- a/include/asm-powerpc/poll.h
+++ b/include/asm-powerpc/poll.h
@@ -13,6 +13,7 @@
13#define POLLWRBAND 0x0200 13#define POLLWRBAND 0x0200
14#define POLLMSG 0x0400 14#define POLLMSG 0x0400
15#define POLLREMOVE 0x1000 15#define POLLREMOVE 0x1000
16#define POLLRDHUP 0x2000
16 17
17struct pollfd { 18struct pollfd {
18 int fd; 19 int fd;
diff --git a/include/asm-s390/bug.h b/include/asm-s390/bug.h
index a2e7430aafa6..7ddaa05b98d8 100644
--- a/include/asm-s390/bug.h
+++ b/include/asm-s390/bug.h
@@ -4,9 +4,10 @@
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5 5
6#ifdef CONFIG_BUG 6#ifdef CONFIG_BUG
7
7#define BUG() do { \ 8#define BUG() do { \
8 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 9 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
9 __asm__ __volatile__(".long 0"); \ 10 __builtin_trap(); \
10} while (0) 11} while (0)
11 12
12#define HAVE_ARCH_BUG 13#define HAVE_ARCH_BUG
diff --git a/include/asm-s390/poll.h b/include/asm-s390/poll.h
index e90a5ca42061..6f7f65ac7d27 100644
--- a/include/asm-s390/poll.h
+++ b/include/asm-s390/poll.h
@@ -24,6 +24,7 @@
24#define POLLWRBAND 0x0200 24#define POLLWRBAND 0x0200
25#define POLLMSG 0x0400 25#define POLLMSG 0x0400
26#define POLLREMOVE 0x1000 26#define POLLREMOVE 0x1000
27#define POLLRDHUP 0x2000
27 28
28struct pollfd { 29struct pollfd {
29 int fd; 30 int fd;
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index b0b2937b6f83..2c3afe71323d 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)
174 generic_io_base = pbase; 174 generic_io_base = pbase;
175} 175}
176 176
177#define isa_readb(a) readb(ioport_map(a, 1))
178#define isa_readw(a) readw(ioport_map(a, 2))
179#define isa_readl(a) readl(ioport_map(a, 4))
180#define isa_writeb(b,a) writeb(b,ioport_map(a, 1))
181#define isa_writew(w,a) writew(w,ioport_map(a, 2))
182#define isa_writel(l,a) writel(l,ioport_map(a, 4))
183
184#define isa_memset_io(a,b,c) \
185 memset((void *)(ioport_map((unsigned long)(a), 1)),(b),(c))
186#define isa_memcpy_fromio(a,b,c) \
187 memcpy((a),(void *)(ioport_map((unsigned long)(b), 1)),(c))
188#define isa_memcpy_toio(a,b,c) \
189 memcpy((void *)(ioport_map((unsigned long)(a), 1)),(b),(c))
190
191/* We really want to try and get these to memcpy etc */ 177/* We really want to try and get these to memcpy etc */
192extern void memcpy_fromio(void *, volatile void __iomem *, unsigned long); 178extern void memcpy_fromio(void *, volatile void __iomem *, unsigned long);
193extern void memcpy_toio(volatile void __iomem *, const void *, unsigned long); 179extern 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 52f95b9188dc..dbca9b32f4a6 100644
--- a/include/asm-sh/poll.h
+++ b/include/asm-sh/poll.h
@@ -16,6 +16,7 @@
16#define POLLWRBAND 0x0200 16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400 17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000 18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
19 20
20struct pollfd { 21struct pollfd {
21 int fd; 22 int fd;
diff --git a/include/asm-sh64/poll.h b/include/asm-sh64/poll.h
index a420d14eb704..3a6cbad08d28 100644
--- a/include/asm-sh64/poll.h
+++ b/include/asm-sh64/poll.h
@@ -26,6 +26,7 @@
26#define POLLWRNORM 0x0100 26#define POLLWRNORM 0x0100
27#define POLLWRBAND 0x0200 27#define POLLWRBAND 0x0200
28#define POLLMSG 0x0400 28#define POLLMSG 0x0400
29#define POLLRDHUP 0x2000
29 30
30struct pollfd { 31struct pollfd {
31 int fd; 32 int fd;
diff --git a/include/asm-sparc/cpudata.h b/include/asm-sparc/cpudata.h
index ec0d9ef90a3b..a2c4d51d36c4 100644
--- a/include/asm-sparc/cpudata.h
+++ b/include/asm-sparc/cpudata.h
@@ -18,6 +18,7 @@ typedef struct {
18 unsigned int counter; 18 unsigned int counter;
19 int prom_node; 19 int prom_node;
20 int mid; 20 int mid;
21 int next;
21} cpuinfo_sparc; 22} cpuinfo_sparc;
22 23
23DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data); 24DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
diff --git a/include/asm-sparc/poll.h b/include/asm-sparc/poll.h
index 3ddcc6481f09..26f13fb35497 100644
--- a/include/asm-sparc/poll.h
+++ b/include/asm-sparc/poll.h
@@ -13,6 +13,7 @@
13#define POLLWRBAND 256 13#define POLLWRBAND 256
14#define POLLMSG 512 14#define POLLMSG 512
15#define POLLREMOVE 1024 15#define POLLREMOVE 1024
16#define POLLRDHUP 2048
16 17
17struct pollfd { 18struct pollfd {
18 int fd; 19 int fd;
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index 580c51d011df..98c46e3fbe8a 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
81 return 0; 81 return 0;
82} 82}
83 83
84extern __volatile__ int __cpu_number_map[NR_CPUS];
85extern __volatile__ int __cpu_logical_map[NR_CPUS];
86
87static inline int cpu_logical_map(int cpu) 84static inline int cpu_logical_map(int cpu)
88{ 85{
89 return __cpu_logical_map[cpu]; 86 return cpu;
90}
91static inline int cpu_number_map(int cpu)
92{
93 return __cpu_number_map[cpu];
94} 87}
95 88
96static inline int hard_smp4m_processor_id(void) 89static inline int hard_smp4m_processor_id(void)
diff --git a/include/asm-sparc/spinlock.h b/include/asm-sparc/spinlock.h
index e344c98a6f5f..3350c90c7869 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)
94#define __raw_read_lock(lock) \ 94#define __raw_read_lock(lock) \
95do { unsigned long flags; \ 95do { unsigned long flags; \
96 local_irq_save(flags); \ 96 local_irq_save(flags); \
97 __raw_read_lock(lock); \ 97 __read_lock(lock); \
98 local_irq_restore(flags); \ 98 local_irq_restore(flags); \
99} while(0) 99} while(0)
100 100
@@ -114,11 +114,11 @@ static inline void __read_unlock(raw_rwlock_t *rw)
114#define __raw_read_unlock(lock) \ 114#define __raw_read_unlock(lock) \
115do { unsigned long flags; \ 115do { unsigned long flags; \
116 local_irq_save(flags); \ 116 local_irq_save(flags); \
117 __raw_read_unlock(lock); \ 117 __read_unlock(lock); \
118 local_irq_restore(flags); \ 118 local_irq_restore(flags); \
119} while(0) 119} while(0)
120 120
121extern __inline__ void __raw_write_lock(raw_rwlock_t *rw) 121static inline void __raw_write_lock(raw_rwlock_t *rw)
122{ 122{
123 register raw_rwlock_t *lp asm("g1"); 123 register raw_rwlock_t *lp asm("g1");
124 lp = rw; 124 lp = rw;
@@ -131,9 +131,28 @@ extern __inline__ void __raw_write_lock(raw_rwlock_t *rw)
131 : "g2", "g4", "memory", "cc"); 131 : "g2", "g4", "memory", "cc");
132} 132}
133 133
134static inline int __raw_write_trylock(raw_rwlock_t *rw)
135{
136 unsigned int val;
137
138 __asm__ __volatile__("ldstub [%1 + 3], %0"
139 : "=r" (val)
140 : "r" (&rw->lock)
141 : "memory");
142
143 if (val == 0) {
144 val = rw->lock & ~0xff;
145 if (val)
146 ((volatile u8*)&rw->lock)[3] = 0;
147 }
148
149 return (val == 0);
150}
151
134#define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0) 152#define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0)
135 153
136#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) 154#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
155#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
137 156
138#endif /* !(__ASSEMBLY__) */ 157#endif /* !(__ASSEMBLY__) */
139 158
diff --git a/include/asm-sparc64/poll.h b/include/asm-sparc64/poll.h
index 31b611aa7468..ab6b0d1bb4ad 100644
--- a/include/asm-sparc64/poll.h
+++ b/include/asm-sparc64/poll.h
@@ -13,6 +13,7 @@
13#define POLLWRBAND 256 13#define POLLWRBAND 256
14#define POLLMSG 512 14#define POLLMSG 512
15#define POLLREMOVE 1024 15#define POLLREMOVE 1024
16#define POLLRDHUP 2048
16 17
17struct pollfd { 18struct pollfd {
18 int fd; 19 int fd;
diff --git a/include/asm-v850/linkage.h b/include/asm-v850/linkage.h
index 291c2d01c44f..b6185d3cfe68 100644
--- a/include/asm-v850/linkage.h
+++ b/include/asm-v850/linkage.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_LINKAGE_H 1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H 2#define __ASM_LINKAGE_H
3 3
4/* Nothing to see here... */ 4#ifdef __ASSEMBLY__
5#include <asm/asm.h>
6#endif
5 7
6#endif 8#endif
diff --git a/include/asm-v850/poll.h b/include/asm-v850/poll.h
index 0369562c7e15..c10176c2c28f 100644
--- a/include/asm-v850/poll.h
+++ b/include/asm-v850/poll.h
@@ -13,6 +13,7 @@
13#define POLLWRBAND 0x0100 13#define POLLWRBAND 0x0100
14#define POLLMSG 0x0400 14#define POLLMSG 0x0400
15#define POLLREMOVE 0x1000 15#define POLLREMOVE 0x1000
16#define POLLRDHUP 0x2000
16 17
17struct pollfd { 18struct pollfd {
18 int fd; 19 int fd;
diff --git a/include/asm-x86_64/apicdef.h b/include/asm-x86_64/apicdef.h
index decaa2d540e8..5a48e9bcf218 100644
--- a/include/asm-x86_64/apicdef.h
+++ b/include/asm-x86_64/apicdef.h
@@ -39,6 +39,7 @@
39#define APIC_SPIV_FOCUS_DISABLED (1<<9) 39#define APIC_SPIV_FOCUS_DISABLED (1<<9)
40#define APIC_SPIV_APIC_ENABLED (1<<8) 40#define APIC_SPIV_APIC_ENABLED (1<<8)
41#define APIC_ISR 0x100 41#define APIC_ISR 0x100
42#define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */
42#define APIC_TMR 0x180 43#define APIC_TMR 0x180
43#define APIC_IRR 0x200 44#define APIC_IRR 0x200
44#define APIC_ESR 0x280 45#define APIC_ESR 0x280
diff --git a/include/asm-x86_64/dmi.h b/include/asm-x86_64/dmi.h
new file mode 100644
index 000000000000..93b2b15d4325
--- /dev/null
+++ b/include/asm-x86_64/dmi.h
@@ -0,0 +1,27 @@
1#ifndef _ASM_DMI_H
2#define _ASM_DMI_H 1
3
4#include <asm/io.h>
5
6extern void *dmi_ioremap(unsigned long addr, unsigned long size);
7extern void dmi_iounmap(void *addr, unsigned long size);
8
9#define DMI_MAX_DATA 2048
10
11extern int dmi_alloc_index;
12extern char dmi_alloc_data[DMI_MAX_DATA];
13
14/* This is so early that there is no good way to allocate dynamic memory.
15 Allocate data in an BSS array. */
16static inline void *dmi_alloc(unsigned len)
17{
18 int idx = dmi_alloc_index;
19 if ((dmi_alloc_index += len) > DMI_MAX_DATA)
20 return NULL;
21 return dmi_alloc_data + idx;
22}
23
24#define dmi_ioremap early_ioremap
25#define dmi_iounmap early_iounmap
26
27#endif
diff --git a/include/asm-x86_64/elf.h b/include/asm-x86_64/elf.h
index 43862cd6a569..c98633af07d2 100644
--- a/include/asm-x86_64/elf.h
+++ b/include/asm-x86_64/elf.h
@@ -8,6 +8,7 @@
8#include <asm/ptrace.h> 8#include <asm/ptrace.h>
9#include <asm/user.h> 9#include <asm/user.h>
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/compat.h>
11 12
12/* x86-64 relocation types */ 13/* x86-64 relocation types */
13#define R_X86_64_NONE 0 /* No reloc */ 14#define R_X86_64_NONE 0 /* No reloc */
@@ -157,6 +158,9 @@ extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
157#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) 158#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
158#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) 159#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
159 160
161/* 1GB for 64bit, 8MB for 32bit */
162#define STACK_RND_MASK (is_compat_task() ? 0x7ff : 0x3fffff)
163
160#endif 164#endif
161 165
162#endif 166#endif
diff --git a/include/asm-x86_64/floppy.h b/include/asm-x86_64/floppy.h
index af7ded63b517..52825ce689f2 100644
--- a/include/asm-x86_64/floppy.h
+++ b/include/asm-x86_64/floppy.h
@@ -155,7 +155,7 @@ static int fd_request_irq(void)
155 155
156static unsigned long dma_mem_alloc(unsigned long size) 156static unsigned long dma_mem_alloc(unsigned long size)
157{ 157{
158 return __get_dma_pages(GFP_KERNEL,get_order(size)); 158 return __get_dma_pages(GFP_KERNEL|__GFP_NORETRY,get_order(size));
159} 159}
160 160
161 161
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index 9dac18db8291..cafdfb37f0d8 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -135,6 +135,9 @@ static inline void __iomem * ioremap (unsigned long offset, unsigned long size)
135 return __ioremap(offset, size, 0); 135 return __ioremap(offset, size, 0);
136} 136}
137 137
138extern void *early_ioremap(unsigned long addr, unsigned long size);
139extern void early_iounmap(void *addr, unsigned long size);
140
138/* 141/*
139 * This one maps high address device memory and turns off caching for that area. 142 * This one maps high address device memory and turns off caching for that area.
140 * it's useful if some control registers are in such an area and write combining 143 * it's useful if some control registers are in such an area and write combining
@@ -143,11 +146,6 @@ static inline void __iomem * ioremap (unsigned long offset, unsigned long size)
143extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); 146extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
144extern void iounmap(volatile void __iomem *addr); 147extern void iounmap(volatile void __iomem *addr);
145 148
146/* Use normal IO mappings for DMI */
147#define dmi_ioremap ioremap
148#define dmi_iounmap(x,l) iounmap(x)
149#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
150
151/* 149/*
152 * ISA I/O bus memory addresses are 1:1 with the physical address. 150 * ISA I/O bus memory addresses are 1:1 with the physical address.
153 */ 151 */
@@ -202,23 +200,6 @@ static inline __u64 __readq(const volatile void __iomem *addr)
202 200
203#define mmiowb() 201#define mmiowb()
204 202
205#ifdef CONFIG_UNORDERED_IO
206static inline void __writel(__u32 val, volatile void __iomem *addr)
207{
208 volatile __u32 __iomem *target = addr;
209 asm volatile("movnti %1,%0"
210 : "=m" (*target)
211 : "r" (val) : "memory");
212}
213
214static inline void __writeq(__u64 val, volatile void __iomem *addr)
215{
216 volatile __u64 __iomem *target = addr;
217 asm volatile("movnti %1,%0"
218 : "=m" (*target)
219 : "r" (val) : "memory");
220}
221#else
222static inline void __writel(__u32 b, volatile void __iomem *addr) 203static inline void __writel(__u32 b, volatile void __iomem *addr)
223{ 204{
224 *(__force volatile __u32 *)addr = b; 205 *(__force volatile __u32 *)addr = b;
@@ -227,7 +208,6 @@ static inline void __writeq(__u64 b, volatile void __iomem *addr)
227{ 208{
228 *(__force volatile __u64 *)addr = b; 209 *(__force volatile __u64 *)addr = b;
229} 210}
230#endif
231static inline void __writeb(__u8 b, volatile void __iomem *addr) 211static inline void __writeb(__u8 b, volatile void __iomem *addr)
232{ 212{
233 *(__force volatile __u8 *)addr = b; 213 *(__force volatile __u8 *)addr = b;
@@ -269,23 +249,11 @@ void memset_io(volatile void __iomem *a, int b, size_t c);
269 */ 249 */
270#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) 250#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
271 251
272#define isa_readb(a) readb(__ISA_IO_base + (a))
273#define isa_readw(a) readw(__ISA_IO_base + (a))
274#define isa_readl(a) readl(__ISA_IO_base + (a))
275#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
276#define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
277#define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
278#define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
279#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
280#define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
281
282
283/* 252/*
284 * Again, x86-64 does not require mem IO specific function. 253 * Again, x86-64 does not require mem IO specific function.
285 */ 254 */
286 255
287#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d)) 256#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d))
288#define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(__ISA_IO_base + (b)),(c),(d))
289 257
290/** 258/**
291 * check_signature - find BIOS signatures 259 * check_signature - find BIOS signatures
diff --git a/include/asm-x86_64/local.h b/include/asm-x86_64/local.h
index 3e72c41727c5..bf148037d4e5 100644
--- a/include/asm-x86_64/local.h
+++ b/include/asm-x86_64/local.h
@@ -5,7 +5,7 @@
5 5
6typedef struct 6typedef struct
7{ 7{
8 volatile unsigned int counter; 8 volatile unsigned long counter;
9} local_t; 9} local_t;
10 10
11#define LOCAL_INIT(i) { (i) } 11#define LOCAL_INIT(i) { (i) }
@@ -16,7 +16,7 @@ typedef struct
16static __inline__ void local_inc(local_t *v) 16static __inline__ void local_inc(local_t *v)
17{ 17{
18 __asm__ __volatile__( 18 __asm__ __volatile__(
19 "incl %0" 19 "incq %0"
20 :"=m" (v->counter) 20 :"=m" (v->counter)
21 :"m" (v->counter)); 21 :"m" (v->counter));
22} 22}
@@ -24,7 +24,7 @@ static __inline__ void local_inc(local_t *v)
24static __inline__ void local_dec(local_t *v) 24static __inline__ void local_dec(local_t *v)
25{ 25{
26 __asm__ __volatile__( 26 __asm__ __volatile__(
27 "decl %0" 27 "decq %0"
28 :"=m" (v->counter) 28 :"=m" (v->counter)
29 :"m" (v->counter)); 29 :"m" (v->counter));
30} 30}
@@ -32,7 +32,7 @@ static __inline__ void local_dec(local_t *v)
32static __inline__ void local_add(unsigned int i, local_t *v) 32static __inline__ void local_add(unsigned int i, local_t *v)
33{ 33{
34 __asm__ __volatile__( 34 __asm__ __volatile__(
35 "addl %1,%0" 35 "addq %1,%0"
36 :"=m" (v->counter) 36 :"=m" (v->counter)
37 :"ir" (i), "m" (v->counter)); 37 :"ir" (i), "m" (v->counter));
38} 38}
@@ -40,7 +40,7 @@ static __inline__ void local_add(unsigned int i, local_t *v)
40static __inline__ void local_sub(unsigned int i, local_t *v) 40static __inline__ void local_sub(unsigned int i, local_t *v)
41{ 41{
42 __asm__ __volatile__( 42 __asm__ __volatile__(
43 "subl %1,%0" 43 "subq %1,%0"
44 :"=m" (v->counter) 44 :"=m" (v->counter)
45 :"ir" (i), "m" (v->counter)); 45 :"ir" (i), "m" (v->counter));
46} 46}
diff --git a/include/asm-x86_64/mmu_context.h b/include/asm-x86_64/mmu_context.h
index 16e4be4de0c5..19f0c83d0792 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,
34 unsigned cpu = smp_processor_id(); 34 unsigned cpu = smp_processor_id();
35 if (likely(prev != next)) { 35 if (likely(prev != next)) {
36 /* stop flush ipis for the previous mm */ 36 /* stop flush ipis for the previous mm */
37 clear_bit(cpu, &prev->cpu_vm_mask); 37 cpu_clear(cpu, prev->cpu_vm_mask);
38#ifdef CONFIG_SMP 38#ifdef CONFIG_SMP
39 write_pda(mmu_state, TLBSTATE_OK); 39 write_pda(mmu_state, TLBSTATE_OK);
40 write_pda(active_mm, next); 40 write_pda(active_mm, next);
41#endif 41#endif
42 set_bit(cpu, &next->cpu_vm_mask); 42 cpu_set(cpu, next->cpu_vm_mask);
43 load_cr3(next->pgd); 43 load_cr3(next->pgd);
44 44
45 if (unlikely(next->context.ldt != prev->context.ldt)) 45 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,
50 write_pda(mmu_state, TLBSTATE_OK); 50 write_pda(mmu_state, TLBSTATE_OK);
51 if (read_pda(active_mm) != next) 51 if (read_pda(active_mm) != next)
52 out_of_line_bug(); 52 out_of_line_bug();
53 if(!test_and_set_bit(cpu, &next->cpu_vm_mask)) { 53 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
54 /* We were in lazy tlb mode and leave_mm disabled 54 /* We were in lazy tlb mode and leave_mm disabled
55 * tlb flush IPI delivery. We must reload CR3 55 * tlb flush IPI delivery. We must reload CR3
56 * to make sure to use no freed page tables. 56 * to make sure to use no freed page tables.
diff --git a/include/asm-x86_64/mmzone.h b/include/asm-x86_64/mmzone.h
index 972c9359f7d7..937f99b26883 100644
--- a/include/asm-x86_64/mmzone.h
+++ b/include/asm-x86_64/mmzone.h
@@ -15,8 +15,13 @@
15#define NODEMAPSIZE 0xfff 15#define NODEMAPSIZE 0xfff
16 16
17/* Simple perfect hash to map physical addresses to node numbers */ 17/* Simple perfect hash to map physical addresses to node numbers */
18extern int memnode_shift; 18struct memnode {
19extern u8 memnodemap[NODEMAPSIZE]; 19 int shift;
20 u8 map[NODEMAPSIZE];
21} ____cacheline_aligned;
22extern struct memnode memnode;
23#define memnode_shift memnode.shift
24#define memnodemap memnode.map
20 25
21extern struct pglist_data *node_data[]; 26extern struct pglist_data *node_data[];
22 27
diff --git a/include/asm-x86_64/numa.h b/include/asm-x86_64/numa.h
index dffe276ca2df..f6cbb4cbb5a3 100644
--- a/include/asm-x86_64/numa.h
+++ b/include/asm-x86_64/numa.h
@@ -4,11 +4,11 @@
4#include <linux/nodemask.h> 4#include <linux/nodemask.h>
5#include <asm/numnodes.h> 5#include <asm/numnodes.h>
6 6
7struct node { 7struct bootnode {
8 u64 start,end; 8 u64 start,end;
9}; 9};
10 10
11extern int compute_hash_shift(struct node *nodes, int numnodes); 11extern int compute_hash_shift(struct bootnode *nodes, int numnodes);
12extern int pxm_to_node(int nid); 12extern int pxm_to_node(int nid);
13 13
14#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT)) 14#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
diff --git a/include/asm-x86_64/pda.h b/include/asm-x86_64/pda.h
index c7ab38a601af..b47c3df9ed1d 100644
--- a/include/asm-x86_64/pda.h
+++ b/include/asm-x86_64/pda.h
@@ -22,8 +22,8 @@ struct x8664_pda {
22 int nodenumber; /* number of current node */ 22 int nodenumber; /* number of current node */
23 unsigned int __softirq_pending; 23 unsigned int __softirq_pending;
24 unsigned int __nmi_count; /* number of NMI on this CPUs */ 24 unsigned int __nmi_count; /* number of NMI on this CPUs */
25 struct mm_struct *active_mm;
26 int mmu_state; 25 int mmu_state;
26 struct mm_struct *active_mm;
27 unsigned apic_timer_irqs; 27 unsigned apic_timer_irqs;
28} ____cacheline_aligned_in_smp; 28} ____cacheline_aligned_in_smp;
29 29
diff --git a/include/asm-x86_64/pgalloc.h b/include/asm-x86_64/pgalloc.h
index 08cad2482bcb..43d4c333a8b1 100644
--- a/include/asm-x86_64/pgalloc.h
+++ b/include/asm-x86_64/pgalloc.h
@@ -45,12 +45,39 @@ static inline void pud_free (pud_t *pud)
45 free_page((unsigned long)pud); 45 free_page((unsigned long)pud);
46} 46}
47 47
48static inline void pgd_list_add(pgd_t *pgd)
49{
50 struct page *page = virt_to_page(pgd);
51
52 spin_lock(&pgd_lock);
53 page->index = (pgoff_t)pgd_list;
54 if (pgd_list)
55 pgd_list->private = (unsigned long)&page->index;
56 pgd_list = page;
57 page->private = (unsigned long)&pgd_list;
58 spin_unlock(&pgd_lock);
59}
60
61static inline void pgd_list_del(pgd_t *pgd)
62{
63 struct page *next, **pprev, *page = virt_to_page(pgd);
64
65 spin_lock(&pgd_lock);
66 next = (struct page *)page->index;
67 pprev = (struct page **)page->private;
68 *pprev = next;
69 if (next)
70 next->private = (unsigned long)pprev;
71 spin_unlock(&pgd_lock);
72}
73
48static inline pgd_t *pgd_alloc(struct mm_struct *mm) 74static inline pgd_t *pgd_alloc(struct mm_struct *mm)
49{ 75{
50 unsigned boundary; 76 unsigned boundary;
51 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); 77 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
52 if (!pgd) 78 if (!pgd)
53 return NULL; 79 return NULL;
80 pgd_list_add(pgd);
54 /* 81 /*
55 * Copy kernel pointers in from init. 82 * Copy kernel pointers in from init.
56 * Could keep a freelist or slab cache of those because the kernel 83 * Could keep a freelist or slab cache of those because the kernel
@@ -67,6 +94,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
67static inline void pgd_free(pgd_t *pgd) 94static inline void pgd_free(pgd_t *pgd)
68{ 95{
69 BUG_ON((unsigned long)pgd & (PAGE_SIZE-1)); 96 BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
97 pgd_list_del(pgd);
70 free_page((unsigned long)pgd); 98 free_page((unsigned long)pgd);
71} 99}
72 100
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index a617d364d08d..31e83c3bd022 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
293{ 293{
294 if (!pte_dirty(*ptep)) 294 if (!pte_dirty(*ptep))
295 return 0; 295 return 0;
296 return test_and_clear_bit(_PAGE_BIT_DIRTY, ptep); 296 return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte);
297} 297}
298 298
299static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) 299static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
300{ 300{
301 if (!pte_young(*ptep)) 301 if (!pte_young(*ptep))
302 return 0; 302 return 0;
303 return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep); 303 return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte);
304} 304}
305 305
306static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 306static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
307{ 307{
308 clear_bit(_PAGE_BIT_RW, ptep); 308 clear_bit(_PAGE_BIT_RW, &ptep->pte);
309} 309}
310 310
311/* 311/*
@@ -420,6 +420,10 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
420#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 420#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
421#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 421#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
422 422
423extern spinlock_t pgd_lock;
424extern struct page *pgd_list;
425void vmalloc_sync_all(void);
426
423#endif /* !__ASSEMBLY__ */ 427#endif /* !__ASSEMBLY__ */
424 428
425extern int kern_addr_valid(unsigned long addr); 429extern int kern_addr_valid(unsigned long addr);
diff --git a/include/asm-x86_64/poll.h b/include/asm-x86_64/poll.h
index c43cbba31913..c0475a9d8bb8 100644
--- a/include/asm-x86_64/poll.h
+++ b/include/asm-x86_64/poll.h
@@ -16,6 +16,7 @@
16#define POLLWRBAND 0x0200 16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400 17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000 18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
19 20
20struct pollfd { 21struct pollfd {
21 int fd; 22 int fd;
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index 3ba8fd45fcb3..8abf2a43c944 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -53,8 +53,6 @@ extern int sysctl_vsyscall;
53extern int nohpet; 53extern int nohpet;
54extern unsigned long vxtime_hz; 54extern unsigned long vxtime_hz;
55 55
56extern void do_softirq_thunk(void);
57
58extern int numa_setup(char *opt); 56extern int numa_setup(char *opt);
59 57
60extern int setup_early_printk(char *); 58extern int setup_early_printk(char *);
@@ -129,7 +127,6 @@ extern int fix_aperture;
129#define iommu_aperture 0 127#define iommu_aperture 0
130#define iommu_aperture_allowed 0 128#define iommu_aperture_allowed 0
131#endif 129#endif
132extern int force_iommu;
133 130
134extern int reboot_force; 131extern int reboot_force;
135extern int notsc_setup(char *); 132extern int notsc_setup(char *);
diff --git a/include/asm-x86_64/string.h b/include/asm-x86_64/string.h
index a3493ee282bb..ee6bf275349e 100644
--- a/include/asm-x86_64/string.h
+++ b/include/asm-x86_64/string.h
@@ -40,26 +40,15 @@ extern void *__memcpy(void *to, const void *from, size_t len);
40 40
41 41
42#define __HAVE_ARCH_MEMSET 42#define __HAVE_ARCH_MEMSET
43#define memset __builtin_memset 43void *memset(void *s, int c, size_t n);
44 44
45#define __HAVE_ARCH_MEMMOVE 45#define __HAVE_ARCH_MEMMOVE
46void * memmove(void * dest,const void *src,size_t count); 46void * memmove(void * dest,const void *src,size_t count);
47 47
48/* Use C out of line version for memcmp */
49#define memcmp __builtin_memcmp
50int memcmp(const void * cs,const void * ct,size_t count); 48int memcmp(const void * cs,const void * ct,size_t count);
51
52/* out of line string functions use always C versions */
53#define strlen __builtin_strlen
54size_t strlen(const char * s); 49size_t strlen(const char * s);
55 50char *strcpy(char * dest,const char *src);
56#define strcpy __builtin_strcpy 51char *strcat(char * dest, const char * src);
57char * strcpy(char * dest,const char *src);
58
59#define strcat __builtin_strcat
60char * strcat(char * dest, const char * src);
61
62#define strcmp __builtin_strcmp
63int strcmp(const char * cs,const char * ct); 52int strcmp(const char * cs,const char * ct);
64 53
65#endif /* __KERNEL__ */ 54#endif /* __KERNEL__ */
diff --git a/include/asm-x86_64/suspend.h b/include/asm-x86_64/suspend.h
index bb9f40597d09..bc7f81715e5e 100644
--- a/include/asm-x86_64/suspend.h
+++ b/include/asm-x86_64/suspend.h
@@ -39,9 +39,7 @@ extern unsigned long saved_context_r12, saved_context_r13, saved_context_r14, sa
39extern unsigned long saved_context_eflags; 39extern unsigned long saved_context_eflags;
40 40
41#define loaddebug(thread,register) \ 41#define loaddebug(thread,register) \
42 __asm__("movq %0,%%db" #register \ 42 set_debugreg((thread)->debugreg##register, register)
43 : /* no output */ \
44 :"r" ((thread)->debugreg##register))
45 43
46extern void fix_processor_context(void); 44extern void fix_processor_context(void);
47 45
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index b7f66034ae7a..397598980228 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -70,12 +70,6 @@ extern void load_gs_index(unsigned);
70 ".previous" \ 70 ".previous" \
71 : :"r" (value), "r" (0)) 71 : :"r" (value), "r" (0))
72 72
73#define set_debug(value,register) \
74 __asm__("movq %0,%%db" #register \
75 : /* no output */ \
76 :"r" ((unsigned long) value))
77
78
79#ifdef __KERNEL__ 73#ifdef __KERNEL__
80struct alt_instr { 74struct alt_instr {
81 __u8 *instr; /* original instruction */ 75 __u8 *instr; /* original instruction */
diff --git a/include/asm-xtensa/poll.h b/include/asm-xtensa/poll.h
index dffe447534e0..6fd94773e866 100644
--- a/include/asm-xtensa/poll.h
+++ b/include/asm-xtensa/poll.h
@@ -27,6 +27,7 @@
27 27
28#define POLLMSG 0x0400 28#define POLLMSG 0x0400
29#define POLLREMOVE 0x0800 29#define POLLREMOVE 0x0800
30#define POLLRDHUP 0x2000
30 31
31struct pollfd { 32struct pollfd {
32 int fd; 33 int fd;
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 7d8ff97b3e92..d9ed27969855 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -46,6 +46,9 @@
46 * bitmap_parse(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 46 * bitmap_parse(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
47 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf 47 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
48 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list 48 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list
49 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
50 * bitmap_release_region(bitmap, pos, order) Free specified bit region
51 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
49 */ 52 */
50 53
51/* 54/*
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 208650b1ad3a..f17525a963d1 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -175,4 +175,11 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
175 return (word >> shift) | (word << (32 - shift)); 175 return (word >> shift) | (word << (32 - shift));
176} 176}
177 177
178static inline unsigned fls_long(unsigned long l)
179{
180 if (sizeof(l) == 4)
181 return fls(l);
182 return fls64(l);
183}
184
178#endif 185#endif
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 993da8cc9706..7155452fb4a8 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -51,6 +51,9 @@ extern void * __init __alloc_bootmem_low_node(pg_data_t *pgdat,
51 unsigned long size, 51 unsigned long size,
52 unsigned long align, 52 unsigned long align,
53 unsigned long goal); 53 unsigned long goal);
54extern void * __init __alloc_bootmem_core(struct bootmem_data *bdata,
55 unsigned long size, unsigned long align, unsigned long goal,
56 unsigned long limit);
54#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE 57#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
55extern void __init reserve_bootmem (unsigned long addr, unsigned long size); 58extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
56#define alloc_bootmem(x) \ 59#define alloc_bootmem(x) \
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 5a23ce752629..6548b35ab9f6 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)
357 357
358#define cap_is_fs_cap(c) (CAP_TO_MASK(c) & CAP_FS_MASK) 358#define cap_is_fs_cap(c) (CAP_TO_MASK(c) & CAP_FS_MASK)
359 359
360extern int capable(int cap); 360int capable(int cap);
361int __capable(struct task_struct *t, int cap);
361 362
362#endif /* __KERNEL__ */ 363#endif /* __KERNEL__ */
363 364
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index d612b89dce33..08d50c53aab4 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -74,7 +74,6 @@ extern int lock_cpu_hotplug_interruptible(void);
74 register_cpu_notifier(&fn##_nb); \ 74 register_cpu_notifier(&fn##_nb); \
75} 75}
76int cpu_down(unsigned int cpu); 76int cpu_down(unsigned int cpu);
77extern int __attribute__((weak)) smp_prepare_cpu(int cpu);
78#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 77#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
79#else 78#else
80#define lock_cpu_hotplug() do { } while (0) 79#define lock_cpu_hotplug() do { } while (0)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 60e56c6e03dd..99e6115d8e52 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -212,17 +212,15 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
212 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); 212 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
213} 213}
214 214
215#define first_cpu(src) __first_cpu(&(src), NR_CPUS) 215#ifdef CONFIG_SMP
216static inline int __first_cpu(const cpumask_t *srcp, int nbits) 216int __first_cpu(const cpumask_t *srcp);
217{ 217#define first_cpu(src) __first_cpu(&(src))
218 return min_t(int, nbits, find_first_bit(srcp->bits, nbits)); 218int __next_cpu(int n, const cpumask_t *srcp);
219} 219#define next_cpu(n, src) __next_cpu((n), &(src))
220 220#else
221#define next_cpu(n, src) __next_cpu((n), &(src), NR_CPUS) 221#define first_cpu(src) 0
222static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits) 222#define next_cpu(n, src) 1
223{ 223#endif
224 return min_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
225}
226 224
227#define cpumask_of_cpu(cpu) \ 225#define cpumask_of_cpu(cpu) \
228({ \ 226({ \
@@ -398,27 +396,17 @@ extern cpumask_t cpu_present_map;
398#define cpu_present(cpu) ((cpu) == 0) 396#define cpu_present(cpu) ((cpu) == 0)
399#endif 397#endif
400 398
401#define any_online_cpu(mask) \ 399#ifdef CONFIG_SMP
402({ \ 400int highest_possible_processor_id(void);
403 int cpu; \ 401#define any_online_cpu(mask) __any_online_cpu(&(mask))
404 for_each_cpu_mask(cpu, (mask)) \ 402int __any_online_cpu(const cpumask_t *mask);
405 if (cpu_online(cpu)) \ 403#else
406 break; \ 404#define highest_possible_processor_id() 0
407 cpu; \ 405#define any_online_cpu(mask) 0
408}) 406#endif
409 407
410#define for_each_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map) 408#define for_each_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
411#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map) 409#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
412#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map) 410#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
413 411
414/* Find the highest possible smp_processor_id() */
415#define highest_possible_processor_id() \
416({ \
417 unsigned int cpu, highest = 0; \
418 for_each_cpu_mask(cpu, cpu_possible_map) \
419 highest = cpu; \
420 highest; \
421})
422
423
424#endif /* __LINUX_CPUMASK_H */ 412#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 3bc606927116..9354722a9217 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -4,7 +4,7 @@
4 * cpuset interface 4 * cpuset interface
5 * 5 *
6 * Copyright (C) 2003 BULL SA 6 * Copyright (C) 2003 BULL SA
7 * Copyright (C) 2004 Silicon Graphics, Inc. 7 * Copyright (C) 2004-2006 Silicon Graphics, Inc.
8 * 8 *
9 */ 9 */
10 10
@@ -51,6 +51,18 @@ extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
51extern void cpuset_lock(void); 51extern void cpuset_lock(void);
52extern void cpuset_unlock(void); 52extern void cpuset_unlock(void);
53 53
54extern int cpuset_mem_spread_node(void);
55
56static inline int cpuset_do_page_mem_spread(void)
57{
58 return current->flags & PF_SPREAD_PAGE;
59}
60
61static inline int cpuset_do_slab_mem_spread(void)
62{
63 return current->flags & PF_SPREAD_SLAB;
64}
65
54#else /* !CONFIG_CPUSETS */ 66#else /* !CONFIG_CPUSETS */
55 67
56static inline int cpuset_init_early(void) { return 0; } 68static inline int cpuset_init_early(void) { return 0; }
@@ -99,6 +111,21 @@ static inline char *cpuset_task_status_allowed(struct task_struct *task,
99static inline void cpuset_lock(void) {} 111static inline void cpuset_lock(void) {}
100static inline void cpuset_unlock(void) {} 112static inline void cpuset_unlock(void) {}
101 113
114static inline int cpuset_mem_spread_node(void)
115{
116 return 0;
117}
118
119static inline int cpuset_do_page_mem_spread(void)
120{
121 return 0;
122}
123
124static inline int cpuset_do_slab_mem_spread(void)
125{
126 return 0;
127}
128
102#endif /* !CONFIG_CPUSETS */ 129#endif /* !CONFIG_CPUSETS */
103 130
104#endif /* _LINUX_CPUSET_H */ 131#endif /* _LINUX_CPUSET_H */
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 4361f3789975..d10bd30c337e 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -162,6 +162,8 @@ d_iput: no no no yes
162#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */ 162#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
163#define DCACHE_UNHASHED 0x0010 163#define DCACHE_UNHASHED 0x0010
164 164
165#define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched */
166
165extern spinlock_t dcache_lock; 167extern spinlock_t dcache_lock;
166 168
167/** 169/**
diff --git a/include/linux/dio.h b/include/linux/dio.h
index fae9395fcf4f..1e65ebc2a3db 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)
276 dev_set_drvdata(&d->dev, data); 276 dev_set_drvdata(&d->dev, data);
277} 277}
278 278
279/*
280 * A helper function which helps ensure correct dio_driver
281 * setup and cleanup for commonly-encountered hotplug/modular cases
282 *
283 * This MUST stay in a header, as it checks for -DMODULE
284 */
285static inline int dio_module_init(struct dio_driver *drv)
286{
287 int rc = dio_register_driver(drv);
288
289 if (rc > 0)
290 return 0;
291
292 /* iff CONFIG_HOTPLUG and built into kernel, we should
293 * leave the driver around for future hotplug events.
294 * For the module case, a hotplug daemon of some sort
295 * should load a module in response to an insert event. */
296#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
297 if (rc == 0)
298 return 0;
299#else
300 if (rc == 0)
301 rc = -ENODEV;
302#endif
303
304 /* if we get here, we need to clean up DIO driver instance
305 * and return some sort of error */
306 dio_unregister_driver(drv);
307
308 return rc;
309}
310
311#endif /* __KERNEL__ */ 279#endif /* __KERNEL__ */
312#endif /* ndef _LINUX_DIO_H */ 280#endif /* ndef _LINUX_DIO_H */
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 2e6bbe014157..64fd6c366604 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -68,6 +68,7 @@ extern char * dmi_get_system_info(int field);
68extern struct dmi_device * dmi_find_device(int type, const char *name, 68extern struct dmi_device * dmi_find_device(int type, const char *name,
69 struct dmi_device *from); 69 struct dmi_device *from);
70extern void dmi_scan_machine(void); 70extern void dmi_scan_machine(void);
71extern int dmi_get_year(int field);
71 72
72#else 73#else
73 74
@@ -75,6 +76,7 @@ static inline int dmi_check_system(struct dmi_system_id *list) { return 0; }
75static inline char * dmi_get_system_info(int field) { return NULL; } 76static inline char * dmi_get_system_info(int field) { return NULL; }
76static inline struct dmi_device * dmi_find_device(int type, const char *name, 77static inline struct dmi_device * dmi_find_device(int type, const char *name,
77 struct dmi_device *from) { return NULL; } 78 struct dmi_device *from) { return NULL; }
79static inline int dmi_get_year(int year) { return 0; }
78 80
79#endif 81#endif
80 82
diff --git a/include/linux/fadvise.h b/include/linux/fadvise.h
index e8e747139b9a..b2913bba35d8 100644
--- a/include/linux/fadvise.h
+++ b/include/linux/fadvise.h
@@ -18,4 +18,10 @@
18#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ 18#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
19#endif 19#endif
20 20
21/*
22 * Linux-specific fadvise() extensions:
23 */
24#define LINUX_FADV_ASYNC_WRITE 32 /* Start writeout on range */
25#define LINUX_FADV_WRITE_WAIT 33 /* Wait upon writeout to range */
26
21#endif /* FADVISE_H_INCLUDED */ 27#endif /* FADVISE_H_INCLUDED */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 404d391f3d35..5adf32b90f36 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -65,6 +65,11 @@ extern int dir_notify_enable;
65#define FMODE_PREAD 8 65#define FMODE_PREAD 8
66#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 66#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
67 67
68/* File is being opened for execution. Primary users of this flag are
69 distributed filesystems that can use it to achieve correct ETXTBUSY
70 behavior for cross-node execution/opening_for_writing of files */
71#define FMODE_EXEC 16
72
68#define RW_MASK 1 73#define RW_MASK 1
69#define RWA_MASK 2 74#define RWA_MASK 2
70#define READ 0 75#define READ 0
@@ -103,7 +108,9 @@ extern int dir_notify_enable;
103#define MS_BIND 4096 108#define MS_BIND 4096
104#define MS_MOVE 8192 109#define MS_MOVE 8192
105#define MS_REC 16384 110#define MS_REC 16384
106#define MS_VERBOSE 32768 111#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
112 MS_VERBOSE is deprecated. */
113#define MS_SILENT 32768
107#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ 114#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
108#define MS_UNBINDABLE (1<<17) /* change to unbindable */ 115#define MS_UNBINDABLE (1<<17) /* change to unbindable */
109#define MS_PRIVATE (1<<18) /* change to private */ 116#define MS_PRIVATE (1<<18) /* change to private */
@@ -348,7 +355,7 @@ struct address_space_operations {
348 /* Write back some dirty pages from this mapping. */ 355 /* Write back some dirty pages from this mapping. */
349 int (*writepages)(struct address_space *, struct writeback_control *); 356 int (*writepages)(struct address_space *, struct writeback_control *);
350 357
351 /* Set a page dirty */ 358 /* Set a page dirty. Return true if this dirtied it */
352 int (*set_page_dirty)(struct page *page); 359 int (*set_page_dirty)(struct page *page);
353 360
354 int (*readpages)(struct file *filp, struct address_space *mapping, 361 int (*readpages)(struct file *filp, struct address_space *mapping,
@@ -1468,6 +1475,12 @@ extern int filemap_fdatawait(struct address_space *);
1468extern int filemap_write_and_wait(struct address_space *mapping); 1475extern int filemap_write_and_wait(struct address_space *mapping);
1469extern int filemap_write_and_wait_range(struct address_space *mapping, 1476extern int filemap_write_and_wait_range(struct address_space *mapping,
1470 loff_t lstart, loff_t lend); 1477 loff_t lstart, loff_t lend);
1478extern int wait_on_page_writeback_range(struct address_space *mapping,
1479 pgoff_t start, pgoff_t end);
1480extern int __filemap_fdatawrite_range(struct address_space *mapping,
1481 loff_t start, loff_t end, int sync_mode);
1482
1483extern long do_fsync(struct file *file, int datasync);
1471extern void sync_supers(void); 1484extern void sync_supers(void);
1472extern void sync_filesystems(int wait); 1485extern void sync_filesystems(int wait);
1473extern void emergency_sync(void); 1486extern void emergency_sync(void);
@@ -1547,7 +1560,6 @@ extern void destroy_inode(struct inode *);
1547extern struct inode *new_inode(struct super_block *); 1560extern struct inode *new_inode(struct super_block *);
1548extern int remove_suid(struct dentry *); 1561extern int remove_suid(struct dentry *);
1549extern void remove_dquot_ref(struct super_block *, int, struct list_head *); 1562extern void remove_dquot_ref(struct super_block *, int, struct list_head *);
1550extern struct mutex iprune_mutex;
1551 1563
1552extern void __insert_inode_hash(struct inode *, unsigned long hashval); 1564extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1553extern void remove_inode_hash(struct inode *); 1565extern void remove_inode_hash(struct inode *);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 03b8e7932b83..f7e517c1f1bd 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -17,6 +17,25 @@
17#include <linux/inotify.h> 17#include <linux/inotify.h>
18 18
19/* 19/*
20 * fsnotify_d_instantiate - instantiate a dentry for inode
21 * Called with dcache_lock held.
22 */
23static inline void fsnotify_d_instantiate(struct dentry *entry,
24 struct inode *inode)
25{
26 inotify_d_instantiate(entry, inode);
27}
28
29/*
30 * fsnotify_d_move - entry has been moved
31 * Called with dcache_lock and entry->d_lock held.
32 */
33static inline void fsnotify_d_move(struct dentry *entry)
34{
35 inotify_d_move(entry);
36}
37
38/*
20 * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir 39 * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
21 */ 40 */
22static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, 41static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index ec311bc89439..679b46a6a565 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -184,6 +184,7 @@
184#define I2C_HW_B_SAVAGE 0x01001d /* savage framebuffer driver */ 184#define I2C_HW_B_SAVAGE 0x01001d /* savage framebuffer driver */
185#define I2C_HW_B_RADEON 0x01001e /* radeon framebuffer driver */ 185#define I2C_HW_B_RADEON 0x01001e /* radeon framebuffer driver */
186#define I2C_HW_B_EM28XX 0x01001f /* em28xx video capture cards */ 186#define I2C_HW_B_EM28XX 0x01001f /* em28xx video capture cards */
187#define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */
187 188
188/* --- PCF 8584 based algorithms */ 189/* --- PCF 8584 based algorithms */
189#define I2C_HW_P_LP 0x020000 /* Parallel port interface */ 190#define I2C_HW_P_LP 0x020000 /* Parallel port interface */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index a7fc4cc79b23..8d2db412ba9c 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -792,6 +792,7 @@ typedef struct hwif_s {
792 unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */ 792 unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
793 unsigned auto_poll : 1; /* supports nop auto-poll */ 793 unsigned auto_poll : 1; /* supports nop auto-poll */
794 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 794 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
795 unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */
795 796
796 struct device gendev; 797 struct device gendev;
797 struct completion gendev_rel_comp; /* To deal with device release() */ 798 struct completion gendev_rel_comp; /* To deal with device release() */
diff --git a/include/linux/init.h b/include/linux/init.h
index ff8d8b8632f4..ed0ac7c39fdc 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -69,6 +69,10 @@ extern initcall_t __security_initcall_start[], __security_initcall_end[];
69 69
70/* Defined in init/main.c */ 70/* Defined in init/main.c */
71extern char saved_command_line[]; 71extern char saved_command_line[];
72
73/* used by init/main.c */
74extern void setup_arch(char **);
75
72#endif 76#endif
73 77
74#ifndef MODULE 78#ifndef MODULE
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 267c88b5f742..09e00433c78e 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -71,6 +71,8 @@ struct inotify_event {
71 71
72#ifdef CONFIG_INOTIFY 72#ifdef CONFIG_INOTIFY
73 73
74extern void inotify_d_instantiate(struct dentry *, struct inode *);
75extern void inotify_d_move(struct dentry *);
74extern void inotify_inode_queue_event(struct inode *, __u32, __u32, 76extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
75 const char *); 77 const char *);
76extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32, 78extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
@@ -81,6 +83,15 @@ extern u32 inotify_get_cookie(void);
81 83
82#else 84#else
83 85
86static inline void inotify_d_instantiate(struct dentry *dentry,
87 struct inode *inode)
88{
89}
90
91static inline void inotify_d_move(struct dentry *dentry)
92{
93}
94
84static inline void inotify_inode_queue_event(struct inode *inode, 95static inline void inotify_inode_queue_event(struct inode *inode,
85 __u32 mask, __u32 cookie, 96 __u32 mask, __u32 cookie,
86 const char *filename) 97 const char *filename)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6c5d4c898ccb..ee2a82a572f7 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)
114#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) 114#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
115extern cpumask_t pending_irq_cpumask[NR_IRQS]; 115extern cpumask_t pending_irq_cpumask[NR_IRQS];
116 116
117static inline void set_pending_irq(unsigned int irq, cpumask_t mask) 117void set_pending_irq(unsigned int irq, cpumask_t mask);
118{ 118void move_native_irq(int irq);
119 irq_desc_t *desc = irq_desc + irq;
120 unsigned long flags;
121
122 spin_lock_irqsave(&desc->lock, flags);
123 desc->move_irq = 1;
124 pending_irq_cpumask[irq] = mask;
125 spin_unlock_irqrestore(&desc->lock, flags);
126}
127
128static inline void
129move_native_irq(int irq)
130{
131 cpumask_t tmp;
132 irq_desc_t *desc = irq_descp(irq);
133
134 if (likely (!desc->move_irq))
135 return;
136
137 desc->move_irq = 0;
138
139 if (likely(cpus_empty(pending_irq_cpumask[irq])))
140 return;
141
142 if (!desc->handler->set_affinity)
143 return;
144
145 /* note - we hold the desc->lock */
146 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
147
148 /*
149 * If there was a valid mask to work with, please
150 * do the disable, re-program, enable sequence.
151 * This is *not* particularly important for level triggered
152 * but in a edge trigger case, we might be setting rte
153 * when an active trigger is comming in. This could
154 * cause some ioapics to mal-function.
155 * Being paranoid i guess!
156 */
157 if (unlikely(!cpus_empty(tmp))) {
158 desc->handler->disable(irq);
159 desc->handler->set_affinity(irq,tmp);
160 desc->handler->enable(irq);
161 }
162 cpus_clear(pending_irq_cpumask[irq]);
163}
164 119
165#ifdef CONFIG_PCI_MSI 120#ifdef CONFIG_PCI_MSI
166/* 121/*
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 2ccbfb6340ba..4fc7dffd66ef 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -29,6 +29,8 @@
29#include <linux/stddef.h> 29#include <linux/stddef.h>
30#include <linux/bit_spinlock.h> 30#include <linux/bit_spinlock.h>
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/timer.h>
33
32#include <asm/semaphore.h> 34#include <asm/semaphore.h>
33#endif 35#endif
34 36
@@ -787,7 +789,7 @@ struct journal_s
787 unsigned long j_commit_interval; 789 unsigned long j_commit_interval;
788 790
789 /* The timer used to wakeup the commit thread: */ 791 /* The timer used to wakeup the commit thread: */
790 struct timer_list *j_commit_timer; 792 struct timer_list j_commit_timer;
791 793
792 /* 794 /*
793 * The revoke table: maintains the list of revoked blocks in the 795 * The revoke table: maintains the list of revoked blocks in the
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index bb6e7ddee2fd..03d6cfaa5b8a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -154,9 +154,10 @@ static inline int __attribute_pure__ long_log2(unsigned long x)
154 return r; 154 return r;
155} 155}
156 156
157static inline unsigned long __attribute_const__ roundup_pow_of_two(unsigned long x) 157static inline unsigned long
158__attribute_const__ roundup_pow_of_two(unsigned long x)
158{ 159{
159 return (1UL << fls(x - 1)); 160 return 1UL << fls_long(x - 1);
160} 161}
161 162
162extern int printk_ratelimit(void); 163extern int printk_ratelimit(void);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 7a54244d30aa..047192253c3a 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -358,6 +358,11 @@ struct ata_device {
358 unsigned int max_sectors; /* per-device max sectors */ 358 unsigned int max_sectors; /* per-device max sectors */
359 unsigned int cdb_len; 359 unsigned int cdb_len;
360 360
361 /* per-dev xfer mask */
362 unsigned int pio_mask;
363 unsigned int mwdma_mask;
364 unsigned int udma_mask;
365
361 /* for CHS addressing */ 366 /* for CHS addressing */
362 u16 cylinders; /* Number of cylinders */ 367 u16 cylinders; /* Number of cylinders */
363 u16 heads; /* Number of heads */ 368 u16 heads; /* Number of heads */
@@ -395,6 +400,7 @@ struct ata_port {
395 400
396 struct ata_host_stats stats; 401 struct ata_host_stats stats;
397 struct ata_host_set *host_set; 402 struct ata_host_set *host_set;
403 struct device *dev;
398 404
399 struct work_struct port_task; 405 struct work_struct port_task;
400 406
@@ -515,9 +521,9 @@ extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
515extern int ata_scsi_release(struct Scsi_Host *host); 521extern int ata_scsi_release(struct Scsi_Host *host);
516extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); 522extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
517extern int ata_scsi_device_resume(struct scsi_device *); 523extern int ata_scsi_device_resume(struct scsi_device *);
518extern int ata_scsi_device_suspend(struct scsi_device *); 524extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state);
519extern int ata_device_resume(struct ata_port *, struct ata_device *); 525extern int ata_device_resume(struct ata_port *, struct ata_device *);
520extern int ata_device_suspend(struct ata_port *, struct ata_device *); 526extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state);
521extern int ata_ratelimit(void); 527extern int ata_ratelimit(void);
522extern unsigned int ata_busy_sleep(struct ata_port *ap, 528extern unsigned int ata_busy_sleep(struct ata_port *ap,
523 unsigned long timeout_pat, 529 unsigned long timeout_pat,
@@ -568,6 +574,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev,
568 struct block_device *bdev, 574 struct block_device *bdev,
569 sector_t capacity, int geom[]); 575 sector_t capacity, int geom[]);
570extern int ata_scsi_slave_config(struct scsi_device *sdev); 576extern int ata_scsi_slave_config(struct scsi_device *sdev);
577extern struct ata_device *ata_dev_pair(struct ata_port *ap,
578 struct ata_device *adev);
571 579
572/* 580/*
573 * Timing helpers 581 * Timing helpers
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 147eb01e0d4b..c08c9983e840 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -28,17 +28,27 @@
28#define ALIGN __ALIGN 28#define ALIGN __ALIGN
29#define ALIGN_STR __ALIGN_STR 29#define ALIGN_STR __ALIGN_STR
30 30
31#ifndef ENTRY
31#define ENTRY(name) \ 32#define ENTRY(name) \
32 .globl name; \ 33 .globl name; \
33 ALIGN; \ 34 ALIGN; \
34 name: 35 name:
36#endif
35 37
36#define KPROBE_ENTRY(name) \ 38#define KPROBE_ENTRY(name) \
37 .section .kprobes.text, "ax"; \ 39 .section .kprobes.text, "ax"; \
38 .globl name; \ 40 ENTRY(name)
39 ALIGN; \
40 name:
41 41
42#ifndef END
43#define END(name) \
44 .size name, .-name
45#endif
46
47#ifndef ENDPROC
48#define ENDPROC(name) \
49 .type name, @function; \
50 END(name)
51#endif
42 52
43#endif 53#endif
44 54
diff --git a/include/linux/major.h b/include/linux/major.h
index e36a46702d94..0a74c52924c9 100644
--- a/include/linux/major.h
+++ b/include/linux/major.h
@@ -113,6 +113,7 @@
113 113
114#define UBD_MAJOR 98 114#define UBD_MAJOR 98
115 115
116#define PP_MAJOR 99
116#define JSFD_MAJOR 99 117#define JSFD_MAJOR 99
117 118
118#define PHONE_MAJOR 100 119#define PHONE_MAJOR 100
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index bbd2221923c3..6a7621b2b12b 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);
147extern void mpol_rebind_task(struct task_struct *tsk, 147extern void mpol_rebind_task(struct task_struct *tsk,
148 const nodemask_t *new); 148 const nodemask_t *new);
149extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new); 149extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new);
150extern void mpol_fix_fork_child_flag(struct task_struct *p);
150#define set_cpuset_being_rebound(x) (cpuset_being_rebound = (x)) 151#define set_cpuset_being_rebound(x) (cpuset_being_rebound = (x))
151 152
152#ifdef CONFIG_CPUSET 153#ifdef CONFIG_CPUSET
@@ -248,6 +249,10 @@ static inline void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
248{ 249{
249} 250}
250 251
252static inline void mpol_fix_fork_child_flag(struct task_struct *p)
253{
254}
255
251#define set_cpuset_being_rebound(x) do {} while (0) 256#define set_cpuset_being_rebound(x) do {} while (0)
252 257
253static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma, 258static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma,
diff --git a/include/linux/module.h b/include/linux/module.h
index 70bd843c71cb..eaec13ddd667 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -183,6 +183,7 @@ void *__symbol_get_gpl(const char *symbol);
183 183
184/* For every exported symbol, place a struct in the __ksymtab section */ 184/* For every exported symbol, place a struct in the __ksymtab section */
185#define __EXPORT_SYMBOL(sym, sec) \ 185#define __EXPORT_SYMBOL(sym, sec) \
186 extern typeof(sym) sym; \
186 __CRC_SYMBOL(sym, sec) \ 187 __CRC_SYMBOL(sym, sec) \
187 static const char __kstrtab_##sym[] \ 188 static const char __kstrtab_##sym[] \
188 __attribute__((section("__ksymtab_strings"))) \ 189 __attribute__((section("__ksymtab_strings"))) \
@@ -554,25 +555,6 @@ static inline void module_remove_driver(struct device_driver *driver)
554 555
555/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ 556/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
556 557
557struct obsolete_modparm {
558 char name[64];
559 char type[64-sizeof(void *)];
560 void *addr;
561};
562
563static inline void MODULE_PARM_(void) { }
564#ifdef MODULE
565/* DEPRECATED: Do not use. */
566#define MODULE_PARM(var,type) \
567extern struct obsolete_modparm __parm_##var \
568__attribute__((section("__obsparm"))); \
569struct obsolete_modparm __parm_##var = \
570{ __stringify(var), type, &MODULE_PARM_ }; \
571__MODULE_PARM_TYPE(var, type);
572#else
573#define MODULE_PARM(var,type) static void __attribute__((__unused__)) *__parm_##var = &MODULE_PARM_;
574#endif
575
576#define __MODULE_STRING(x) __stringify(x) 558#define __MODULE_STRING(x) __stringify(x)
577 559
578/* Use symbol_get and symbol_put instead. You'll thank me. */ 560/* Use symbol_get and symbol_put instead. You'll thank me. */
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index b5c98c43779e..7c0c2c198f1f 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);
162extern int param_set_copystring(const char *val, struct kernel_param *kp); 162extern int param_set_copystring(const char *val, struct kernel_param *kp);
163extern int param_get_string(char *buffer, struct kernel_param *kp); 163extern int param_get_string(char *buffer, struct kernel_param *kp);
164 164
165int param_array(const char *name,
166 const char *val,
167 unsigned int min, unsigned int max,
168 void *elem, int elemsize,
169 int (*set)(const char *, struct kernel_param *kp),
170 int *num);
171
172/* for exporting parameters in /sys/parameters */ 165/* for exporting parameters in /sys/parameters */
173 166
174struct module; 167struct module;
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index ee700c6eb442..839f0b3c23aa 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)
51#define page_cache_release(page) put_page(page) 51#define page_cache_release(page) put_page(page)
52void release_pages(struct page **pages, int nr, int cold); 52void release_pages(struct page **pages, int nr, int cold);
53 53
54#ifdef CONFIG_NUMA
55extern struct page *page_cache_alloc(struct address_space *x);
56extern struct page *page_cache_alloc_cold(struct address_space *x);
57#else
54static inline struct page *page_cache_alloc(struct address_space *x) 58static inline struct page *page_cache_alloc(struct address_space *x)
55{ 59{
56 return alloc_pages(mapping_gfp_mask(x), 0); 60 return alloc_pages(mapping_gfp_mask(x), 0);
@@ -60,6 +64,7 @@ static inline struct page *page_cache_alloc_cold(struct address_space *x)
60{ 64{
61 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0); 65 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
62} 66}
67#endif
63 68
64typedef int filler_t(void *, struct page *); 69typedef int filler_t(void *, struct page *);
65 70
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index f3dcf89d5232..6f080ae59286 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -69,6 +69,7 @@
69#define PCI_CLASS_SYSTEM_TIMER 0x0802 69#define PCI_CLASS_SYSTEM_TIMER 0x0802
70#define PCI_CLASS_SYSTEM_RTC 0x0803 70#define PCI_CLASS_SYSTEM_RTC 0x0803
71#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804 71#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804
72#define PCI_CLASS_SYSTEM_SDHCI 0x0805
72#define PCI_CLASS_SYSTEM_OTHER 0x0880 73#define PCI_CLASS_SYSTEM_OTHER 0x0880
73 74
74#define PCI_BASE_CLASS_INPUT 0x09 75#define PCI_BASE_CLASS_INPUT 0x09
diff --git a/include/linux/platform.h b/include/linux/platform.h
deleted file mode 100644
index 3c33084a6ec2..000000000000
--- a/include/linux/platform.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * include/linux/platform.h - platform driver definitions
3 *
4 * Because of the prolific consumerism of the average American,
5 * and the dominant marketing budgets of PC OEMs, we have been
6 * blessed with frequent updates of the PC architecture.
7 *
8 * While most of these calls are singular per architecture, they
9 * require an extra layer of abstraction on the x86 so the right
10 * subsystem gets the right call.
11 *
12 * Basically, this consolidates the power off and reboot callbacks
13 * into one structure, as well as adding power management hooks.
14 *
15 * When adding a platform driver, please make sure all callbacks are
16 * filled. There are defaults defined below that do nothing; use those
17 * if you do not support that callback.
18 */
19
20#ifndef _PLATFORM_H_
21#define _PLATFORM_H_
22#ifdef __KERNEL__
23
24#include <linux/types.h>
25
26struct platform_t {
27 char * name;
28 u32 suspend_states;
29 void (*reboot)(char * cmd);
30 void (*halt)(void);
31 void (*power_off)(void);
32 int (*suspend)(int state, int flags);
33 void (*idle)(void);
34};
35
36extern struct platform_t * platform;
37extern void default_reboot(char * cmd);
38extern void default_halt(void);
39extern int default_suspend(int state, int flags);
40extern void default_idle(void);
41
42#endif /* __KERNEL__ */
43#endif /* _PLATFORM_H */
diff --git a/include/linux/ppdev.h b/include/linux/ppdev.h
index 141c96586824..f376a7598a78 100644
--- a/include/linux/ppdev.h
+++ b/include/linux/ppdev.h
@@ -14,8 +14,6 @@
14 * Added PPGETMODES/PPGETMODE/PPGETPHASE, Fred Barnes <frmb2@ukc.ac.uk>, 03/01/2001 14 * Added PPGETMODES/PPGETMODE/PPGETPHASE, Fred Barnes <frmb2@ukc.ac.uk>, 03/01/2001
15 */ 15 */
16 16
17#define PP_MAJOR 99
18
19#define PP_IOCTL 'p' 17#define PP_IOCTL 'p'
20 18
21/* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */ 19/* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 8dc2d04a103f..2dab71e1c3d1 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -209,7 +209,6 @@ extern struct dqstats dqstats;
209#define DQ_FAKE_B 3 /* no limits only usage */ 209#define DQ_FAKE_B 3 /* no limits only usage */
210#define DQ_READ_B 4 /* dquot was read into memory */ 210#define DQ_READ_B 4 /* dquot was read into memory */
211#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */ 211#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */
212#define DQ_WAITFREE_B 6 /* dquot being waited (by invalidate_dquots) */
213 212
214struct dquot { 213struct dquot {
215 struct hlist_node dq_hash; /* Hash list in memory */ 214 struct hlist_node dq_hash; /* Hash list in memory */
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index c57ff2fcb30a..dd83cca28001 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -45,6 +45,8 @@ do { \
45 (root)->rnode = NULL; \ 45 (root)->rnode = NULL; \
46} while (0) 46} while (0)
47 47
48#define RADIX_TREE_MAX_TAGS 2
49
48int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); 50int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
49void *radix_tree_lookup(struct radix_tree_root *, unsigned long); 51void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
50void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long); 52void **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,
55int radix_tree_preload(gfp_t gfp_mask); 57int radix_tree_preload(gfp_t gfp_mask);
56void radix_tree_init(void); 58void radix_tree_init(void);
57void *radix_tree_tag_set(struct radix_tree_root *root, 59void *radix_tree_tag_set(struct radix_tree_root *root,
58 unsigned long index, int tag); 60 unsigned long index, unsigned int tag);
59void *radix_tree_tag_clear(struct radix_tree_root *root, 61void *radix_tree_tag_clear(struct radix_tree_root *root,
60 unsigned long index, int tag); 62 unsigned long index, unsigned int tag);
61int radix_tree_tag_get(struct radix_tree_root *root, 63int radix_tree_tag_get(struct radix_tree_root *root,
62 unsigned long index, int tag); 64 unsigned long index, unsigned int tag);
63unsigned int 65unsigned int
64radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, 66radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
65 unsigned long first_index, unsigned int max_items, int tag); 67 unsigned long first_index, unsigned int max_items,
66int radix_tree_tagged(struct radix_tree_root *root, int tag); 68 unsigned int tag);
69int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag);
67 70
68static inline void radix_tree_preload_end(void) 71static inline void radix_tree_preload_end(void)
69{ 72{
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index dad78cecfd20..912f1b7cb18f 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)
1704 return 0; 1704 return 0;
1705} 1705}
1706 1706
1707static inline int reiserfs_transaction_free_space(struct reiserfs_transaction_handle *th)
1708{
1709 return th->t_blocks_allocated - th->t_blocks_logged;
1710}
1711
1707int reiserfs_async_progress_wait(struct super_block *s); 1712int reiserfs_async_progress_wait(struct super_block *s);
1708 1713
1709struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct 1714struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index 87280eb6083d..5353afb11db3 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)
101#else 101#else
102 102
103#define is_reiserfs_priv_object(inode) 0 103#define is_reiserfs_priv_object(inode) 0
104#define reiserfs_mark_inode_private(inode) 104#define reiserfs_mark_inode_private(inode) do {;} while(0)
105#define reiserfs_getxattr NULL 105#define reiserfs_getxattr NULL
106#define reiserfs_setxattr NULL 106#define reiserfs_setxattr NULL
107#define reiserfs_listxattr NULL 107#define reiserfs_listxattr NULL
108#define reiserfs_removexattr NULL 108#define reiserfs_removexattr NULL
109#define reiserfs_write_lock_xattrs(sb) 109#define reiserfs_write_lock_xattrs(sb) do {;} while(0)
110#define reiserfs_write_unlock_xattrs(sb) 110#define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
111#define reiserfs_read_lock_xattrs(sb) 111#define reiserfs_read_lock_xattrs(sb)
112#define reiserfs_read_unlock_xattrs(sb) 112#define reiserfs_read_unlock_xattrs(sb)
113 113
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e60a91d5b369..e0054c1b9a09 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -206,11 +206,11 @@ extern void update_process_times(int user);
206extern void scheduler_tick(void); 206extern void scheduler_tick(void);
207 207
208#ifdef CONFIG_DETECT_SOFTLOCKUP 208#ifdef CONFIG_DETECT_SOFTLOCKUP
209extern void softlockup_tick(struct pt_regs *regs); 209extern void softlockup_tick(void);
210extern void spawn_softlockup_task(void); 210extern void spawn_softlockup_task(void);
211extern void touch_softlockup_watchdog(void); 211extern void touch_softlockup_watchdog(void);
212#else 212#else
213static inline void softlockup_tick(struct pt_regs *regs) 213static inline void softlockup_tick(void)
214{ 214{
215} 215}
216static inline void spawn_softlockup_task(void) 216static inline void spawn_softlockup_task(void)
@@ -869,6 +869,7 @@ struct task_struct {
869 struct cpuset *cpuset; 869 struct cpuset *cpuset;
870 nodemask_t mems_allowed; 870 nodemask_t mems_allowed;
871 int cpuset_mems_generation; 871 int cpuset_mems_generation;
872 int cpuset_mem_spread_rotor;
872#endif 873#endif
873 atomic_t fs_excl; /* holding fs exclusive resources */ 874 atomic_t fs_excl; /* holding fs exclusive resources */
874 struct rcu_head rcu; 875 struct rcu_head rcu;
@@ -929,6 +930,9 @@ static inline void put_task_struct(struct task_struct *t)
929#define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */ 930#define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */
930#define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */ 931#define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */
931#define PF_SWAPWRITE 0x01000000 /* Allowed to write to swap */ 932#define PF_SWAPWRITE 0x01000000 /* Allowed to write to swap */
933#define PF_SPREAD_PAGE 0x04000000 /* Spread page cache over cpuset */
934#define PF_SPREAD_SLAB 0x08000000 /* Spread some slab caches over cpuset */
935#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
932 936
933/* 937/*
934 * Only the _current_ task can read/write to tsk->flags, but other 938 * 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 b18eb8cfa639..3c19be35124b 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1040,6 +1040,11 @@ struct swap_info_struct;
1040 * @effective contains the effective capability set. 1040 * @effective contains the effective capability set.
1041 * @inheritable contains the inheritable capability set. 1041 * @inheritable contains the inheritable capability set.
1042 * @permitted contains the permitted capability set. 1042 * @permitted contains the permitted capability set.
1043 * @capable:
1044 * Check whether the @tsk process has the @cap capability.
1045 * @tsk contains the task_struct for the process.
1046 * @cap contains the capability <include/linux/capability.h>.
1047 * Return 0 if the capability is granted for @tsk.
1043 * @acct: 1048 * @acct:
1044 * Check permission before enabling or disabling process accounting. If 1049 * Check permission before enabling or disabling process accounting. If
1045 * accounting is being enabled, then @file refers to the open file used to 1050 * accounting is being enabled, then @file refers to the open file used to
@@ -1053,11 +1058,6 @@ struct swap_info_struct;
1053 * @table contains the ctl_table structure for the sysctl variable. 1058 * @table contains the ctl_table structure for the sysctl variable.
1054 * @op contains the operation (001 = search, 002 = write, 004 = read). 1059 * @op contains the operation (001 = search, 002 = write, 004 = read).
1055 * Return 0 if permission is granted. 1060 * Return 0 if permission is granted.
1056 * @capable:
1057 * Check whether the @tsk process has the @cap capability.
1058 * @tsk contains the task_struct for the process.
1059 * @cap contains the capability <include/linux/capability.h>.
1060 * Return 0 if the capability is granted for @tsk.
1061 * @syslog: 1061 * @syslog:
1062 * Check permission before accessing the kernel message ring or changing 1062 * Check permission before accessing the kernel message ring or changing
1063 * logging to the console. 1063 * logging to the console.
@@ -1099,9 +1099,9 @@ struct security_operations {
1099 kernel_cap_t * effective, 1099 kernel_cap_t * effective,
1100 kernel_cap_t * inheritable, 1100 kernel_cap_t * inheritable,
1101 kernel_cap_t * permitted); 1101 kernel_cap_t * permitted);
1102 int (*capable) (struct task_struct * tsk, int cap);
1102 int (*acct) (struct file * file); 1103 int (*acct) (struct file * file);
1103 int (*sysctl) (struct ctl_table * table, int op); 1104 int (*sysctl) (struct ctl_table * table, int op);
1104 int (*capable) (struct task_struct * tsk, int cap);
1105 int (*quotactl) (int cmds, int type, int id, struct super_block * sb); 1105 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1106 int (*quota_on) (struct dentry * dentry); 1106 int (*quota_on) (struct dentry * dentry);
1107 int (*syslog) (int type); 1107 int (*syslog) (int type);
@@ -1347,6 +1347,11 @@ static inline void security_capset_set (struct task_struct *target,
1347 security_ops->capset_set (target, effective, inheritable, permitted); 1347 security_ops->capset_set (target, effective, inheritable, permitted);
1348} 1348}
1349 1349
1350static inline int security_capable(struct task_struct *tsk, int cap)
1351{
1352 return security_ops->capable(tsk, cap);
1353}
1354
1350static inline int security_acct (struct file *file) 1355static inline int security_acct (struct file *file)
1351{ 1356{
1352 return security_ops->acct (file); 1357 return security_ops->acct (file);
@@ -2050,6 +2055,11 @@ static inline void security_capset_set (struct task_struct *target,
2050 cap_capset_set (target, effective, inheritable, permitted); 2055 cap_capset_set (target, effective, inheritable, permitted);
2051} 2056}
2052 2057
2058static inline int security_capable(struct task_struct *tsk, int cap)
2059{
2060 return cap_capable(tsk, cap);
2061}
2062
2053static inline int security_acct (struct file *file) 2063static inline int security_acct (struct file *file)
2054{ 2064{
2055 return 0; 2065 return 0;
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 2b28c849d75a..15e1d9736b1b 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -46,6 +46,7 @@ typedef struct kmem_cache kmem_cache_t;
46 what is reclaimable later*/ 46 what is reclaimable later*/
47#define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */ 47#define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */
48#define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */ 48#define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */
49#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
49 50
50/* flags passed to a constructor func */ 51/* flags passed to a constructor func */
51#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */ 52#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
63extern int kmem_cache_destroy(kmem_cache_t *); 64extern int kmem_cache_destroy(kmem_cache_t *);
64extern int kmem_cache_shrink(kmem_cache_t *); 65extern int kmem_cache_shrink(kmem_cache_t *);
65extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); 66extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
67extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
66extern void kmem_cache_free(kmem_cache_t *, void *); 68extern void kmem_cache_free(kmem_cache_t *, void *);
67extern unsigned int kmem_cache_size(kmem_cache_t *); 69extern unsigned int kmem_cache_size(kmem_cache_t *);
68extern const char *kmem_cache_name(kmem_cache_t *); 70extern const char *kmem_cache_name(kmem_cache_t *);
@@ -76,11 +78,12 @@ struct cache_sizes {
76}; 78};
77extern struct cache_sizes malloc_sizes[]; 79extern struct cache_sizes malloc_sizes[];
78 80
79#ifndef CONFIG_DEBUG_SLAB
80extern void *__kmalloc(size_t, gfp_t); 81extern void *__kmalloc(size_t, gfp_t);
82#ifndef CONFIG_DEBUG_SLAB
83#define ____kmalloc(size, flags) __kmalloc(size, flags)
81#else 84#else
82extern void *__kmalloc_track_caller(size_t, gfp_t, void*); 85extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
83#define __kmalloc(size, flags) \ 86#define ____kmalloc(size, flags) \
84 __kmalloc_track_caller(size, flags, __builtin_return_address(0)) 87 __kmalloc_track_caller(size, flags, __builtin_return_address(0))
85#endif 88#endif
86 89
@@ -107,7 +110,30 @@ found:
107 return __kmalloc(size, flags); 110 return __kmalloc(size, flags);
108} 111}
109 112
110extern void *kzalloc(size_t, gfp_t); 113extern void *__kzalloc(size_t, gfp_t);
114
115static inline void *kzalloc(size_t size, gfp_t flags)
116{
117 if (__builtin_constant_p(size)) {
118 int i = 0;
119#define CACHE(x) \
120 if (size <= x) \
121 goto found; \
122 else \
123 i++;
124#include "kmalloc_sizes.h"
125#undef CACHE
126 {
127 extern void __you_cannot_kzalloc_that_much(void);
128 __you_cannot_kzalloc_that_much();
129 }
130found:
131 return kmem_cache_zalloc((flags & GFP_DMA) ?
132 malloc_sizes[i].cs_dmacachep :
133 malloc_sizes[i].cs_cachep, flags);
134 }
135 return __kzalloc(size, flags);
136}
111 137
112/** 138/**
113 * kcalloc - allocate memory for an array. The memory is set to zero. 139 * 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,
154 void (*)(void *, struct kmem_cache *, unsigned long)); 180 void (*)(void *, struct kmem_cache *, unsigned long));
155int kmem_cache_destroy(struct kmem_cache *c); 181int kmem_cache_destroy(struct kmem_cache *c);
156void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); 182void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags);
183void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
157void kmem_cache_free(struct kmem_cache *c, void *b); 184void kmem_cache_free(struct kmem_cache *c, void *b);
158const char *kmem_cache_name(struct kmem_cache *); 185const char *kmem_cache_name(struct kmem_cache *);
159void *kmalloc(size_t size, gfp_t flags); 186void *kmalloc(size_t size, gfp_t flags);
160void *kzalloc(size_t size, gfp_t flags); 187void *__kzalloc(size_t size, gfp_t flags);
161void kfree(const void *m); 188void kfree(const void *m);
162unsigned int ksize(const void *m); 189unsigned int ksize(const void *m);
163unsigned int kmem_cache_size(struct kmem_cache *c); 190unsigned int kmem_cache_size(struct kmem_cache *c);
164 191
165static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 192static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
166{ 193{
167 return kzalloc(n * size, flags); 194 return __kzalloc(n * size, flags);
168} 195}
169 196
170#define kmem_cache_shrink(d) (0) 197#define kmem_cache_shrink(d) (0)
@@ -172,6 +199,8 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
172#define kmem_ptr_validate(a, b) (0) 199#define kmem_ptr_validate(a, b) (0)
173#define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f) 200#define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f)
174#define kmalloc_node(s, f, n) kmalloc(s, f) 201#define kmalloc_node(s, f, n) kmalloc(s, f)
202#define kzalloc(s, f) __kzalloc(s, f)
203#define ____kmalloc kmalloc
175 204
176#endif /* CONFIG_SLOB */ 205#endif /* CONFIG_SLOB */
177 206
diff --git a/include/linux/string.h b/include/linux/string.h
index 369be3264a55..dee221429ad0 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -18,6 +18,8 @@ extern char * strsep(char **,const char *);
18extern __kernel_size_t strspn(const char *,const char *); 18extern __kernel_size_t strspn(const char *,const char *);
19extern __kernel_size_t strcspn(const char *,const char *); 19extern __kernel_size_t strcspn(const char *,const char *);
20 20
21extern char *strndup_user(const char __user *, long);
22
21/* 23/*
22 * Include machine specific inline routines 24 * Include machine specific inline routines
23 */ 25 */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index b9ea44ac0ddb..e487e3b60f60 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,
568 int flag); 568 int flag);
569asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename, 569asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
570 int flags, int mode); 570 int flags, int mode);
571asmlinkage long sys_unshare(unsigned long unshare_flags);
571 572
572#endif 573#endif
diff --git a/include/linux/time.h b/include/linux/time.h
index d9cdba54b789..bf0e785e2e03 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);
101struct itimerval; 101struct itimerval;
102extern int do_setitimer(int which, struct itimerval *value, 102extern int do_setitimer(int which, struct itimerval *value,
103 struct itimerval *ovalue); 103 struct itimerval *ovalue);
104extern unsigned int alarm_setitimer(unsigned int seconds);
104extern int do_getitimer(int which, struct itimerval *value); 105extern int do_getitimer(int which, struct itimerval *value);
105extern void getnstimeofday(struct timespec *tv); 106extern void getnstimeofday(struct timespec *tv);
106 107
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 9b9877fd2505..ee5a09e806e8 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -69,13 +69,13 @@ extern unsigned long next_timer_interrupt(void);
69 * @timer: the timer to be added 69 * @timer: the timer to be added
70 * 70 *
71 * The kernel will do a ->function(->data) callback from the 71 * The kernel will do a ->function(->data) callback from the
72 * timer interrupt at the ->expired point in the future. The 72 * timer interrupt at the ->expires point in the future. The
73 * current time is 'jiffies'. 73 * current time is 'jiffies'.
74 * 74 *
75 * The timer's ->expired, ->function (and if the handler uses it, ->data) 75 * The timer's ->expires, ->function (and if the handler uses it, ->data)
76 * fields must be set prior calling this function. 76 * fields must be set prior calling this function.
77 * 77 *
78 * Timers with an ->expired field in the past will be executed in the next 78 * Timers with an ->expires field in the past will be executed in the next
79 * timer tick. 79 * timer tick.
80 */ 80 */
81static inline void add_timer(struct timer_list *timer) 81static inline void add_timer(struct timer_list *timer)
diff --git a/include/linux/timex.h b/include/linux/timex.h
index b7ca1204e42a..82dc9ae79d37 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -97,38 +97,11 @@
97 97
98#define MAXPHASE 512000L /* max phase error (us) */ 98#define MAXPHASE 512000L /* max phase error (us) */
99#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ 99#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */
100#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
101#define MINSEC 16L /* min interval between updates (s) */ 100#define MINSEC 16L /* min interval between updates (s) */
102#define MAXSEC 1200L /* max interval between updates (s) */ 101#define MAXSEC 1200L /* max interval between updates (s) */
103#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ 102#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */
104 103
105/* 104/*
106 * The following defines are used only if a pulse-per-second (PPS)
107 * signal is available and connected via a modem control lead, such as
108 * produced by the optional ppsclock feature incorporated in the Sun
109 * asynch driver. They establish the design parameters of the frequency-
110 * lock loop used to discipline the CPU clock oscillator to the PPS
111 * signal.
112 *
113 * PPS_AVG is the averaging factor for the frequency loop, as well as
114 * the time and frequency dispersion.
115 *
116 * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
117 * calibration intervals, respectively, in seconds as a power of two.
118 *
119 * PPS_VALID is the maximum interval before the PPS signal is considered
120 * invalid and protocol updates used directly instead.
121 *
122 * MAXGLITCH is the maximum interval before a time offset of more than
123 * MAXTIME is believed.
124 */
125#define PPS_AVG 2 /* pps averaging constant (shift) */
126#define PPS_SHIFT 2 /* min interval duration (s) (shift) */
127#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */
128#define PPS_VALID 120 /* pps signal watchdog max (s) */
129#define MAXGLITCH 30 /* pps signal glitch max (s) */
130
131/*
132 * syscall interface - used (mainly by NTP daemon) 105 * syscall interface - used (mainly by NTP daemon)
133 * to discipline kernel clock oscillator 106 * to discipline kernel clock oscillator
134 */ 107 */
@@ -246,20 +219,6 @@ extern long time_reftime; /* time at last adjustment (s) */
246extern long time_adjust; /* The amount of adjtime left */ 219extern long time_adjust; /* The amount of adjtime left */
247extern long time_next_adjust; /* Value for time_adjust at next tick */ 220extern long time_next_adjust; /* Value for time_adjust at next tick */
248 221
249/* interface variables pps->timer interrupt */
250extern long pps_offset; /* pps time offset (us) */
251extern long pps_jitter; /* time dispersion (jitter) (us) */
252extern long pps_freq; /* frequency offset (scaled ppm) */
253extern long pps_stabil; /* frequency dispersion (scaled ppm) */
254extern long pps_valid; /* pps signal watchdog counter */
255
256/* interface variables pps->adjtimex */
257extern int pps_shift; /* interval duration (s) (shift) */
258extern long pps_jitcnt; /* jitter limit exceeded */
259extern long pps_calcnt; /* calibration intervals */
260extern long pps_errcnt; /* calibration errors */
261extern long pps_stbcnt; /* stability limit exceeded */
262
263/** 222/**
264 * ntp_clear - Clears the NTP state variables 223 * ntp_clear - Clears the NTP state variables
265 * 224 *
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 0c6169fff366..0976a163b459 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -2,8 +2,8 @@
2#define _LINUX_TTY_FLIP_H 2#define _LINUX_TTY_FLIP_H
3 3
4extern int tty_buffer_request_room(struct tty_struct *tty, size_t size); 4extern int tty_buffer_request_room(struct tty_struct *tty, size_t size);
5extern int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size); 5extern int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size);
6extern int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size); 6extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size);
7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); 7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);
8extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); 8extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size);
9 9
diff --git a/include/linux/udf_fs_i.h b/include/linux/udf_fs_i.h
index 1e7508420fcf..ffaf05679ffb 100644
--- a/include/linux/udf_fs_i.h
+++ b/include/linux/udf_fs_i.h
@@ -15,27 +15,6 @@
15 15
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17 17
18#ifndef _ECMA_167_H
19typedef struct
20{
21 __u32 logicalBlockNum;
22 __u16 partitionReferenceNum;
23} __attribute__ ((packed)) lb_addr;
24
25typedef struct
26{
27 __u32 extLength;
28 __u32 extPosition;
29} __attribute__ ((packed)) short_ad;
30
31typedef struct
32{
33 __u32 extLength;
34 lb_addr extLocation;
35 __u8 impUse[6];
36} __attribute__ ((packed)) long_ad;
37#endif
38
39struct udf_inode_info 18struct udf_inode_info
40{ 19{
41 struct timespec i_crtime; 20 struct timespec i_crtime;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 724cfbf54b8a..2275bfec5b68 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -883,6 +883,7 @@ struct v4l2_modulator
883#define V4L2_TUNER_MODE_LANG2 0x0002 883#define V4L2_TUNER_MODE_LANG2 0x0002
884#define V4L2_TUNER_MODE_SAP 0x0002 884#define V4L2_TUNER_MODE_SAP 0x0002
885#define V4L2_TUNER_MODE_LANG1 0x0003 885#define V4L2_TUNER_MODE_LANG1 0x0003
886#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
886 887
887struct v4l2_frequency 888struct v4l2_frequency
888{ 889{
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index beaef5c7a0ea..56f92fcbe94a 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -88,8 +88,8 @@ void throttle_vm_writeout(void);
88/* These are exported to sysctl. */ 88/* These are exported to sysctl. */
89extern int dirty_background_ratio; 89extern int dirty_background_ratio;
90extern int vm_dirty_ratio; 90extern int vm_dirty_ratio;
91extern int dirty_writeback_centisecs; 91extern int dirty_writeback_interval;
92extern int dirty_expire_centisecs; 92extern int dirty_expire_interval;
93extern int block_dump; 93extern int block_dump;
94extern int laptop_mode; 94extern int laptop_mode;
95 95
@@ -99,7 +99,15 @@ int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *,
99 void __user *, size_t *, loff_t *); 99 void __user *, size_t *, loff_t *);
100 100
101void page_writeback_init(void); 101void page_writeback_init(void);
102void balance_dirty_pages_ratelimited(struct address_space *mapping); 102void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
103 unsigned long nr_pages_dirtied);
104
105static inline void
106balance_dirty_pages_ratelimited(struct address_space *mapping)
107{
108 balance_dirty_pages_ratelimited_nr(mapping, 1);
109}
110
103int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0); 111int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
104int do_writepages(struct address_space *mapping, struct writeback_control *wbc); 112int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
105int sync_page_range(struct inode *inode, struct address_space *mapping, 113int sync_page_range(struct inode *inode, struct address_space *mapping,
diff --git a/include/linux/zorro.h b/include/linux/zorro.h
index ba5b72768bbe..2f135cf6eef1 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)
271} 271}
272 272
273 273
274/*
275 * A helper function which helps ensure correct zorro_driver
276 * setup and cleanup for commonly-encountered hotplug/modular cases
277 *
278 * This MUST stay in a header, as it checks for -DMODULE
279 */
280static inline int zorro_module_init(struct zorro_driver *drv)
281{
282 int rc = zorro_register_driver(drv);
283
284 if (rc > 0)
285 return 0;
286
287 /* iff CONFIG_HOTPLUG and built into kernel, we should
288 * leave the driver around for future hotplug events.
289 * For the module case, a hotplug daemon of some sort
290 * should load a module in response to an insert event. */
291#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
292 if (rc == 0)
293 return 0;
294#else
295 if (rc == 0)
296 rc = -ENODEV;
297#endif
298
299 /* if we get here, we need to clean up Zorro driver instance
300 * and return some sort of error */
301 zorro_unregister_driver(drv);
302
303 return rc;
304}
305
306
307 /* 274 /*
308 * Bitmask indicating portions of available Zorro II RAM that are unused 275 * Bitmask indicating portions of available Zorro II RAM that are unused
309 * by the system. Every bit represents a 64K chunk, for a maximum of 8MB 276 * 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 295d256ee811..1fd4a2207574 100644
--- a/include/media/audiochip.h
+++ b/include/media/audiochip.h
@@ -21,18 +21,4 @@ enum audiochip {
21 AUDIO_CHIP_MSP34XX 21 AUDIO_CHIP_MSP34XX
22}; 22};
23 23
24/* ---------------------------------------------------------------------- */
25
26/* audio inputs */
27#define AUDIO_TUNER 0x00
28#define AUDIO_RADIO 0x01
29#define AUDIO_EXTERN 0x02
30#define AUDIO_INTERN 0x03
31#define AUDIO_OFF 0x04
32#define AUDIO_ON 0x05
33#define AUDIO_EXTERN_1 AUDIO_EXTERN
34#define AUDIO_EXTERN_2 0x06
35#define AUDIO_MUTE 0x80
36#define AUDIO_UNMUTE 0x81
37
38#endif /* AUDIOCHIP_H */ 24#endif /* AUDIOCHIP_H */
diff --git a/include/media/cs53l32a.h b/include/media/cs53l32a.h
new file mode 100644
index 000000000000..bf76197d3790
--- /dev/null
+++ b/include/media/cs53l32a.h
@@ -0,0 +1,34 @@
1/*
2 cs53l32a.h - definition for cs53l32a inputs and outputs
3
4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _CS53L32A_H_
22#define _CS53L32A_H_
23
24/* There are 2 physical inputs, but the second input can be
25 placed in two modes, the first mode bypasses the PGA (gain),
26 the second goes through the PGA. Hence there are three
27 possible inputs to choose from. */
28
29/* CS53L32A HW inputs */
30#define CS53L32A_IN0 0
31#define CS53L32A_IN1 1
32#define CS53L32A_IN2 2
33
34#endif
diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h
new file mode 100644
index 000000000000..e7ff44a35ca0
--- /dev/null
+++ b/include/media/i2c-addr.h
@@ -0,0 +1,44 @@
1/*
2 * V4L I2C address list
3 *
4 *
5 * Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
6 * Based on a previous mapping by
7 * Ralph Metzler (rjkm@thp.uni-koeln.de)
8 * Gerd Knorr <kraxel@goldbach.in-berlin.de>
9 *
10 */
11
12/* bttv address list */
13#define I2C_ADDR_TSA5522 0xc2
14#define I2C_ADDR_TDA7432 0x8a
15#define I2C_ADDR_BT832_ALT1 0x88
16#define I2C_ADDR_BT832_ALT2 0x8a // alternate setting
17#define I2C_ADDR_TDA8425 0x82
18#define I2C_ADDR_TDA9840 0x84
19#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */
20#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
21#define I2C_ADDR_TDA9875 0xb0
22#define I2C_ADDR_HAUPEE 0xa0
23#define I2C_ADDR_STBEE 0xae
24#define I2C_ADDR_VHX 0xc0
25#define I2C_ADDR_MSP3400 0x80
26#define I2C_ADDR_MSP3400_ALT 0x88
27#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
28#define I2C_ADDR_DPL3518 0x84
29#define I2C_ADDR_TDA9887 0x86
30
31/*
32 * i2c bus addresses for the chips supported by tvaudio.c
33 */
34
35#define I2C_ADDR_TDA8425 0x82
36#define I2C_ADDR_TDA9840 0x84 /* also used by TA8874Z */
37#define I2C_ADDR_TDA985x_L 0xb4 /* also used by 9873 */
38#define I2C_ADDR_TDA985x_H 0xb6
39#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
40
41#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
42#define I2C_ADDR_TEA6420 0x98
43
44#define I2C_ADDR_PIC16C54 0x96 /* PV951 */
diff --git a/include/media/msp3400.h b/include/media/msp3400.h
new file mode 100644
index 000000000000..0be61a021d45
--- /dev/null
+++ b/include/media/msp3400.h
@@ -0,0 +1,226 @@
1/*
2 msp3400.h - definition for msp3400 inputs and outputs
3
4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _MSP3400_H_
22#define _MSP3400_H_
23
24/* msp3400 routing
25 ===============
26
27 The msp3400 has a complicated routing scheme with many possible
28 combinations. The details are all in the datasheets but I will try
29 to give a short description here.
30
31 Inputs
32 ======
33
34 There are 1) tuner inputs, 2) I2S inputs, 3) SCART inputs. You will have
35 to select which tuner input to use and which SCART input to use. The
36 selected tuner input, the selected SCART input and all I2S inputs go to
37 the DSP (the tuner input first goes through the demodulator).
38
39 The DSP handles things like volume, bass/treble, balance, and some chips
40 have support for surround sound. It has several outputs: MAIN, AUX, I2S
41 and SCART1/2. Each output can select which DSP input to use. So the MAIN
42 output can select the tuner input while at the same time the SCART1 output
43 uses the I2S input.
44
45 Outputs
46 =======
47
48 Most DSP outputs are also the outputs of the msp3400. However, the SCART
49 outputs of the msp3400 can select which input to use: either the SCART1 or
50 SCART2 output from the DSP, or the msp3400 SCART inputs, thus completely
51 bypassing the DSP.
52
53 Summary
54 =======
55
56 So to specify a complete routing scheme for the msp3400 you will have to
57 specify in the 'input' field of the v4l2_routing struct:
58
59 1) which tuner input to use
60 2) which SCART input to use
61 3) which DSP input to use for each DSP output
62
63 And in the 'output' field of the v4l2_routing struct you specify:
64
65 1) which SCART input to use for each SCART output
66
67 Depending on how the msp is wired to the other components you can
68 ignore or mute certain inputs or outputs.
69
70 Also, depending on the msp version only a subset of the inputs or
71 outputs may be present. At the end of this header some tables are
72 added containing a list of what is available for each msp version.
73 */
74
75/* Inputs to the DSP unit: two independent selections have to be made:
76 1) the tuner (SIF) input
77 2) the SCART input
78 Bits 0-2 are used for the SCART input select, bit 3 is used for the tuner
79 input, bits 4-7 are reserved.
80 */
81
82/* SCART input to DSP selection */
83#define MSP_IN_SCART_1 0 /* Pin SC1_IN */
84#define MSP_IN_SCART_2 1 /* Pin SC2_IN */
85#define MSP_IN_SCART_3 2 /* Pin SC3_IN */
86#define MSP_IN_SCART_4 3 /* Pin SC4_IN */
87#define MSP_IN_MONO 6 /* Pin MONO_IN */
88#define MSP_IN_MUTE 7 /* Mute DSP input */
89#define MSP_SCART_TO_DSP(in) (in)
90/* Tuner input to demodulator and DSP selection */
91#define MSP_IN_TUNER_1 0 /* Analog Sound IF input pin ANA_IN1 */
92#define MSP_IN_TUNER_2 1 /* Analog Sound IF input pin ANA_IN2 */
93#define MSP_TUNER_TO_DSP(in) ((in) << 3)
94
95/* The msp has up to 5 DSP outputs, each output can independently select
96 a DSP input.
97
98 The DSP outputs are: loudspeaker output (aka MAIN), headphones output
99 (aka AUX), SCART1 DA output, SCART2 DA output and an I2S output.
100 There also is a quasi-peak detector output, but that is not used by
101 this driver and is set to the same input as the loudspeaker output.
102 Not all outputs are supported by all msp models. Setting the input
103 of an unsupported output will be ignored by the driver.
104
105 There are up to 16 DSP inputs to choose from, so each output is
106 assigned 4 bits.
107
108 Note: the 44x8G can mix two inputs and feed the result back to the
109 DSP. This is currently not implemented. Also not implemented is the
110 multi-channel capable I2S3 input of the 44x0G. If someone can demonstrate
111 a need for one of those features then additional support can be added. */
112#define MSP_DSP_OUT_TUNER 0 /* Tuner output */
113#define MSP_DSP_OUT_SCART 2 /* SCART output */
114#define MSP_DSP_OUT_I2S1 5 /* I2S1 output */
115#define MSP_DSP_OUT_I2S2 6 /* I2S2 output */
116#define MSP_DSP_OUT_I2S3 7 /* I2S3 output */
117#define MSP_DSP_OUT_MAIN_AVC 11 /* MAIN AVC processed output */
118#define MSP_DSP_OUT_MAIN 12 /* MAIN output */
119#define MSP_DSP_OUT_AUX 13 /* AUX output */
120#define MSP_DSP_TO_MAIN(in) ((in) << 4)
121#define MSP_DSP_TO_AUX(in) ((in) << 8)
122#define MSP_DSP_TO_SCART1(in) ((in) << 12)
123#define MSP_DSP_TO_SCART2(in) ((in) << 16)
124#define MSP_DSP_TO_I2S(in) ((in) << 20)
125
126/* Output SCART select: the SCART outputs can select which input
127 to use. */
128#define MSP_OUT_SCART1 0 /* SCART1 input, bypassing the DSP */
129#define MSP_OUT_SCART2 1 /* SCART2 input, bypassing the DSP */
130#define MSP_OUT_SCART3 2 /* SCART3 input, bypassing the DSP */
131#define MSP_OUT_SCART4 3 /* SCART4 input, bypassing the DSP */
132#define MSP_OUT_SCART1_DA 4 /* DSP SCART1 output */
133#define MSP_OUT_SCART2_DA 5 /* DSP SCART2 output */
134#define MSP_OUT_MONO 6 /* MONO input, bypassing the DSP */
135#define MSP_OUT_MUTE 7 /* MUTE output */
136#define MSP_OUT_TO_SCART1(in) (in)
137#define MSP_OUT_TO_SCART2(in) ((in) << 4)
138
139/* Shortcut macros */
140#define MSP_INPUT(sc, t, main_aux_src, sc_i2s_src) \
141 (MSP_SCART_TO_DSP(sc) | \
142 MSP_TUNER_TO_DSP(t) | \
143 MSP_DSP_TO_MAIN(main_aux_src) | \
144 MSP_DSP_TO_AUX(main_aux_src) | \
145 MSP_DSP_TO_SCART1(sc_i2s_src) | \
146 MSP_DSP_TO_SCART2(sc_i2s_src) | \
147 MSP_DSP_TO_I2S(sc_i2s_src))
148#define MSP_INPUT_DEFAULT MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1, \
149 MSP_DSP_OUT_TUNER, MSP_DSP_OUT_TUNER)
150#define MSP_OUTPUT(sc) \
151 (MSP_OUT_TO_SCART1(sc) | \
152 MSP_OUT_TO_SCART2(sc))
153/* This equals the RESET position of the msp3400 ACB register */
154#define MSP_OUTPUT_DEFAULT (MSP_OUT_TO_SCART1(MSP_OUT_SCART3) | \
155 MSP_OUT_TO_SCART2(MSP_OUT_SCART1_DA))
156
157/* Tuner inputs vs. msp version */
158/* Chip TUNER_1 TUNER_2
159 -------------------------
160 msp34x0b y y
161 msp34x0c y y
162 msp34x0d y y
163 msp34x5d y n
164 msp34x7d y n
165 msp34x0g y y
166 msp34x1g y y
167 msp34x2g y y
168 msp34x5g y n
169 msp34x7g y n
170 msp44x0g y y
171 msp44x8g y y
172 */
173
174/* SCART inputs vs. msp version */
175/* Chip SC1 SC2 SC3 SC4
176 -------------------------
177 msp34x0b y y y n
178 msp34x0c y y y n
179 msp34x0d y y y y
180 msp34x5d y y n n
181 msp34x7d y n n n
182 msp34x0g y y y y
183 msp34x1g y y y y
184 msp34x2g y y y y
185 msp34x5g y y n n
186 msp34x7g y n n n
187 msp44x0g y y y y
188 msp44x8g y y y y
189 */
190
191/* DSP inputs vs. msp version (tuner and SCART inputs are always available) */
192/* Chip I2S1 I2S2 I2S3 MAIN_AVC MAIN AUX
193 ------------------------------------------
194 msp34x0b y n n n n n
195 msp34x0c y y n n n n
196 msp34x0d y y n n n n
197 msp34x5d y y n n n n
198 msp34x7d n n n n n n
199 msp34x0g y y n n n n
200 msp34x1g y y n n n n
201 msp34x2g y y n y y y
202 msp34x5g y y n n n n
203 msp34x7g n n n n n n
204 msp44x0g y y y y y y
205 msp44x8g y y y n n n
206 */
207
208/* DSP outputs vs. msp version */
209/* Chip MAIN AUX SCART1 SCART2 I2S
210 ------------------------------------
211 msp34x0b y y y n y
212 msp34x0c y y y n y
213 msp34x0d y y y y y
214 msp34x5d y n y n y
215 msp34x7d y n y n n
216 msp34x0g y y y y y
217 msp34x1g y y y y y
218 msp34x2g y y y y y
219 msp34x5g y n y n y
220 msp34x7g y n y n n
221 msp44x0g y y y y y
222 msp44x8g y y y y y
223 */
224
225#endif /* MSP3400_H */
226
diff --git a/drivers/media/video/rds.h b/include/media/rds.h
index 0d30eb744e61..951c1ae0be74 100644
--- a/drivers/media/video/rds.h
+++ b/include/media/rds.h
@@ -42,7 +42,3 @@ struct rds_command {
42#define RDS_CMD_POLL _IOR('R',4,int) 42#define RDS_CMD_POLL _IOR('R',4,int)
43 43
44#endif 44#endif
45
46
47
48
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index e5e749e984ee..4507cb61ae93 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,
197void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi); 197void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
198int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf); 198int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
199void saa7146_buffer_timeout(unsigned long data); 199void saa7146_buffer_timeout(unsigned long data);
200void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf); 200void saa7146_dma_free(struct saa7146_dev* dev,struct videobuf_queue *q,
201 struct saa7146_buf *buf);
201 202
202int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv); 203int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv);
203int saa7146_vv_release(struct saa7146_dev* dev); 204int saa7146_vv_release(struct saa7146_dev* dev);
diff --git a/include/media/tvaudio.h b/include/media/tvaudio.h
new file mode 100644
index 000000000000..6915aafc875a
--- /dev/null
+++ b/include/media/tvaudio.h
@@ -0,0 +1,30 @@
1/*
2 tvaudio.h - definition for tvaudio inputs
3
4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _TVAUDIO_H
22#define _TVAUDIO_H
23
24/* The tvaudio module accepts the following inputs: */
25#define TVAUDIO_INPUT_TUNER 0
26#define TVAUDIO_INPUT_RADIO 1
27#define TVAUDIO_INPUT_EXTERN 2
28#define TVAUDIO_INPUT_INTERN 3
29
30#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 2360453e7496..642520acdfa7 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -123,17 +123,6 @@ enum v4l2_chip_ident {
123/* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */ 123/* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */
124#define AUDC_SET_RADIO _IO('d',88) 124#define AUDC_SET_RADIO _IO('d',88)
125 125
126/* select from TV,radio,extern,MUTE, to be replaced with VIDIOC_INT_S_AUDIO_ROUTING */
127#define AUDC_SET_INPUT _IOW('d',89,int)
128
129/* msp3400 ioctl: will be removed in the near future, to be replaced by
130 VIDIOC_INT_S_AUDIO_ROUTING. */
131struct msp_matrix {
132 int input;
133 int output;
134};
135#define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix)
136
137/* tuner ioctls */ 126/* tuner ioctls */
138 127
139/* Sets tuner type and its I2C addr */ 128/* Sets tuner type and its I2C addr */
@@ -209,10 +198,10 @@ struct v4l2_routing {
209}; 198};
210 199
211/* These internal commands should be used to define the inputs and outputs 200/* These internal commands should be used to define the inputs and outputs
212 of an audio/video chip. They will replace AUDC_SET_INPUT. 201 of an audio/video chip. They will replace the v4l2 API commands
213 The v4l2 API commands VIDIOC_S/G_INPUT, VIDIOC_S/G_OUTPUT, 202 VIDIOC_S/G_INPUT, VIDIOC_S/G_OUTPUT, VIDIOC_S/G_AUDIO and VIDIOC_S/G_AUDOUT
214 VIDIOC_S/G_AUDIO and VIDIOC_S/G_AUDOUT are meant to be used by the 203 that are meant to be used by the user.
215 user. Internally these commands should be used to switch inputs/outputs 204 The internal commands should be used to switch inputs/outputs
216 because only the driver knows how to map a 'Television' input to the precise 205 because only the driver knows how to map a 'Television' input to the precise
217 input/output routing of an A/D converter, or a DSP, or a video digitizer. 206 input/output routing of an A/D converter, or a DSP, or a video digitizer.
218 These four commands should only be sent directly to an i2c device, they 207 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 d90dec5484ee..fff3fd0fbf94 100644
--- a/include/media/video-buf.h
+++ b/include/media/video-buf.h
@@ -1,15 +1,20 @@
1/* 1/*
2 * 2 *
3 * generic helper functions for video4linux capture buffers, to handle 3 * generic helper functions for video4linux capture buffers, to handle
4 * memory management and PCI DMA. Right now bttv + saa7134 use it. 4 * memory management and PCI DMA.
5 * Right now, bttv, saa7134, saa7146 and cx88 use it.
5 * 6 *
6 * The functions expect the hardware being able to scatter gatter 7 * The functions expect the hardware being able to scatter gatter
7 * (i.e. the buffers are not linear in physical memory, but fragmented 8 * (i.e. the buffers are not linear in physical memory, but fragmented
8 * into PAGE_SIZE chunks). They also assume the driver does not need 9 * into PAGE_SIZE chunks). They also assume the driver does not need
9 * to touch the video data (thus it is probably not useful for USB as 10 * to touch the video data.
10 * data often must be uncompressed by the drivers). 11 *
12 * device specific map/unmap/sync stuff now are mapped as file operations
13 * to allow its usage by USB and virtual devices.
11 * 14 *
12 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> 15 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
16 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
17 * (c) 2006 Ted Walther and John Sokol
13 * 18 *
14 * This program is free software; you can redistribute it and/or modify 19 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 20 * 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);
38struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages, 43struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
39 int offset); 44 int offset);
40 45
46struct videobuf_buffer;
47struct videobuf_queue;
48
41/* --------------------------------------------------------------------- */ 49/* --------------------------------------------------------------------- */
42 50
43/* 51/*
@@ -49,7 +57,7 @@ struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
49 * pointer + length. The kernel version just wants the size and 57 * pointer + length. The kernel version just wants the size and
50 * does memory allocation too using vmalloc_32(). 58 * does memory allocation too using vmalloc_32().
51 * 59 *
52 * videobuf_dma_pci_*() 60 * videobuf_dma_*()
53 * see Documentation/DMA-mapping.txt, these functions to 61 * see Documentation/DMA-mapping.txt, these functions to
54 * basically the same. The map function does also build a 62 * basically the same. The map function does also build a
55 * scatterlist for the buffer (and unmap frees it ...) 63 * scatterlist for the buffer (and unmap frees it ...)
@@ -86,12 +94,18 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
86 int nr_pages); 94 int nr_pages);
87int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, 95int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
88 dma_addr_t addr, int nr_pages); 96 dma_addr_t addr, int nr_pages);
89int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma);
90int videobuf_dma_pci_sync(struct pci_dev *dev,
91 struct videobuf_dmabuf *dma);
92int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma);
93int videobuf_dma_free(struct videobuf_dmabuf *dma); 97int videobuf_dma_free(struct videobuf_dmabuf *dma);
94 98
99int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
100int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
101int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
102
103 /*FIXME: these variants are used only on *-alsa code, where videobuf is
104 * used without queue
105 */
106int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma);
107int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma);
108
95/* --------------------------------------------------------------------- */ 109/* --------------------------------------------------------------------- */
96 110
97/* 111/*
@@ -115,9 +129,6 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma);
115 * 129 *
116 */ 130 */
117 131
118struct videobuf_buffer;
119struct videobuf_queue;
120
121struct videobuf_mapping { 132struct videobuf_mapping {
122 unsigned int count; 133 unsigned int count;
123 unsigned long start; 134 unsigned long start;
@@ -164,6 +175,10 @@ struct videobuf_buffer {
164 struct timeval ts; 175 struct timeval ts;
165}; 176};
166 177
178typedef int (vb_map_sg_t)(void *dev,struct scatterlist *sglist,int nr_pages,
179 int direction);
180
181
167struct videobuf_queue_ops { 182struct videobuf_queue_ops {
168 int (*buf_setup)(struct videobuf_queue *q, 183 int (*buf_setup)(struct videobuf_queue *q,
169 unsigned int *count, unsigned int *size); 184 unsigned int *count, unsigned int *size);
@@ -174,12 +189,20 @@ struct videobuf_queue_ops {
174 struct videobuf_buffer *vb); 189 struct videobuf_buffer *vb);
175 void (*buf_release)(struct videobuf_queue *q, 190 void (*buf_release)(struct videobuf_queue *q,
176 struct videobuf_buffer *vb); 191 struct videobuf_buffer *vb);
192
193 /* Helper operations - device dependent.
194 * If null, videobuf_init defaults all to PCI handling
195 */
196
197 vb_map_sg_t *vb_map_sg;
198 vb_map_sg_t *vb_dma_sync_sg;
199 vb_map_sg_t *vb_unmap_sg;
177}; 200};
178 201
179struct videobuf_queue { 202struct videobuf_queue {
180 struct mutex lock; 203 struct mutex lock;
181 spinlock_t *irqlock; 204 spinlock_t *irqlock;
182 struct pci_dev *pci; 205 void *dev; /* on pci, points to struct pci_dev */
183 206
184 enum v4l2_buf_type type; 207 enum v4l2_buf_type type;
185 unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ 208 unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */
@@ -204,12 +227,15 @@ struct videobuf_queue {
204 227
205void* videobuf_alloc(unsigned int size); 228void* videobuf_alloc(unsigned int size);
206int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); 229int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
207int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb, 230int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
208 struct v4l2_framebuffer *fbuf); 231 struct v4l2_framebuffer *fbuf);
232
233/* Maps fops to PCI stuff */
234void videobuf_queue_pci(struct videobuf_queue* q);
209 235
210void videobuf_queue_init(struct videobuf_queue *q, 236void videobuf_queue_init(struct videobuf_queue *q,
211 struct videobuf_queue_ops *ops, 237 struct videobuf_queue_ops *ops,
212 struct pci_dev *pci, 238 void *dev,
213 spinlock_t *irqlock, 239 spinlock_t *irqlock,
214 enum v4l2_buf_type type, 240 enum v4l2_buf_type type,
215 enum v4l2_field field, 241 enum v4l2_field field,
diff --git a/include/media/wm8775.h b/include/media/wm8775.h
new file mode 100644
index 000000000000..60739c5a23ae
--- /dev/null
+++ b/include/media/wm8775.h
@@ -0,0 +1,35 @@
1/*
2 wm8775.h - definition for wm8775 inputs and outputs
3
4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _WM8775_H_
22#define _WM8775_H_
23
24/* The WM8775 has 4 inputs and one output. Zero or more inputs
25 are multiplexed together to the output. Hence there are
26 16 combinations.
27 If only one input is active (the normal case) then the
28 input values 1, 2, 4 or 8 should be used. */
29
30#define WM8775_AIN1 1
31#define WM8775_AIN2 2
32#define WM8775_AIN3 4
33#define WM8775_AIN4 8
34
35#endif
diff --git a/include/net/route.h b/include/net/route.h
index 9c04f15090d2..98c915abdec8 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -110,7 +110,7 @@ extern struct ip_rt_acct *ip_rt_acct;
110struct in_device; 110struct in_device;
111extern int ip_rt_init(void); 111extern int ip_rt_init(void);
112extern void ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw, 112extern void ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw,
113 u32 src, u8 tos, struct net_device *dev); 113 u32 src, struct net_device *dev);
114extern void ip_rt_advice(struct rtable **rp, int advice); 114extern void ip_rt_advice(struct rtable **rp, int advice);
115extern void rt_cache_flush(int how); 115extern void rt_cache_flush(int how);
116extern int __ip_route_output_key(struct rtable **, const struct flowi *flp); 116extern int __ip_route_output_key(struct rtable **, const struct flowi *flp);
diff --git a/include/net/sock.h b/include/net/sock.h
index ec226f31dc2a..2aa73c0ec6c2 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -210,6 +210,7 @@ struct sock {
210 gfp_t sk_allocation; 210 gfp_t sk_allocation;
211 int sk_sndbuf; 211 int sk_sndbuf;
212 int sk_route_caps; 212 int sk_route_caps;
213 int sk_rcvlowat;
213 unsigned long sk_flags; 214 unsigned long sk_flags;
214 unsigned long sk_lingertime; 215 unsigned long sk_lingertime;
215 /* 216 /*
@@ -230,7 +231,6 @@ struct sock {
230 unsigned short sk_max_ack_backlog; 231 unsigned short sk_max_ack_backlog;
231 __u32 sk_priority; 232 __u32 sk_priority;
232 struct ucred sk_peercred; 233 struct ucred sk_peercred;
233 int sk_rcvlowat;
234 long sk_rcvtimeo; 234 long sk_rcvtimeo;
235 long sk_sndtimeo; 235 long sk_sndtimeo;
236 struct sk_filter *sk_filter; 236 struct sk_filter *sk_filter;
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index a6cf3e535c0b..dc6862d09e53 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -286,7 +286,7 @@ struct scsi_host_template {
286 * suspend support 286 * suspend support
287 */ 287 */
288 int (*resume)(struct scsi_device *); 288 int (*resume)(struct scsi_device *);
289 int (*suspend)(struct scsi_device *); 289 int (*suspend)(struct scsi_device *, pm_message_t state);
290 290
291 /* 291 /*
292 * Name of proc directory 292 * Name of proc directory
diff --git a/include/sound/opl3.h b/include/sound/opl3.h
index 444907166f97..82fdb0930720 100644
--- a/include/sound/opl3.h
+++ b/include/sound/opl3.h
@@ -230,7 +230,6 @@
230#define OPL3_HW_OPL3_CS 0x0302 /* CS4232/CS4236+ */ 230#define OPL3_HW_OPL3_CS 0x0302 /* CS4232/CS4236+ */
231#define OPL3_HW_OPL3_FM801 0x0303 /* FM801 */ 231#define OPL3_HW_OPL3_FM801 0x0303 /* FM801 */
232#define OPL3_HW_OPL3_CS4281 0x0304 /* CS4281 */ 232#define OPL3_HW_OPL3_CS4281 0x0304 /* CS4281 */
233#define OPL3_HW_OPL3_PC98 0x0305 /* PC9800 */
234#define OPL3_HW_OPL4 0x0400 /* YMF278B/YMF295 */ 233#define OPL3_HW_OPL4 0x0400 /* YMF278B/YMF295 */
235#define OPL3_HW_OPL4_ML 0x0401 /* YMF704/YMF721 */ 234#define OPL3_HW_OPL4_ML 0x0401 /* YMF704/YMF721 */
236#define OPL3_HW_MASK 0xff00 235#define OPL3_HW_MASK 0xff00
diff --git a/include/video/pm3fb.h b/include/video/pm3fb.h
index 6f4ea808cf74..ac021379ac40 100644
--- a/include/video/pm3fb.h
+++ b/include/video/pm3fb.h
@@ -1128,10 +1128,7 @@
1128#endif 1128#endif
1129 1129
1130/* max number of simultaneous board */ 1130/* max number of simultaneous board */
1131/* warning : make sure module array def's are coherent with PM3_MAX_BOARD */
1132#define PM3_MAX_BOARD 4 1131#define PM3_MAX_BOARD 4
1133#define PM3_MAX_BOARD_MODULE_ARRAY_SHORT "1-4h"
1134#define PM3_MAX_BOARD_MODULE_ARRAY_STRING "1-4s"
1135 1132
1136/* max size of options */ 1133/* max size of options */
1137#define PM3_OPTIONS_SIZE 256 1134#define PM3_OPTIONS_SIZE 256
diff --git a/init/Kconfig b/init/Kconfig
index 1d19fd25204b..3b36a1d53656 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -365,43 +365,6 @@ config SHMEM
365 option replaces shmem and tmpfs with the much simpler ramfs code, 365 option replaces shmem and tmpfs with the much simpler ramfs code,
366 which may be appropriate on small systems without swap. 366 which may be appropriate on small systems without swap.
367 367
368config CC_ALIGN_FUNCTIONS
369 int "Function alignment" if EMBEDDED
370 default 0
371 help
372 Align the start of functions to the next power-of-two greater than n,
373 skipping up to n bytes. For instance, 32 aligns functions
374 to the next 32-byte boundary, but 24 would align to the next
375 32-byte boundary only if this can be done by skipping 23 bytes or less.
376 Zero means use compiler's default.
377
378config CC_ALIGN_LABELS
379 int "Label alignment" if EMBEDDED
380 default 0
381 help
382 Align all branch targets to a power-of-two boundary, skipping
383 up to n bytes like ALIGN_FUNCTIONS. This option can easily
384 make code slower, because it must insert dummy operations for
385 when the branch target is reached in the usual flow of the code.
386 Zero means use compiler's default.
387
388config CC_ALIGN_LOOPS
389 int "Loop alignment" if EMBEDDED
390 default 0
391 help
392 Align loops to a power-of-two boundary, skipping up to n bytes.
393 Zero means use compiler's default.
394
395config CC_ALIGN_JUMPS
396 int "Jump alignment" if EMBEDDED
397 default 0
398 help
399 Align branch targets to a power-of-two boundary, for branch
400 targets where the targets can only be reached by jumping,
401 skipping up to n bytes like ALIGN_FUNCTIONS. In this case,
402 no dummy operations need be executed.
403 Zero means use compiler's default.
404
405config SLAB 368config SLAB
406 default y 369 default y
407 bool "Use full SLAB allocator" if EMBEDDED 370 bool "Use full SLAB allocator" if EMBEDDED
@@ -470,15 +433,6 @@ config MODULE_FORCE_UNLOAD
470 rmmod). This is mainly for kernel developers and desperate users. 433 rmmod). This is mainly for kernel developers and desperate users.
471 If unsure, say N. 434 If unsure, say N.
472 435
473config OBSOLETE_MODPARM
474 bool
475 default y
476 depends on MODULES
477 help
478 You need this option to use module parameters on modules which
479 have not been converted to the new module parameter system yet.
480 If unsure, say Y.
481
482config MODVERSIONS 436config MODVERSIONS
483 bool "Module versioning support" 437 bool "Module versioning support"
484 depends on MODULES 438 depends on MODULES
diff --git a/init/do_mounts.c b/init/do_mounts.c
index b27c11064409..8b671fe68afa 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -19,7 +19,7 @@ extern int get_filesystem_list(char * buf);
19 19
20int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */ 20int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */
21 21
22int root_mountflags = MS_RDONLY | MS_VERBOSE; 22int root_mountflags = MS_RDONLY | MS_SILENT;
23char * __initdata root_device_name; 23char * __initdata root_device_name;
24static char __initdata saved_root_name[64]; 24static char __initdata saved_root_name[64];
25 25
diff --git a/init/initramfs.c b/init/initramfs.c
index 637344b05981..77b934cccefe 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -506,6 +506,7 @@ void __init populate_rootfs(void)
506 panic(err); 506 panic(err);
507#ifdef CONFIG_BLK_DEV_INITRD 507#ifdef CONFIG_BLK_DEV_INITRD
508 if (initrd_start) { 508 if (initrd_start) {
509#ifdef CONFIG_BLK_DEV_RAM
509 int fd; 510 int fd;
510 printk(KERN_INFO "checking if image is initramfs..."); 511 printk(KERN_INFO "checking if image is initramfs...");
511 err = unpack_to_rootfs((char *)initrd_start, 512 err = unpack_to_rootfs((char *)initrd_start,
@@ -525,6 +526,15 @@ void __init populate_rootfs(void)
525 sys_close(fd); 526 sys_close(fd);
526 free_initrd(); 527 free_initrd();
527 } 528 }
529#else
530 printk(KERN_INFO "Unpacking initramfs...");
531 err = unpack_to_rootfs((char *)initrd_start,
532 initrd_end - initrd_start, 0);
533 if (err)
534 panic(err);
535 printk(" done\n");
536 free_initrd();
537#endif
528 } 538 }
529#endif 539#endif
530} 540}
diff --git a/init/main.c b/init/main.c
index 2714e0e7cfec..006dcd547dc2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -306,8 +306,6 @@ static int __init rdinit_setup(char *str)
306} 306}
307__setup("rdinit=", rdinit_setup); 307__setup("rdinit=", rdinit_setup);
308 308
309extern void setup_arch(char **);
310
311#ifndef CONFIG_SMP 309#ifndef CONFIG_SMP
312 310
313#ifdef CONFIG_X86_LOCAL_APIC 311#ifdef CONFIG_X86_LOCAL_APIC
@@ -571,17 +569,23 @@ static void __init do_initcalls(void)
571 int count = preempt_count(); 569 int count = preempt_count();
572 570
573 for (call = __initcall_start; call < __initcall_end; call++) { 571 for (call = __initcall_start; call < __initcall_end; call++) {
574 char *msg; 572 char *msg = NULL;
573 char msgbuf[40];
574 int result;
575 575
576 if (initcall_debug) { 576 if (initcall_debug) {
577 printk(KERN_DEBUG "Calling initcall 0x%p", *call); 577 printk("Calling initcall 0x%p", *call);
578 print_fn_descriptor_symbol(": %s()", (unsigned long) *call); 578 print_fn_descriptor_symbol(": %s()",
579 (unsigned long) *call);
579 printk("\n"); 580 printk("\n");
580 } 581 }
581 582
582 (*call)(); 583 result = (*call)();
583 584
584 msg = NULL; 585 if (result && (result != -ENODEV || initcall_debug)) {
586 sprintf(msgbuf, "error code %d", result);
587 msg = msgbuf;
588 }
585 if (preempt_count() != count) { 589 if (preempt_count() != count) {
586 msg = "preemption imbalance"; 590 msg = "preemption imbalance";
587 preempt_count() = count; 591 preempt_count() = count;
@@ -591,8 +595,10 @@ static void __init do_initcalls(void)
591 local_irq_enable(); 595 local_irq_enable();
592 } 596 }
593 if (msg) { 597 if (msg) {
594 printk(KERN_WARNING "error in initcall at 0x%p: " 598 printk(KERN_WARNING "initcall at 0x%p", *call);
595 "returned with %s\n", *call, msg); 599 print_fn_descriptor_symbol(": %s()",
600 (unsigned long) *call);
601 printk(": returned with %s\n", msg);
596 } 602 }
597 } 603 }
598 604
diff --git a/ipc/msg.c b/ipc/msg.c
index fbf757064a32..60c1e5c23418 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -220,8 +220,7 @@ asmlinkage long sys_msgget (key_t key, int msgflg)
220 ret = -EEXIST; 220 ret = -EEXIST;
221 } else { 221 } else {
222 msq = msg_lock(id); 222 msq = msg_lock(id);
223 if(msq==NULL) 223 BUG_ON(msq==NULL);
224 BUG();
225 if (ipcperms(&msq->q_perm, msgflg)) 224 if (ipcperms(&msq->q_perm, msgflg))
226 ret = -EACCES; 225 ret = -EACCES;
227 else { 226 else {
diff --git a/ipc/shm.c b/ipc/shm.c
index 9162123a7b23..16fe2786087d 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -814,6 +814,9 @@ asmlinkage long sys_shmdt(char __user *shmaddr)
814 loff_t size = 0; 814 loff_t size = 0;
815 int retval = -EINVAL; 815 int retval = -EINVAL;
816 816
817 if (addr & ~PAGE_MASK)
818 return retval;
819
817 down_write(&mm->mmap_sem); 820 down_write(&mm->mmap_sem);
818 821
819 /* 822 /*
diff --git a/kernel/capability.c b/kernel/capability.c
index bfa3c92e16f2..1a4d8a40d3f9 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -233,3 +233,19 @@ out:
233 233
234 return ret; 234 return ret;
235} 235}
236
237int __capable(struct task_struct *t, int cap)
238{
239 if (security_capable(t, cap) == 0) {
240 t->flags |= PF_SUPERPRIV;
241 return 1;
242 }
243 return 0;
244}
245EXPORT_SYMBOL(__capable);
246
247int capable(int cap)
248{
249 return __capable(current, cap);
250}
251EXPORT_SYMBOL(capable);
diff --git a/kernel/cpu.c b/kernel/cpu.c
index e882c6babf41..8be22bd80933 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -223,8 +223,7 @@ int __devinit cpu_up(unsigned int cpu)
223 ret = __cpu_up(cpu); 223 ret = __cpu_up(cpu);
224 if (ret != 0) 224 if (ret != 0)
225 goto out_notify; 225 goto out_notify;
226 if (!cpu_online(cpu)) 226 BUG_ON(!cpu_online(cpu));
227 BUG();
228 227
229 /* Now call notifier in preparation. */ 228 /* Now call notifier in preparation. */
230 notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu); 229 notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index c86ee051b734..18aea1bd1284 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -4,15 +4,14 @@
4 * Processor and Memory placement constraints for sets of tasks. 4 * Processor and Memory placement constraints for sets of tasks.
5 * 5 *
6 * Copyright (C) 2003 BULL SA. 6 * Copyright (C) 2003 BULL SA.
7 * Copyright (C) 2004 Silicon Graphics, Inc. 7 * Copyright (C) 2004-2006 Silicon Graphics, Inc.
8 * 8 *
9 * Portions derived from Patrick Mochel's sysfs code. 9 * Portions derived from Patrick Mochel's sysfs code.
10 * sysfs is Copyright (c) 2001-3 Patrick Mochel 10 * sysfs is Copyright (c) 2001-3 Patrick Mochel
11 * Portions Copyright (c) 2004 Silicon Graphics, Inc.
12 * 11 *
13 * 2003-10-10 Written by Simon Derr <simon.derr@bull.net> 12 * 2003-10-10 Written by Simon Derr.
14 * 2003-10-22 Updates by Stephen Hemminger. 13 * 2003-10-22 Updates by Stephen Hemminger.
15 * 2004 May-July Rework by Paul Jackson <pj@sgi.com> 14 * 2004 May-July Rework by Paul Jackson.
16 * 15 *
17 * This file is subject to the terms and conditions of the GNU General Public 16 * This file is subject to the terms and conditions of the GNU General Public
18 * License. See the file COPYING in the main directory of the Linux 17 * License. See the file COPYING in the main directory of the Linux
@@ -108,37 +107,49 @@ typedef enum {
108 CS_MEM_EXCLUSIVE, 107 CS_MEM_EXCLUSIVE,
109 CS_MEMORY_MIGRATE, 108 CS_MEMORY_MIGRATE,
110 CS_REMOVED, 109 CS_REMOVED,
111 CS_NOTIFY_ON_RELEASE 110 CS_NOTIFY_ON_RELEASE,
111 CS_SPREAD_PAGE,
112 CS_SPREAD_SLAB,
112} cpuset_flagbits_t; 113} cpuset_flagbits_t;
113 114
114/* convenient tests for these bits */ 115/* convenient tests for these bits */
115static inline int is_cpu_exclusive(const struct cpuset *cs) 116static inline int is_cpu_exclusive(const struct cpuset *cs)
116{ 117{
117 return !!test_bit(CS_CPU_EXCLUSIVE, &cs->flags); 118 return test_bit(CS_CPU_EXCLUSIVE, &cs->flags);
118} 119}
119 120
120static inline int is_mem_exclusive(const struct cpuset *cs) 121static inline int is_mem_exclusive(const struct cpuset *cs)
121{ 122{
122 return !!test_bit(CS_MEM_EXCLUSIVE, &cs->flags); 123 return test_bit(CS_MEM_EXCLUSIVE, &cs->flags);
123} 124}
124 125
125static inline int is_removed(const struct cpuset *cs) 126static inline int is_removed(const struct cpuset *cs)
126{ 127{
127 return !!test_bit(CS_REMOVED, &cs->flags); 128 return test_bit(CS_REMOVED, &cs->flags);
128} 129}
129 130
130static inline int notify_on_release(const struct cpuset *cs) 131static inline int notify_on_release(const struct cpuset *cs)
131{ 132{
132 return !!test_bit(CS_NOTIFY_ON_RELEASE, &cs->flags); 133 return test_bit(CS_NOTIFY_ON_RELEASE, &cs->flags);
133} 134}
134 135
135static inline int is_memory_migrate(const struct cpuset *cs) 136static inline int is_memory_migrate(const struct cpuset *cs)
136{ 137{
137 return !!test_bit(CS_MEMORY_MIGRATE, &cs->flags); 138 return test_bit(CS_MEMORY_MIGRATE, &cs->flags);
139}
140
141static inline int is_spread_page(const struct cpuset *cs)
142{
143 return test_bit(CS_SPREAD_PAGE, &cs->flags);
144}
145
146static inline int is_spread_slab(const struct cpuset *cs)
147{
148 return test_bit(CS_SPREAD_SLAB, &cs->flags);
138} 149}
139 150
140/* 151/*
141 * Increment this atomic integer everytime any cpuset changes its 152 * Increment this integer everytime any cpuset changes its
142 * mems_allowed value. Users of cpusets can track this generation 153 * mems_allowed value. Users of cpusets can track this generation
143 * number, and avoid having to lock and reload mems_allowed unless 154 * number, and avoid having to lock and reload mems_allowed unless
144 * the cpuset they're using changes generation. 155 * the cpuset they're using changes generation.
@@ -152,8 +163,11 @@ static inline int is_memory_migrate(const struct cpuset *cs)
152 * on every visit to __alloc_pages(), to efficiently check whether 163 * on every visit to __alloc_pages(), to efficiently check whether
153 * its current->cpuset->mems_allowed has changed, requiring an update 164 * its current->cpuset->mems_allowed has changed, requiring an update
154 * of its current->mems_allowed. 165 * of its current->mems_allowed.
166 *
167 * Since cpuset_mems_generation is guarded by manage_mutex,
168 * there is no need to mark it atomic.
155 */ 169 */
156static atomic_t cpuset_mems_generation = ATOMIC_INIT(1); 170static int cpuset_mems_generation;
157 171
158static struct cpuset top_cpuset = { 172static struct cpuset top_cpuset = {
159 .flags = ((1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)), 173 .flags = ((1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)),
@@ -657,6 +671,14 @@ void cpuset_update_task_memory_state(void)
657 cs = tsk->cpuset; /* Maybe changed when task not locked */ 671 cs = tsk->cpuset; /* Maybe changed when task not locked */
658 guarantee_online_mems(cs, &tsk->mems_allowed); 672 guarantee_online_mems(cs, &tsk->mems_allowed);
659 tsk->cpuset_mems_generation = cs->mems_generation; 673 tsk->cpuset_mems_generation = cs->mems_generation;
674 if (is_spread_page(cs))
675 tsk->flags |= PF_SPREAD_PAGE;
676 else
677 tsk->flags &= ~PF_SPREAD_PAGE;
678 if (is_spread_slab(cs))
679 tsk->flags |= PF_SPREAD_SLAB;
680 else
681 tsk->flags &= ~PF_SPREAD_SLAB;
660 task_unlock(tsk); 682 task_unlock(tsk);
661 mutex_unlock(&callback_mutex); 683 mutex_unlock(&callback_mutex);
662 mpol_rebind_task(tsk, &tsk->mems_allowed); 684 mpol_rebind_task(tsk, &tsk->mems_allowed);
@@ -858,8 +880,7 @@ static int update_nodemask(struct cpuset *cs, char *buf)
858 880
859 mutex_lock(&callback_mutex); 881 mutex_lock(&callback_mutex);
860 cs->mems_allowed = trialcs.mems_allowed; 882 cs->mems_allowed = trialcs.mems_allowed;
861 atomic_inc(&cpuset_mems_generation); 883 cs->mems_generation = cpuset_mems_generation++;
862 cs->mems_generation = atomic_read(&cpuset_mems_generation);
863 mutex_unlock(&callback_mutex); 884 mutex_unlock(&callback_mutex);
864 885
865 set_cpuset_being_rebound(cs); /* causes mpol_copy() rebind */ 886 set_cpuset_being_rebound(cs); /* causes mpol_copy() rebind */
@@ -957,7 +978,8 @@ static int update_memory_pressure_enabled(struct cpuset *cs, char *buf)
957/* 978/*
958 * update_flag - read a 0 or a 1 in a file and update associated flag 979 * update_flag - read a 0 or a 1 in a file and update associated flag
959 * bit: the bit to update (CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE, 980 * bit: the bit to update (CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE,
960 * CS_NOTIFY_ON_RELEASE, CS_MEMORY_MIGRATE) 981 * CS_NOTIFY_ON_RELEASE, CS_MEMORY_MIGRATE,
982 * CS_SPREAD_PAGE, CS_SPREAD_SLAB)
961 * cs: the cpuset to update 983 * cs: the cpuset to update
962 * buf: the buffer where we read the 0 or 1 984 * buf: the buffer where we read the 0 or 1
963 * 985 *
@@ -1188,6 +1210,8 @@ typedef enum {
1188 FILE_NOTIFY_ON_RELEASE, 1210 FILE_NOTIFY_ON_RELEASE,
1189 FILE_MEMORY_PRESSURE_ENABLED, 1211 FILE_MEMORY_PRESSURE_ENABLED,
1190 FILE_MEMORY_PRESSURE, 1212 FILE_MEMORY_PRESSURE,
1213 FILE_SPREAD_PAGE,
1214 FILE_SPREAD_SLAB,
1191 FILE_TASKLIST, 1215 FILE_TASKLIST,
1192} cpuset_filetype_t; 1216} cpuset_filetype_t;
1193 1217
@@ -1247,6 +1271,14 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
1247 case FILE_MEMORY_PRESSURE: 1271 case FILE_MEMORY_PRESSURE:
1248 retval = -EACCES; 1272 retval = -EACCES;
1249 break; 1273 break;
1274 case FILE_SPREAD_PAGE:
1275 retval = update_flag(CS_SPREAD_PAGE, cs, buffer);
1276 cs->mems_generation = cpuset_mems_generation++;
1277 break;
1278 case FILE_SPREAD_SLAB:
1279 retval = update_flag(CS_SPREAD_SLAB, cs, buffer);
1280 cs->mems_generation = cpuset_mems_generation++;
1281 break;
1250 case FILE_TASKLIST: 1282 case FILE_TASKLIST:
1251 retval = attach_task(cs, buffer, &pathbuf); 1283 retval = attach_task(cs, buffer, &pathbuf);
1252 break; 1284 break;
@@ -1356,6 +1388,12 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
1356 case FILE_MEMORY_PRESSURE: 1388 case FILE_MEMORY_PRESSURE:
1357 s += sprintf(s, "%d", fmeter_getrate(&cs->fmeter)); 1389 s += sprintf(s, "%d", fmeter_getrate(&cs->fmeter));
1358 break; 1390 break;
1391 case FILE_SPREAD_PAGE:
1392 *s++ = is_spread_page(cs) ? '1' : '0';
1393 break;
1394 case FILE_SPREAD_SLAB:
1395 *s++ = is_spread_slab(cs) ? '1' : '0';
1396 break;
1359 default: 1397 default:
1360 retval = -EINVAL; 1398 retval = -EINVAL;
1361 goto out; 1399 goto out;
@@ -1719,6 +1757,16 @@ static struct cftype cft_memory_pressure = {
1719 .private = FILE_MEMORY_PRESSURE, 1757 .private = FILE_MEMORY_PRESSURE,
1720}; 1758};
1721 1759
1760static struct cftype cft_spread_page = {
1761 .name = "memory_spread_page",
1762 .private = FILE_SPREAD_PAGE,
1763};
1764
1765static struct cftype cft_spread_slab = {
1766 .name = "memory_spread_slab",
1767 .private = FILE_SPREAD_SLAB,
1768};
1769
1722static int cpuset_populate_dir(struct dentry *cs_dentry) 1770static int cpuset_populate_dir(struct dentry *cs_dentry)
1723{ 1771{
1724 int err; 1772 int err;
@@ -1737,6 +1785,10 @@ static int cpuset_populate_dir(struct dentry *cs_dentry)
1737 return err; 1785 return err;
1738 if ((err = cpuset_add_file(cs_dentry, &cft_memory_pressure)) < 0) 1786 if ((err = cpuset_add_file(cs_dentry, &cft_memory_pressure)) < 0)
1739 return err; 1787 return err;
1788 if ((err = cpuset_add_file(cs_dentry, &cft_spread_page)) < 0)
1789 return err;
1790 if ((err = cpuset_add_file(cs_dentry, &cft_spread_slab)) < 0)
1791 return err;
1740 if ((err = cpuset_add_file(cs_dentry, &cft_tasks)) < 0) 1792 if ((err = cpuset_add_file(cs_dentry, &cft_tasks)) < 0)
1741 return err; 1793 return err;
1742 return 0; 1794 return 0;
@@ -1765,13 +1817,16 @@ static long cpuset_create(struct cpuset *parent, const char *name, int mode)
1765 cs->flags = 0; 1817 cs->flags = 0;
1766 if (notify_on_release(parent)) 1818 if (notify_on_release(parent))
1767 set_bit(CS_NOTIFY_ON_RELEASE, &cs->flags); 1819 set_bit(CS_NOTIFY_ON_RELEASE, &cs->flags);
1820 if (is_spread_page(parent))
1821 set_bit(CS_SPREAD_PAGE, &cs->flags);
1822 if (is_spread_slab(parent))
1823 set_bit(CS_SPREAD_SLAB, &cs->flags);
1768 cs->cpus_allowed = CPU_MASK_NONE; 1824 cs->cpus_allowed = CPU_MASK_NONE;
1769 cs->mems_allowed = NODE_MASK_NONE; 1825 cs->mems_allowed = NODE_MASK_NONE;
1770 atomic_set(&cs->count, 0); 1826 atomic_set(&cs->count, 0);
1771 INIT_LIST_HEAD(&cs->sibling); 1827 INIT_LIST_HEAD(&cs->sibling);
1772 INIT_LIST_HEAD(&cs->children); 1828 INIT_LIST_HEAD(&cs->children);
1773 atomic_inc(&cpuset_mems_generation); 1829 cs->mems_generation = cpuset_mems_generation++;
1774 cs->mems_generation = atomic_read(&cpuset_mems_generation);
1775 fmeter_init(&cs->fmeter); 1830 fmeter_init(&cs->fmeter);
1776 1831
1777 cs->parent = parent; 1832 cs->parent = parent;
@@ -1861,7 +1916,7 @@ int __init cpuset_init_early(void)
1861 struct task_struct *tsk = current; 1916 struct task_struct *tsk = current;
1862 1917
1863 tsk->cpuset = &top_cpuset; 1918 tsk->cpuset = &top_cpuset;
1864 tsk->cpuset->mems_generation = atomic_read(&cpuset_mems_generation); 1919 tsk->cpuset->mems_generation = cpuset_mems_generation++;
1865 return 0; 1920 return 0;
1866} 1921}
1867 1922
@@ -1880,8 +1935,7 @@ int __init cpuset_init(void)
1880 top_cpuset.mems_allowed = NODE_MASK_ALL; 1935 top_cpuset.mems_allowed = NODE_MASK_ALL;
1881 1936
1882 fmeter_init(&top_cpuset.fmeter); 1937 fmeter_init(&top_cpuset.fmeter);
1883 atomic_inc(&cpuset_mems_generation); 1938 top_cpuset.mems_generation = cpuset_mems_generation++;
1884 top_cpuset.mems_generation = atomic_read(&cpuset_mems_generation);
1885 1939
1886 init_task.cpuset = &top_cpuset; 1940 init_task.cpuset = &top_cpuset;
1887 1941
@@ -1972,7 +2026,7 @@ void cpuset_fork(struct task_struct *child)
1972 * because tsk is already marked PF_EXITING, so attach_task() won't 2026 * because tsk is already marked PF_EXITING, so attach_task() won't
1973 * mess with it, or task is a failed fork, never visible to attach_task. 2027 * mess with it, or task is a failed fork, never visible to attach_task.
1974 * 2028 *
1975 * Hack: 2029 * the_top_cpuset_hack:
1976 * 2030 *
1977 * Set the exiting tasks cpuset to the root cpuset (top_cpuset). 2031 * Set the exiting tasks cpuset to the root cpuset (top_cpuset).
1978 * 2032 *
@@ -2011,7 +2065,7 @@ void cpuset_exit(struct task_struct *tsk)
2011 struct cpuset *cs; 2065 struct cpuset *cs;
2012 2066
2013 cs = tsk->cpuset; 2067 cs = tsk->cpuset;
2014 tsk->cpuset = &top_cpuset; /* Hack - see comment above */ 2068 tsk->cpuset = &top_cpuset; /* the_top_cpuset_hack - see above */
2015 2069
2016 if (notify_on_release(cs)) { 2070 if (notify_on_release(cs)) {
2017 char *pathbuf = NULL; 2071 char *pathbuf = NULL;
@@ -2151,7 +2205,7 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
2151{ 2205{
2152 int node; /* node that zone z is on */ 2206 int node; /* node that zone z is on */
2153 const struct cpuset *cs; /* current cpuset ancestors */ 2207 const struct cpuset *cs; /* current cpuset ancestors */
2154 int allowed = 1; /* is allocation in zone z allowed? */ 2208 int allowed; /* is allocation in zone z allowed? */
2155 2209
2156 if (in_interrupt()) 2210 if (in_interrupt())
2157 return 1; 2211 return 1;
@@ -2204,6 +2258,44 @@ void cpuset_unlock(void)
2204} 2258}
2205 2259
2206/** 2260/**
2261 * cpuset_mem_spread_node() - On which node to begin search for a page
2262 *
2263 * If a task is marked PF_SPREAD_PAGE or PF_SPREAD_SLAB (as for
2264 * tasks in a cpuset with is_spread_page or is_spread_slab set),
2265 * and if the memory allocation used cpuset_mem_spread_node()
2266 * to determine on which node to start looking, as it will for
2267 * certain page cache or slab cache pages such as used for file
2268 * system buffers and inode caches, then instead of starting on the
2269 * local node to look for a free page, rather spread the starting
2270 * node around the tasks mems_allowed nodes.
2271 *
2272 * We don't have to worry about the returned node being offline
2273 * because "it can't happen", and even if it did, it would be ok.
2274 *
2275 * The routines calling guarantee_online_mems() are careful to
2276 * only set nodes in task->mems_allowed that are online. So it
2277 * should not be possible for the following code to return an
2278 * offline node. But if it did, that would be ok, as this routine
2279 * is not returning the node where the allocation must be, only
2280 * the node where the search should start. The zonelist passed to
2281 * __alloc_pages() will include all nodes. If the slab allocator
2282 * is passed an offline node, it will fall back to the local node.
2283 * See kmem_cache_alloc_node().
2284 */
2285
2286int cpuset_mem_spread_node(void)
2287{
2288 int node;
2289
2290 node = next_node(current->cpuset_mem_spread_rotor, current->mems_allowed);
2291 if (node == MAX_NUMNODES)
2292 node = first_node(current->mems_allowed);
2293 current->cpuset_mem_spread_rotor = node;
2294 return node;
2295}
2296EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);
2297
2298/**
2207 * cpuset_excl_nodes_overlap - Do we overlap @p's mem_exclusive ancestors? 2299 * cpuset_excl_nodes_overlap - Do we overlap @p's mem_exclusive ancestors?
2208 * @p: pointer to task_struct of some other task. 2300 * @p: pointer to task_struct of some other task.
2209 * 2301 *
@@ -2284,12 +2376,12 @@ void __cpuset_memory_pressure_bump(void)
2284 * - No need to task_lock(tsk) on this tsk->cpuset reference, as it 2376 * - No need to task_lock(tsk) on this tsk->cpuset reference, as it
2285 * doesn't really matter if tsk->cpuset changes after we read it, 2377 * doesn't really matter if tsk->cpuset changes after we read it,
2286 * and we take manage_mutex, keeping attach_task() from changing it 2378 * and we take manage_mutex, keeping attach_task() from changing it
2287 * anyway. 2379 * anyway. No need to check that tsk->cpuset != NULL, thanks to
2380 * the_top_cpuset_hack in cpuset_exit(), which sets an exiting tasks
2381 * cpuset to top_cpuset.
2288 */ 2382 */
2289
2290static int proc_cpuset_show(struct seq_file *m, void *v) 2383static int proc_cpuset_show(struct seq_file *m, void *v)
2291{ 2384{
2292 struct cpuset *cs;
2293 struct task_struct *tsk; 2385 struct task_struct *tsk;
2294 char *buf; 2386 char *buf;
2295 int retval = 0; 2387 int retval = 0;
@@ -2300,13 +2392,7 @@ static int proc_cpuset_show(struct seq_file *m, void *v)
2300 2392
2301 tsk = m->private; 2393 tsk = m->private;
2302 mutex_lock(&manage_mutex); 2394 mutex_lock(&manage_mutex);
2303 cs = tsk->cpuset; 2395 retval = cpuset_path(tsk->cpuset, buf, PAGE_SIZE);
2304 if (!cs) {
2305 retval = -EINVAL;
2306 goto out;
2307 }
2308
2309 retval = cpuset_path(cs, buf, PAGE_SIZE);
2310 if (retval < 0) 2396 if (retval < 0)
2311 goto out; 2397 goto out;
2312 seq_puts(m, buf); 2398 seq_puts(m, buf);
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index 867d6dbeb574..c01cead2cfd6 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -140,6 +140,7 @@ __set_personality(u_long personality)
140 ep = lookup_exec_domain(personality); 140 ep = lookup_exec_domain(personality);
141 if (ep == current_thread_info()->exec_domain) { 141 if (ep == current_thread_info()->exec_domain) {
142 current->personality = personality; 142 current->personality = personality;
143 module_put(ep->module);
143 return 0; 144 return 0;
144 } 145 }
145 146
diff --git a/kernel/fork.c b/kernel/fork.c
index c21bae8c93b9..a02063903aaa 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1021,6 +1021,7 @@ static task_t *copy_process(unsigned long clone_flags,
1021 p->mempolicy = NULL; 1021 p->mempolicy = NULL;
1022 goto bad_fork_cleanup_cpuset; 1022 goto bad_fork_cleanup_cpuset;
1023 } 1023 }
1024 mpol_fix_fork_child_flag(p);
1024#endif 1025#endif
1025 1026
1026#ifdef CONFIG_DEBUG_MUTEXES 1027#ifdef CONFIG_DEBUG_MUTEXES
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile
index 49378738ff5e..2b33f852be3e 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -1,5 +1,4 @@
1 1
2obj-y := handle.o manage.o spurious.o 2obj-y := handle.o manage.o spurious.o migration.o
3obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o 3obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
4obj-$(CONFIG_PROC_FS) += proc.o 4obj-$(CONFIG_PROC_FS) += proc.o
5
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 97d5559997d2..6edfcef291e8 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -204,10 +204,14 @@ int setup_irq(unsigned int irq, struct irqaction * new)
204 p = &desc->action; 204 p = &desc->action;
205 if ((old = *p) != NULL) { 205 if ((old = *p) != NULL) {
206 /* Can't share interrupts unless both agree to */ 206 /* Can't share interrupts unless both agree to */
207 if (!(old->flags & new->flags & SA_SHIRQ)) { 207 if (!(old->flags & new->flags & SA_SHIRQ))
208 spin_unlock_irqrestore(&desc->lock,flags); 208 goto mismatch;
209 return -EBUSY; 209
210 } 210#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
211 /* All handlers must agree on per-cpuness */
212 if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
213 goto mismatch;
214#endif
211 215
212 /* add new interrupt at end of irq queue */ 216 /* add new interrupt at end of irq queue */
213 do { 217 do {
@@ -218,7 +222,10 @@ int setup_irq(unsigned int irq, struct irqaction * new)
218 } 222 }
219 223
220 *p = new; 224 *p = new;
221 225#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
226 if (new->flags & SA_PERCPU_IRQ)
227 desc->status |= IRQ_PER_CPU;
228#endif
222 if (!shared) { 229 if (!shared) {
223 desc->depth = 0; 230 desc->depth = 0;
224 desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | 231 desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
@@ -236,6 +243,12 @@ int setup_irq(unsigned int irq, struct irqaction * new)
236 register_handler_proc(irq, new); 243 register_handler_proc(irq, new);
237 244
238 return 0; 245 return 0;
246
247mismatch:
248 spin_unlock_irqrestore(&desc->lock, flags);
249 printk(KERN_ERR "%s: irq handler mismatch\n", __FUNCTION__);
250 dump_stack();
251 return -EBUSY;
239} 252}
240 253
241/** 254/**
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
new file mode 100644
index 000000000000..52a8655fa080
--- /dev/null
+++ b/kernel/irq/migration.c
@@ -0,0 +1,65 @@
1#include <linux/irq.h>
2
3#if defined(CONFIG_GENERIC_PENDING_IRQ)
4
5void set_pending_irq(unsigned int irq, cpumask_t mask)
6{
7 irq_desc_t *desc = irq_desc + irq;
8 unsigned long flags;
9
10 spin_lock_irqsave(&desc->lock, flags);
11 desc->move_irq = 1;
12 pending_irq_cpumask[irq] = mask;
13 spin_unlock_irqrestore(&desc->lock, flags);
14}
15
16void move_native_irq(int irq)
17{
18 cpumask_t tmp;
19 irq_desc_t *desc = irq_descp(irq);
20
21 if (likely(!desc->move_irq))
22 return;
23
24 /*
25 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
26 */
27 if (CHECK_IRQ_PER_CPU(desc->status)) {
28 WARN_ON(1);
29 return;
30 }
31
32 desc->move_irq = 0;
33
34 if (likely(cpus_empty(pending_irq_cpumask[irq])))
35 return;
36
37 if (!desc->handler->set_affinity)
38 return;
39
40 assert_spin_locked(&desc->lock);
41
42 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
43
44 /*
45 * If there was a valid mask to work with, please
46 * do the disable, re-program, enable sequence.
47 * This is *not* particularly important for level triggered
48 * but in a edge trigger case, we might be setting rte
49 * when an active trigger is comming in. This could
50 * cause some ioapics to mal-function.
51 * Being paranoid i guess!
52 */
53 if (unlikely(!cpus_empty(tmp))) {
54 if (likely(!(desc->status & IRQ_DISABLED)))
55 desc->handler->disable(irq);
56
57 desc->handler->set_affinity(irq,tmp);
58
59 if (likely(!(desc->status & IRQ_DISABLED)))
60 desc->handler->enable(irq);
61 }
62 cpus_clear(pending_irq_cpumask[irq]);
63}
64
65#endif
diff --git a/kernel/itimer.c b/kernel/itimer.c
index 379be2f8c84c..680e6b70c872 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -143,6 +143,60 @@ int it_real_fn(void *data)
143 return HRTIMER_NORESTART; 143 return HRTIMER_NORESTART;
144} 144}
145 145
146/*
147 * We do not care about correctness. We just sanitize the values so
148 * the ktime_t operations which expect normalized values do not
149 * break. This converts negative values to long timeouts similar to
150 * the code in kernel versions < 2.6.16
151 *
152 * Print a limited number of warning messages when an invalid timeval
153 * is detected.
154 */
155static void fixup_timeval(struct timeval *tv, int interval)
156{
157 static int warnlimit = 10;
158 unsigned long tmp;
159
160 if (warnlimit > 0) {
161 warnlimit--;
162 printk(KERN_WARNING
163 "setitimer: %s (pid = %d) provided "
164 "invalid timeval %s: tv_sec = %ld tv_usec = %ld\n",
165 current->comm, current->pid,
166 interval ? "it_interval" : "it_value",
167 tv->tv_sec, (long) tv->tv_usec);
168 }
169
170 tmp = tv->tv_usec;
171 if (tmp >= USEC_PER_SEC) {
172 tv->tv_usec = tmp % USEC_PER_SEC;
173 tv->tv_sec += tmp / USEC_PER_SEC;
174 }
175
176 tmp = tv->tv_sec;
177 if (tmp > LONG_MAX)
178 tv->tv_sec = LONG_MAX;
179}
180
181/*
182 * Returns true if the timeval is in canonical form
183 */
184#define timeval_valid(t) \
185 (((t)->tv_sec >= 0) && (((unsigned long) (t)->tv_usec) < USEC_PER_SEC))
186
187/*
188 * Check for invalid timevals, sanitize them and print a limited
189 * number of warnings.
190 */
191static void check_itimerval(struct itimerval *value) {
192
193 if (unlikely(!timeval_valid(&value->it_value)))
194 fixup_timeval(&value->it_value, 0);
195
196 if (unlikely(!timeval_valid(&value->it_interval)))
197 fixup_timeval(&value->it_interval, 1);
198}
199
146int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue) 200int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
147{ 201{
148 struct task_struct *tsk = current; 202 struct task_struct *tsk = current;
@@ -150,6 +204,18 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
150 ktime_t expires; 204 ktime_t expires;
151 cputime_t cval, cinterval, nval, ninterval; 205 cputime_t cval, cinterval, nval, ninterval;
152 206
207 /*
208 * Validate the timevals in value.
209 *
210 * Note: Although the spec requires that invalid values shall
211 * return -EINVAL, we just fixup the value and print a limited
212 * number of warnings in order not to break users of this
213 * historical misfeature.
214 *
215 * Scheduled for replacement in March 2007
216 */
217 check_itimerval(value);
218
153 switch (which) { 219 switch (which) {
154 case ITIMER_REAL: 220 case ITIMER_REAL:
155again: 221again:
@@ -226,6 +292,43 @@ again:
226 return 0; 292 return 0;
227} 293}
228 294
295/**
296 * alarm_setitimer - set alarm in seconds
297 *
298 * @seconds: number of seconds until alarm
299 * 0 disables the alarm
300 *
301 * Returns the remaining time in seconds of a pending timer or 0 when
302 * the timer is not active.
303 *
304 * On 32 bit machines the seconds value is limited to (INT_MAX/2) to avoid
305 * negative timeval settings which would cause immediate expiry.
306 */
307unsigned int alarm_setitimer(unsigned int seconds)
308{
309 struct itimerval it_new, it_old;
310
311#if BITS_PER_LONG < 64
312 if (seconds > INT_MAX)
313 seconds = INT_MAX;
314#endif
315 it_new.it_value.tv_sec = seconds;
316 it_new.it_value.tv_usec = 0;
317 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
318
319 do_setitimer(ITIMER_REAL, &it_new, &it_old);
320
321 /*
322 * We can't return 0 if we have an alarm pending ... And we'd
323 * better return too much than too little anyway
324 */
325 if ((!it_old.it_value.tv_sec && it_old.it_value.tv_usec) ||
326 it_old.it_value.tv_usec >= 500000)
327 it_old.it_value.tv_sec++;
328
329 return it_old.it_value.tv_sec;
330}
331
229asmlinkage long sys_setitimer(int which, 332asmlinkage long sys_setitimer(int which,
230 struct itimerval __user *value, 333 struct itimerval __user *value,
231 struct itimerval __user *ovalue) 334 struct itimerval __user *ovalue)
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index f2690ed74530..f119e098e67b 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -22,7 +22,7 @@ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
22static struct subsys_attribute _name##_attr = \ 22static struct subsys_attribute _name##_attr = \
23 __ATTR(_name, 0644, _name##_show, _name##_store) 23 __ATTR(_name, 0644, _name##_show, _name##_store)
24 24
25#ifdef CONFIG_HOTPLUG 25#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
26/* current uevent sequence number */ 26/* current uevent sequence number */
27static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page) 27static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page)
28{ 28{
@@ -52,7 +52,7 @@ decl_subsys(kernel, NULL, NULL);
52EXPORT_SYMBOL_GPL(kernel_subsys); 52EXPORT_SYMBOL_GPL(kernel_subsys);
53 53
54static struct attribute * kernel_attrs[] = { 54static struct attribute * kernel_attrs[] = {
55#ifdef CONFIG_HOTPLUG 55#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
56 &uevent_seqnum_attr.attr, 56 &uevent_seqnum_attr.attr,
57 &uevent_helper_attr.attr, 57 &uevent_helper_attr.attr,
58#endif 58#endif
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 6a5373868a98..c5f3c6613b6d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -115,7 +115,9 @@ static void keventd_create_kthread(void *_create)
115 create->result = ERR_PTR(pid); 115 create->result = ERR_PTR(pid);
116 } else { 116 } else {
117 wait_for_completion(&create->started); 117 wait_for_completion(&create->started);
118 read_lock(&tasklist_lock);
118 create->result = find_task_by_pid(pid); 119 create->result = find_task_by_pid(pid);
120 read_unlock(&tasklist_lock);
119 } 121 }
120 complete(&create->done); 122 complete(&create->done);
121} 123}
diff --git a/kernel/module.c b/kernel/module.c
index fb404299082e..ddfe45ac2fd1 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -233,24 +233,6 @@ static unsigned long __find_symbol(const char *name,
233 return 0; 233 return 0;
234} 234}
235 235
236/* Find a symbol in this elf symbol table */
237static unsigned long find_local_symbol(Elf_Shdr *sechdrs,
238 unsigned int symindex,
239 const char *strtab,
240 const char *name)
241{
242 unsigned int i;
243 Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
244
245 /* Search (defined) internal symbols first. */
246 for (i = 1; i < sechdrs[symindex].sh_size/sizeof(*sym); i++) {
247 if (sym[i].st_shndx != SHN_UNDEF
248 && strcmp(name, strtab + sym[i].st_name) == 0)
249 return sym[i].st_value;
250 }
251 return 0;
252}
253
254/* Search for module by name: must hold module_mutex. */ 236/* Search for module by name: must hold module_mutex. */
255static struct module *find_module(const char *name) 237static struct module *find_module(const char *name)
256{ 238{
@@ -785,139 +767,6 @@ static struct module_attribute *modinfo_attrs[] = {
785 NULL, 767 NULL,
786}; 768};
787 769
788#ifdef CONFIG_OBSOLETE_MODPARM
789/* Bounds checking done below */
790static int obsparm_copy_string(const char *val, struct kernel_param *kp)
791{
792 strcpy(kp->arg, val);
793 return 0;
794}
795
796static int set_obsolete(const char *val, struct kernel_param *kp)
797{
798 unsigned int min, max;
799 unsigned int size, maxsize;
800 int dummy;
801 char *endp;
802 const char *p;
803 struct obsolete_modparm *obsparm = kp->arg;
804
805 if (!val) {
806 printk(KERN_ERR "Parameter %s needs an argument\n", kp->name);
807 return -EINVAL;
808 }
809
810 /* type is: [min[-max]]{b,h,i,l,s} */
811 p = obsparm->type;
812 min = simple_strtol(p, &endp, 10);
813 if (endp == obsparm->type)
814 min = max = 1;
815 else if (*endp == '-') {
816 p = endp+1;
817 max = simple_strtol(p, &endp, 10);
818 } else
819 max = min;
820 switch (*endp) {
821 case 'b':
822 return param_array(kp->name, val, min, max, obsparm->addr,
823 1, param_set_byte, &dummy);
824 case 'h':
825 return param_array(kp->name, val, min, max, obsparm->addr,
826 sizeof(short), param_set_short, &dummy);
827 case 'i':
828 return param_array(kp->name, val, min, max, obsparm->addr,
829 sizeof(int), param_set_int, &dummy);
830 case 'l':
831 return param_array(kp->name, val, min, max, obsparm->addr,
832 sizeof(long), param_set_long, &dummy);
833 case 's':
834 return param_array(kp->name, val, min, max, obsparm->addr,
835 sizeof(char *), param_set_charp, &dummy);
836
837 case 'c':
838 /* Undocumented: 1-5c50 means 1-5 strings of up to 49 chars,
839 and the decl is "char xxx[5][50];" */
840 p = endp+1;
841 maxsize = simple_strtol(p, &endp, 10);
842 /* We check lengths here (yes, this is a hack). */
843 p = val;
844 while (p[size = strcspn(p, ",")]) {
845 if (size >= maxsize)
846 goto oversize;
847 p += size+1;
848 }
849 if (size >= maxsize)
850 goto oversize;
851 return param_array(kp->name, val, min, max, obsparm->addr,
852 maxsize, obsparm_copy_string, &dummy);
853 }
854 printk(KERN_ERR "Unknown obsolete parameter type %s\n", obsparm->type);
855 return -EINVAL;
856 oversize:
857 printk(KERN_ERR
858 "Parameter %s doesn't fit in %u chars.\n", kp->name, maxsize);
859 return -EINVAL;
860}
861
862static int obsolete_params(const char *name,
863 char *args,
864 struct obsolete_modparm obsparm[],
865 unsigned int num,
866 Elf_Shdr *sechdrs,
867 unsigned int symindex,
868 const char *strtab)
869{
870 struct kernel_param *kp;
871 unsigned int i;
872 int ret;
873
874 kp = kmalloc(sizeof(kp[0]) * num, GFP_KERNEL);
875 if (!kp)
876 return -ENOMEM;
877
878 for (i = 0; i < num; i++) {
879 char sym_name[128 + sizeof(MODULE_SYMBOL_PREFIX)];
880
881 snprintf(sym_name, sizeof(sym_name), "%s%s",
882 MODULE_SYMBOL_PREFIX, obsparm[i].name);
883
884 kp[i].name = obsparm[i].name;
885 kp[i].perm = 000;
886 kp[i].set = set_obsolete;
887 kp[i].get = NULL;
888 obsparm[i].addr
889 = (void *)find_local_symbol(sechdrs, symindex, strtab,
890 sym_name);
891 if (!obsparm[i].addr) {
892 printk("%s: falsely claims to have parameter %s\n",
893 name, obsparm[i].name);
894 ret = -EINVAL;
895 goto out;
896 }
897 kp[i].arg = &obsparm[i];
898 }
899
900 ret = parse_args(name, args, kp, num, NULL);
901 out:
902 kfree(kp);
903 return ret;
904}
905#else
906static int obsolete_params(const char *name,
907 char *args,
908 struct obsolete_modparm obsparm[],
909 unsigned int num,
910 Elf_Shdr *sechdrs,
911 unsigned int symindex,
912 const char *strtab)
913{
914 if (num != 0)
915 printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
916 name);
917 return 0;
918}
919#endif /* CONFIG_OBSOLETE_MODPARM */
920
921static const char vermagic[] = VERMAGIC_STRING; 770static const char vermagic[] = VERMAGIC_STRING;
922 771
923#ifdef CONFIG_MODVERSIONS 772#ifdef CONFIG_MODVERSIONS
@@ -1572,7 +1421,6 @@ static struct module *load_module(void __user *umod,
1572 exportindex, modindex, obsparmindex, infoindex, gplindex, 1421 exportindex, modindex, obsparmindex, infoindex, gplindex,
1573 crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex, 1422 crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex,
1574 gplfuturecrcindex; 1423 gplfuturecrcindex;
1575 long arglen;
1576 struct module *mod; 1424 struct module *mod;
1577 long err = 0; 1425 long err = 0;
1578 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1426 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -1691,23 +1539,11 @@ static struct module *load_module(void __user *umod,
1691 } 1539 }
1692 1540
1693 /* Now copy in args */ 1541 /* Now copy in args */
1694 arglen = strlen_user(uargs); 1542 args = strndup_user(uargs, ~0UL >> 1);
1695 if (!arglen) { 1543 if (IS_ERR(args)) {
1696 err = -EFAULT; 1544 err = PTR_ERR(args);
1697 goto free_hdr;
1698 }
1699 args = kmalloc(arglen, GFP_KERNEL);
1700 if (!args) {
1701 err = -ENOMEM;
1702 goto free_hdr; 1545 goto free_hdr;
1703 } 1546 }
1704 if (copy_from_user(args, uargs, arglen) != 0) {
1705 err = -EFAULT;
1706 goto free_mod;
1707 }
1708
1709 /* Userspace could have altered the string after the strlen_user() */
1710 args[arglen - 1] = '\0';
1711 1547
1712 if (find_module(mod->name)) { 1548 if (find_module(mod->name)) {
1713 err = -EEXIST; 1549 err = -EEXIST;
@@ -1887,27 +1723,17 @@ static struct module *load_module(void __user *umod,
1887 set_fs(old_fs); 1723 set_fs(old_fs);
1888 1724
1889 mod->args = args; 1725 mod->args = args;
1890 if (obsparmindex) { 1726 if (obsparmindex)
1891 err = obsolete_params(mod->name, mod->args, 1727 printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
1892 (struct obsolete_modparm *) 1728 mod->name);
1893 sechdrs[obsparmindex].sh_addr, 1729
1894 sechdrs[obsparmindex].sh_size 1730 /* Size of section 0 is 0, so this works well if no params */
1895 / sizeof(struct obsolete_modparm), 1731 err = parse_args(mod->name, mod->args,
1896 sechdrs, symindex, 1732 (struct kernel_param *)
1897 (char *)sechdrs[strindex].sh_addr); 1733 sechdrs[setupindex].sh_addr,
1898 if (setupindex) 1734 sechdrs[setupindex].sh_size
1899 printk(KERN_WARNING "%s: Ignoring new-style " 1735 / sizeof(struct kernel_param),
1900 "parameters in presence of obsolete ones\n", 1736 NULL);
1901 mod->name);
1902 } else {
1903 /* Size of section 0 is 0, so this works well if no params */
1904 err = parse_args(mod->name, mod->args,
1905 (struct kernel_param *)
1906 sechdrs[setupindex].sh_addr,
1907 sechdrs[setupindex].sh_size
1908 / sizeof(struct kernel_param),
1909 NULL);
1910 }
1911 if (err < 0) 1737 if (err < 0)
1912 goto arch_cleanup; 1738 goto arch_cleanup;
1913 1739
diff --git a/kernel/params.c b/kernel/params.c
index a29150582310..9de637a5c8bc 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -265,12 +265,12 @@ int param_get_invbool(char *buffer, struct kernel_param *kp)
265} 265}
266 266
267/* We cheat here and temporarily mangle the string. */ 267/* We cheat here and temporarily mangle the string. */
268int param_array(const char *name, 268static int param_array(const char *name,
269 const char *val, 269 const char *val,
270 unsigned int min, unsigned int max, 270 unsigned int min, unsigned int max,
271 void *elem, int elemsize, 271 void *elem, int elemsize,
272 int (*set)(const char *, struct kernel_param *kp), 272 int (*set)(const char *, struct kernel_param *kp),
273 int *num) 273 int *num)
274{ 274{
275 int ret; 275 int ret;
276 struct kernel_param kp; 276 struct kernel_param kp;
diff --git a/kernel/power/smp.c b/kernel/power/smp.c
index 911fc62b8225..5957312b2d68 100644
--- a/kernel/power/smp.c
+++ b/kernel/power/smp.c
@@ -49,9 +49,7 @@ void enable_nonboot_cpus(void)
49 49
50 printk("Thawing cpus ...\n"); 50 printk("Thawing cpus ...\n");
51 for_each_cpu_mask(cpu, frozen_cpus) { 51 for_each_cpu_mask(cpu, frozen_cpus) {
52 error = smp_prepare_cpu(cpu); 52 error = cpu_up(cpu);
53 if (!error)
54 error = cpu_up(cpu);
55 if (!error) { 53 if (!error) {
56 printk("CPU%d is up\n", cpu); 54 printk("CPU%d is up\n", cpu);
57 continue; 55 continue;
diff --git a/kernel/printk.c b/kernel/printk.c
index 13ced0f7828f..8cc19431e74b 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -122,44 +122,6 @@ static char *log_buf = __log_buf;
122static int log_buf_len = __LOG_BUF_LEN; 122static int log_buf_len = __LOG_BUF_LEN;
123static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */ 123static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
124 124
125/*
126 * Setup a list of consoles. Called from init/main.c
127 */
128static int __init console_setup(char *str)
129{
130 char name[sizeof(console_cmdline[0].name)];
131 char *s, *options;
132 int idx;
133
134 /*
135 * Decode str into name, index, options.
136 */
137 if (str[0] >= '0' && str[0] <= '9') {
138 strcpy(name, "ttyS");
139 strncpy(name + 4, str, sizeof(name) - 5);
140 } else
141 strncpy(name, str, sizeof(name) - 1);
142 name[sizeof(name) - 1] = 0;
143 if ((options = strchr(str, ',')) != NULL)
144 *(options++) = 0;
145#ifdef __sparc__
146 if (!strcmp(str, "ttya"))
147 strcpy(name, "ttyS0");
148 if (!strcmp(str, "ttyb"))
149 strcpy(name, "ttyS1");
150#endif
151 for (s = name; *s; s++)
152 if ((*s >= '0' && *s <= '9') || *s == ',')
153 break;
154 idx = simple_strtoul(s, NULL, 10);
155 *s = 0;
156
157 add_preferred_console(name, idx, options);
158 return 1;
159}
160
161__setup("console=", console_setup);
162
163static int __init log_buf_len_setup(char *str) 125static int __init log_buf_len_setup(char *str)
164{ 126{
165 unsigned long size = memparse(str, &str); 127 unsigned long size = memparse(str, &str);
@@ -659,6 +621,44 @@ static void call_console_drivers(unsigned long start, unsigned long end)
659 621
660#endif 622#endif
661 623
624/*
625 * Set up a list of consoles. Called from init/main.c
626 */
627static int __init console_setup(char *str)
628{
629 char name[sizeof(console_cmdline[0].name)];
630 char *s, *options;
631 int idx;
632
633 /*
634 * Decode str into name, index, options.
635 */
636 if (str[0] >= '0' && str[0] <= '9') {
637 strcpy(name, "ttyS");
638 strncpy(name + 4, str, sizeof(name) - 5);
639 } else {
640 strncpy(name, str, sizeof(name) - 1);
641 }
642 name[sizeof(name) - 1] = 0;
643 if ((options = strchr(str, ',')) != NULL)
644 *(options++) = 0;
645#ifdef __sparc__
646 if (!strcmp(str, "ttya"))
647 strcpy(name, "ttyS0");
648 if (!strcmp(str, "ttyb"))
649 strcpy(name, "ttyS1");
650#endif
651 for (s = name; *s; s++)
652 if ((*s >= '0' && *s <= '9') || *s == ',')
653 break;
654 idx = simple_strtoul(s, NULL, 10);
655 *s = 0;
656
657 add_preferred_console(name, idx, options);
658 return 1;
659}
660__setup("console=", console_setup);
661
662/** 662/**
663 * add_preferred_console - add a device to the list of preferred consoles. 663 * add_preferred_console - add a device to the list of preferred consoles.
664 * @name: device name 664 * @name: device name
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 6df1559b1c02..13458bbaa1be 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -416,8 +416,8 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp,
416 rdp->curtail = &rdp->curlist; 416 rdp->curtail = &rdp->curlist;
417 } 417 }
418 418
419 local_irq_disable();
420 if (rdp->nxtlist && !rdp->curlist) { 419 if (rdp->nxtlist && !rdp->curlist) {
420 local_irq_disable();
421 rdp->curlist = rdp->nxtlist; 421 rdp->curlist = rdp->nxtlist;
422 rdp->curtail = rdp->nxttail; 422 rdp->curtail = rdp->nxttail;
423 rdp->nxtlist = NULL; 423 rdp->nxtlist = NULL;
@@ -442,9 +442,8 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp,
442 rcu_start_batch(rcp); 442 rcu_start_batch(rcp);
443 spin_unlock(&rcp->lock); 443 spin_unlock(&rcp->lock);
444 } 444 }
445 } else {
446 local_irq_enable();
447 } 445 }
446
448 rcu_check_quiescent_state(rcp, rdp); 447 rcu_check_quiescent_state(rcp, rdp);
449 if (rdp->donelist) 448 if (rdp->donelist)
450 rcu_do_batch(rdp); 449 rcu_do_batch(rdp);
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 7712912dbc84..b4b362b5baf5 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -54,15 +54,15 @@ static int verbose; /* Print more debug info. */
54static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */ 54static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */
55static int shuffle_interval = 5; /* Interval between shuffles (in sec)*/ 55static int shuffle_interval = 5; /* Interval between shuffles (in sec)*/
56 56
57MODULE_PARM(nreaders, "i"); 57module_param(nreaders, int, 0);
58MODULE_PARM_DESC(nreaders, "Number of RCU reader threads"); 58MODULE_PARM_DESC(nreaders, "Number of RCU reader threads");
59MODULE_PARM(stat_interval, "i"); 59module_param(stat_interval, int, 0);
60MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s"); 60MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s");
61MODULE_PARM(verbose, "i"); 61module_param(verbose, bool, 0);
62MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s"); 62MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s");
63MODULE_PARM(test_no_idle_hz, "i"); 63module_param(test_no_idle_hz, bool, 0);
64MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs"); 64MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
65MODULE_PARM(shuffle_interval, "i"); 65module_param(shuffle_interval, int, 0);
66MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles"); 66MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
67#define TORTURE_FLAG "rcutorture: " 67#define TORTURE_FLAG "rcutorture: "
68#define PRINTK_STRING(s) \ 68#define PRINTK_STRING(s) \
@@ -441,6 +441,16 @@ rcu_torture_shuffle(void *arg)
441 return 0; 441 return 0;
442} 442}
443 443
444static inline void
445rcu_torture_print_module_parms(char *tag)
446{
447 printk(KERN_ALERT TORTURE_FLAG "--- %s: nreaders=%d "
448 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
449 "shuffle_interval = %d\n",
450 tag, nrealreaders, stat_interval, verbose, test_no_idle_hz,
451 shuffle_interval);
452}
453
444static void 454static void
445rcu_torture_cleanup(void) 455rcu_torture_cleanup(void)
446{ 456{
@@ -483,9 +493,10 @@ rcu_torture_cleanup(void)
483 rcu_barrier(); 493 rcu_barrier();
484 494
485 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 495 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
486 printk(KERN_ALERT TORTURE_FLAG 496 if (atomic_read(&n_rcu_torture_error))
487 "--- End of test: %s\n", 497 rcu_torture_print_module_parms("End of test: FAILURE");
488 atomic_read(&n_rcu_torture_error) == 0 ? "SUCCESS" : "FAILURE"); 498 else
499 rcu_torture_print_module_parms("End of test: SUCCESS");
489} 500}
490 501
491static int 502static int
@@ -501,11 +512,7 @@ rcu_torture_init(void)
501 nrealreaders = nreaders; 512 nrealreaders = nreaders;
502 else 513 else
503 nrealreaders = 2 * num_online_cpus(); 514 nrealreaders = 2 * num_online_cpus();
504 printk(KERN_ALERT TORTURE_FLAG "--- Start of test: nreaders=%d " 515 rcu_torture_print_module_parms("Start of test");
505 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
506 "shuffle_interval = %d\n",
507 nrealreaders, stat_interval, verbose, test_no_idle_hz,
508 shuffle_interval);
509 fullstop = 0; 516 fullstop = 0;
510 517
511 /* Set up the freelist. */ 518 /* Set up the freelist. */
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index c67189a25d52..d9b3d5847ed8 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -1,12 +1,11 @@
1/* 1/*
2 * Detect Soft Lockups 2 * Detect Soft Lockups
3 * 3 *
4 * started by Ingo Molnar, (C) 2005, Red Hat 4 * started by Ingo Molnar, Copyright (C) 2005, 2006 Red Hat, Inc.
5 * 5 *
6 * this code detects soft lockups: incidents in where on a CPU 6 * this code detects soft lockups: incidents in where on a CPU
7 * the kernel does not reschedule for 10 seconds or more. 7 * the kernel does not reschedule for 10 seconds or more.
8 */ 8 */
9
10#include <linux/mm.h> 9#include <linux/mm.h>
11#include <linux/cpu.h> 10#include <linux/cpu.h>
12#include <linux/init.h> 11#include <linux/init.h>
@@ -17,13 +16,14 @@
17 16
18static DEFINE_SPINLOCK(print_lock); 17static DEFINE_SPINLOCK(print_lock);
19 18
20static DEFINE_PER_CPU(unsigned long, timestamp) = 0; 19static DEFINE_PER_CPU(unsigned long, touch_timestamp);
21static DEFINE_PER_CPU(unsigned long, print_timestamp) = 0; 20static DEFINE_PER_CPU(unsigned long, print_timestamp);
22static DEFINE_PER_CPU(struct task_struct *, watchdog_task); 21static DEFINE_PER_CPU(struct task_struct *, watchdog_task);
23 22
24static int did_panic = 0; 23static int did_panic = 0;
25static int softlock_panic(struct notifier_block *this, unsigned long event, 24
26 void *ptr) 25static int
26softlock_panic(struct notifier_block *this, unsigned long event, void *ptr)
27{ 27{
28 did_panic = 1; 28 did_panic = 1;
29 29
@@ -36,7 +36,7 @@ static struct notifier_block panic_block = {
36 36
37void touch_softlockup_watchdog(void) 37void touch_softlockup_watchdog(void)
38{ 38{
39 per_cpu(timestamp, raw_smp_processor_id()) = jiffies; 39 per_cpu(touch_timestamp, raw_smp_processor_id()) = jiffies;
40} 40}
41EXPORT_SYMBOL(touch_softlockup_watchdog); 41EXPORT_SYMBOL(touch_softlockup_watchdog);
42 42
@@ -44,25 +44,35 @@ EXPORT_SYMBOL(touch_softlockup_watchdog);
44 * This callback runs from the timer interrupt, and checks 44 * This callback runs from the timer interrupt, and checks
45 * whether the watchdog thread has hung or not: 45 * whether the watchdog thread has hung or not:
46 */ 46 */
47void softlockup_tick(struct pt_regs *regs) 47void softlockup_tick(void)
48{ 48{
49 int this_cpu = smp_processor_id(); 49 int this_cpu = smp_processor_id();
50 unsigned long timestamp = per_cpu(timestamp, this_cpu); 50 unsigned long touch_timestamp = per_cpu(touch_timestamp, this_cpu);
51 51
52 if (per_cpu(print_timestamp, this_cpu) == timestamp) 52 /* prevent double reports: */
53 if (per_cpu(print_timestamp, this_cpu) == touch_timestamp ||
54 did_panic ||
55 !per_cpu(watchdog_task, this_cpu))
53 return; 56 return;
54 57
55 /* Do not cause a second panic when there already was one */ 58 /* do not print during early bootup: */
56 if (did_panic) 59 if (unlikely(system_state != SYSTEM_RUNNING)) {
60 touch_softlockup_watchdog();
57 return; 61 return;
62 }
58 63
59 if (time_after(jiffies, timestamp + 10*HZ)) { 64 /* Wake up the high-prio watchdog task every second: */
60 per_cpu(print_timestamp, this_cpu) = timestamp; 65 if (time_after(jiffies, touch_timestamp + HZ))
66 wake_up_process(per_cpu(watchdog_task, this_cpu));
67
68 /* Warn about unreasonable 10+ seconds delays: */
69 if (time_after(jiffies, touch_timestamp + 10*HZ)) {
70 per_cpu(print_timestamp, this_cpu) = touch_timestamp;
61 71
62 spin_lock(&print_lock); 72 spin_lock(&print_lock);
63 printk(KERN_ERR "BUG: soft lockup detected on CPU#%d!\n", 73 printk(KERN_ERR "BUG: soft lockup detected on CPU#%d!\n",
64 this_cpu); 74 this_cpu);
65 show_regs(regs); 75 dump_stack();
66 spin_unlock(&print_lock); 76 spin_unlock(&print_lock);
67 } 77 }
68} 78}
@@ -77,18 +87,16 @@ static int watchdog(void * __bind_cpu)
77 sched_setscheduler(current, SCHED_FIFO, &param); 87 sched_setscheduler(current, SCHED_FIFO, &param);
78 current->flags |= PF_NOFREEZE; 88 current->flags |= PF_NOFREEZE;
79 89
80 set_current_state(TASK_INTERRUPTIBLE);
81
82 /* 90 /*
83 * Run briefly once per second - if this gets delayed for 91 * Run briefly once per second to reset the softlockup timestamp.
84 * more than 10 seconds then the debug-printout triggers 92 * If this gets delayed for more than 10 seconds then the
85 * in softlockup_tick(): 93 * debug-printout triggers in softlockup_tick().
86 */ 94 */
87 while (!kthread_should_stop()) { 95 while (!kthread_should_stop()) {
88 msleep_interruptible(1000); 96 set_current_state(TASK_INTERRUPTIBLE);
89 touch_softlockup_watchdog(); 97 touch_softlockup_watchdog();
98 schedule();
90 } 99 }
91 __set_current_state(TASK_RUNNING);
92 100
93 return 0; 101 return 0;
94} 102}
@@ -110,11 +118,11 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
110 printk("watchdog for %i failed\n", hotcpu); 118 printk("watchdog for %i failed\n", hotcpu);
111 return NOTIFY_BAD; 119 return NOTIFY_BAD;
112 } 120 }
121 per_cpu(touch_timestamp, hotcpu) = jiffies;
113 per_cpu(watchdog_task, hotcpu) = p; 122 per_cpu(watchdog_task, hotcpu) = p;
114 kthread_bind(p, hotcpu); 123 kthread_bind(p, hotcpu);
115 break; 124 break;
116 case CPU_ONLINE: 125 case CPU_ONLINE:
117
118 wake_up_process(per_cpu(watchdog_task, hotcpu)); 126 wake_up_process(per_cpu(watchdog_task, hotcpu));
119 break; 127 break;
120#ifdef CONFIG_HOTPLUG_CPU 128#ifdef CONFIG_HOTPLUG_CPU
@@ -146,4 +154,3 @@ __init void spawn_softlockup_task(void)
146 154
147 notifier_chain_register(&panic_notifier_list, &panic_block); 155 notifier_chain_register(&panic_notifier_list, &panic_block);
148} 156}
149
diff --git a/kernel/sys.c b/kernel/sys.c
index c0fcad9f826c..38bc73ede2ba 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -224,18 +224,6 @@ int unregister_reboot_notifier(struct notifier_block * nb)
224 224
225EXPORT_SYMBOL(unregister_reboot_notifier); 225EXPORT_SYMBOL(unregister_reboot_notifier);
226 226
227#ifndef CONFIG_SECURITY
228int capable(int cap)
229{
230 if (cap_raised(current->cap_effective, cap)) {
231 current->flags |= PF_SUPERPRIV;
232 return 1;
233 }
234 return 0;
235}
236EXPORT_SYMBOL(capable);
237#endif
238
239static int set_one_prio(struct task_struct *p, int niceval, int error) 227static int set_one_prio(struct task_struct *p, int niceval, int error)
240{ 228{
241 int no_nice; 229 int no_nice;
@@ -1375,7 +1363,7 @@ static void groups_sort(struct group_info *group_info)
1375/* a simple bsearch */ 1363/* a simple bsearch */
1376int groups_search(struct group_info *group_info, gid_t grp) 1364int groups_search(struct group_info *group_info, gid_t grp)
1377{ 1365{
1378 int left, right; 1366 unsigned int left, right;
1379 1367
1380 if (!group_info) 1368 if (!group_info)
1381 return 0; 1369 return 0;
@@ -1383,7 +1371,7 @@ int groups_search(struct group_info *group_info, gid_t grp)
1383 left = 0; 1371 left = 0;
1384 right = group_info->ngroups; 1372 right = group_info->ngroups;
1385 while (left < right) { 1373 while (left < right) {
1386 int mid = (left+right)/2; 1374 unsigned int mid = (left+right)/2;
1387 int cmp = grp - GROUP_AT(group_info, mid); 1375 int cmp = grp - GROUP_AT(group_info, mid);
1388 if (cmp > 0) 1376 if (cmp > 0)
1389 left = mid + 1; 1377 left = mid + 1;
@@ -1433,7 +1421,6 @@ asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist)
1433 return -EINVAL; 1421 return -EINVAL;
1434 1422
1435 /* no need to grab task_lock here; it cannot change */ 1423 /* no need to grab task_lock here; it cannot change */
1436 get_group_info(current->group_info);
1437 i = current->group_info->ngroups; 1424 i = current->group_info->ngroups;
1438 if (gidsetsize) { 1425 if (gidsetsize) {
1439 if (i > gidsetsize) { 1426 if (i > gidsetsize) {
@@ -1446,7 +1433,6 @@ asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist)
1446 } 1433 }
1447 } 1434 }
1448out: 1435out:
1449 put_group_info(current->group_info);
1450 return i; 1436 return i;
1451} 1437}
1452 1438
@@ -1487,9 +1473,7 @@ int in_group_p(gid_t grp)
1487{ 1473{
1488 int retval = 1; 1474 int retval = 1;
1489 if (grp != current->fsgid) { 1475 if (grp != current->fsgid) {
1490 get_group_info(current->group_info);
1491 retval = groups_search(current->group_info, grp); 1476 retval = groups_search(current->group_info, grp);
1492 put_group_info(current->group_info);
1493 } 1477 }
1494 return retval; 1478 return retval;
1495} 1479}
@@ -1500,9 +1484,7 @@ int in_egroup_p(gid_t grp)
1500{ 1484{
1501 int retval = 1; 1485 int retval = 1;
1502 if (grp != current->egid) { 1486 if (grp != current->egid) {
1503 get_group_info(current->group_info);
1504 retval = groups_search(current->group_info, grp); 1487 retval = groups_search(current->group_info, grp);
1505 put_group_info(current->group_info);
1506 } 1488 }
1507 return retval; 1489 return retval;
1508} 1490}
@@ -1630,20 +1612,21 @@ asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *r
1630asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) 1612asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
1631{ 1613{
1632 struct rlimit new_rlim, *old_rlim; 1614 struct rlimit new_rlim, *old_rlim;
1615 unsigned long it_prof_secs;
1633 int retval; 1616 int retval;
1634 1617
1635 if (resource >= RLIM_NLIMITS) 1618 if (resource >= RLIM_NLIMITS)
1636 return -EINVAL; 1619 return -EINVAL;
1637 if(copy_from_user(&new_rlim, rlim, sizeof(*rlim))) 1620 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
1638 return -EFAULT; 1621 return -EFAULT;
1639 if (new_rlim.rlim_cur > new_rlim.rlim_max) 1622 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1640 return -EINVAL; 1623 return -EINVAL;
1641 old_rlim = current->signal->rlim + resource; 1624 old_rlim = current->signal->rlim + resource;
1642 if ((new_rlim.rlim_max > old_rlim->rlim_max) && 1625 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
1643 !capable(CAP_SYS_RESOURCE)) 1626 !capable(CAP_SYS_RESOURCE))
1644 return -EPERM; 1627 return -EPERM;
1645 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN) 1628 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
1646 return -EPERM; 1629 return -EPERM;
1647 1630
1648 retval = security_task_setrlimit(resource, &new_rlim); 1631 retval = security_task_setrlimit(resource, &new_rlim);
1649 if (retval) 1632 if (retval)
@@ -1653,19 +1636,40 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
1653 *old_rlim = new_rlim; 1636 *old_rlim = new_rlim;
1654 task_unlock(current->group_leader); 1637 task_unlock(current->group_leader);
1655 1638
1656 if (resource == RLIMIT_CPU && new_rlim.rlim_cur != RLIM_INFINITY && 1639 if (resource != RLIMIT_CPU)
1657 (cputime_eq(current->signal->it_prof_expires, cputime_zero) || 1640 goto out;
1658 new_rlim.rlim_cur <= cputime_to_secs( 1641
1659 current->signal->it_prof_expires))) { 1642 /*
1660 cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur); 1643 * RLIMIT_CPU handling. Note that the kernel fails to return an error
1644 * code if it rejected the user's attempt to set RLIMIT_CPU. This is a
1645 * very long-standing error, and fixing it now risks breakage of
1646 * applications, so we live with it
1647 */
1648 if (new_rlim.rlim_cur == RLIM_INFINITY)
1649 goto out;
1650
1651 it_prof_secs = cputime_to_secs(current->signal->it_prof_expires);
1652 if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {
1653 unsigned long rlim_cur = new_rlim.rlim_cur;
1654 cputime_t cputime;
1655
1656 if (rlim_cur == 0) {
1657 /*
1658 * The caller is asking for an immediate RLIMIT_CPU
1659 * expiry. But we use the zero value to mean "it was
1660 * never set". So let's cheat and make it one second
1661 * instead
1662 */
1663 rlim_cur = 1;
1664 }
1665 cputime = secs_to_cputime(rlim_cur);
1661 read_lock(&tasklist_lock); 1666 read_lock(&tasklist_lock);
1662 spin_lock_irq(&current->sighand->siglock); 1667 spin_lock_irq(&current->sighand->siglock);
1663 set_process_cpu_timer(current, CPUCLOCK_PROF, 1668 set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
1664 &cputime, NULL);
1665 spin_unlock_irq(&current->sighand->siglock); 1669 spin_unlock_irq(&current->sighand->siglock);
1666 read_unlock(&tasklist_lock); 1670 read_unlock(&tasklist_lock);
1667 } 1671 }
1668 1672out:
1669 return 0; 1673 return 0;
1670} 1674}
1671 1675
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 32b48e8ee36e..e82726faeeff 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -742,18 +742,18 @@ static ctl_table vm_table[] = {
742 { 742 {
743 .ctl_name = VM_DIRTY_WB_CS, 743 .ctl_name = VM_DIRTY_WB_CS,
744 .procname = "dirty_writeback_centisecs", 744 .procname = "dirty_writeback_centisecs",
745 .data = &dirty_writeback_centisecs, 745 .data = &dirty_writeback_interval,
746 .maxlen = sizeof(dirty_writeback_centisecs), 746 .maxlen = sizeof(dirty_writeback_interval),
747 .mode = 0644, 747 .mode = 0644,
748 .proc_handler = &dirty_writeback_centisecs_handler, 748 .proc_handler = &dirty_writeback_centisecs_handler,
749 }, 749 },
750 { 750 {
751 .ctl_name = VM_DIRTY_EXPIRE_CS, 751 .ctl_name = VM_DIRTY_EXPIRE_CS,
752 .procname = "dirty_expire_centisecs", 752 .procname = "dirty_expire_centisecs",
753 .data = &dirty_expire_centisecs, 753 .data = &dirty_expire_interval,
754 .maxlen = sizeof(dirty_expire_centisecs), 754 .maxlen = sizeof(dirty_expire_interval),
755 .mode = 0644, 755 .mode = 0644,
756 .proc_handler = &proc_dointvec, 756 .proc_handler = &proc_dointvec_userhz_jiffies,
757 }, 757 },
758 { 758 {
759 .ctl_name = VM_NR_PDFLUSH_THREADS, 759 .ctl_name = VM_NR_PDFLUSH_THREADS,
@@ -848,9 +848,8 @@ static ctl_table vm_table[] = {
848 .data = &laptop_mode, 848 .data = &laptop_mode,
849 .maxlen = sizeof(laptop_mode), 849 .maxlen = sizeof(laptop_mode),
850 .mode = 0644, 850 .mode = 0644,
851 .proc_handler = &proc_dointvec, 851 .proc_handler = &proc_dointvec_jiffies,
852 .strategy = &sysctl_intvec, 852 .strategy = &sysctl_jiffies,
853 .extra1 = &zero,
854 }, 853 },
855 { 854 {
856 .ctl_name = VM_BLOCK_DUMP, 855 .ctl_name = VM_BLOCK_DUMP,
@@ -2054,6 +2053,8 @@ static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2054 int write, void *data) 2053 int write, void *data)
2055{ 2054{
2056 if (write) { 2055 if (write) {
2056 if (*lvalp > LONG_MAX / HZ)
2057 return 1;
2057 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 2058 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2058 } else { 2059 } else {
2059 int val = *valp; 2060 int val = *valp;
@@ -2075,6 +2076,8 @@ static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2075 int write, void *data) 2076 int write, void *data)
2076{ 2077{
2077 if (write) { 2078 if (write) {
2079 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2080 return 1;
2078 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 2081 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2079 } else { 2082 } else {
2080 int val = *valp; 2083 int val = *valp;
diff --git a/kernel/time.c b/kernel/time.c
index 804539165d8b..e00a97b77241 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -202,24 +202,6 @@ asmlinkage long sys_settimeofday(struct timeval __user *tv,
202 return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL); 202 return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
203} 203}
204 204
205long pps_offset; /* pps time offset (us) */
206long pps_jitter = MAXTIME; /* time dispersion (jitter) (us) */
207
208long pps_freq; /* frequency offset (scaled ppm) */
209long pps_stabil = MAXFREQ; /* frequency dispersion (scaled ppm) */
210
211long pps_valid = PPS_VALID; /* pps signal watchdog counter */
212
213int pps_shift = PPS_SHIFT; /* interval duration (s) (shift) */
214
215long pps_jitcnt; /* jitter limit exceeded */
216long pps_calcnt; /* calibration intervals */
217long pps_errcnt; /* calibration errors */
218long pps_stbcnt; /* stability limit exceeded */
219
220/* hook for a loadable hardpps kernel module */
221void (*hardpps_ptr)(struct timeval *);
222
223/* we call this to notify the arch when the clock is being 205/* we call this to notify the arch when the clock is being
224 * controlled. If no such arch routine, do nothing. 206 * controlled. If no such arch routine, do nothing.
225 */ 207 */
@@ -279,7 +261,7 @@ int do_adjtimex(struct timex *txc)
279 result = -EINVAL; 261 result = -EINVAL;
280 goto leave; 262 goto leave;
281 } 263 }
282 time_freq = txc->freq - pps_freq; 264 time_freq = txc->freq;
283 } 265 }
284 266
285 if (txc->modes & ADJ_MAXERROR) { 267 if (txc->modes & ADJ_MAXERROR) {
@@ -312,10 +294,8 @@ int do_adjtimex(struct timex *txc)
312 if ((time_next_adjust = txc->offset) == 0) 294 if ((time_next_adjust = txc->offset) == 0)
313 time_adjust = 0; 295 time_adjust = 0;
314 } 296 }
315 else if ( time_status & (STA_PLL | STA_PPSTIME) ) { 297 else if (time_status & STA_PLL) {
316 ltemp = (time_status & (STA_PPSTIME | STA_PPSSIGNAL)) == 298 ltemp = txc->offset;
317 (STA_PPSTIME | STA_PPSSIGNAL) ?
318 pps_offset : txc->offset;
319 299
320 /* 300 /*
321 * Scale the phase adjustment and 301 * Scale the phase adjustment and
@@ -356,23 +336,14 @@ int do_adjtimex(struct timex *txc)
356 } 336 }
357 time_freq = min(time_freq, time_tolerance); 337 time_freq = min(time_freq, time_tolerance);
358 time_freq = max(time_freq, -time_tolerance); 338 time_freq = max(time_freq, -time_tolerance);
359 } /* STA_PLL || STA_PPSTIME */ 339 } /* STA_PLL */
360 } /* txc->modes & ADJ_OFFSET */ 340 } /* txc->modes & ADJ_OFFSET */
361 if (txc->modes & ADJ_TICK) { 341 if (txc->modes & ADJ_TICK) {
362 tick_usec = txc->tick; 342 tick_usec = txc->tick;
363 tick_nsec = TICK_USEC_TO_NSEC(tick_usec); 343 tick_nsec = TICK_USEC_TO_NSEC(tick_usec);
364 } 344 }
365 } /* txc->modes */ 345 } /* txc->modes */
366leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0 346leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
367 || ((time_status & (STA_PPSFREQ|STA_PPSTIME)) != 0
368 && (time_status & STA_PPSSIGNAL) == 0)
369 /* p. 24, (b) */
370 || ((time_status & (STA_PPSTIME|STA_PPSJITTER))
371 == (STA_PPSTIME|STA_PPSJITTER))
372 /* p. 24, (c) */
373 || ((time_status & STA_PPSFREQ) != 0
374 && (time_status & (STA_PPSWANDER|STA_PPSERROR)) != 0))
375 /* p. 24, (d) */
376 result = TIME_ERROR; 347 result = TIME_ERROR;
377 348
378 if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT) 349 if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT)
@@ -380,7 +351,7 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0
380 else { 351 else {
381 txc->offset = shift_right(time_offset, SHIFT_UPDATE); 352 txc->offset = shift_right(time_offset, SHIFT_UPDATE);
382 } 353 }
383 txc->freq = time_freq + pps_freq; 354 txc->freq = time_freq;
384 txc->maxerror = time_maxerror; 355 txc->maxerror = time_maxerror;
385 txc->esterror = time_esterror; 356 txc->esterror = time_esterror;
386 txc->status = time_status; 357 txc->status = time_status;
@@ -388,14 +359,16 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0
388 txc->precision = time_precision; 359 txc->precision = time_precision;
389 txc->tolerance = time_tolerance; 360 txc->tolerance = time_tolerance;
390 txc->tick = tick_usec; 361 txc->tick = tick_usec;
391 txc->ppsfreq = pps_freq; 362
392 txc->jitter = pps_jitter >> PPS_AVG; 363 /* PPS is not implemented, so these are zero */
393 txc->shift = pps_shift; 364 txc->ppsfreq = 0;
394 txc->stabil = pps_stabil; 365 txc->jitter = 0;
395 txc->jitcnt = pps_jitcnt; 366 txc->shift = 0;
396 txc->calcnt = pps_calcnt; 367 txc->stabil = 0;
397 txc->errcnt = pps_errcnt; 368 txc->jitcnt = 0;
398 txc->stbcnt = pps_stbcnt; 369 txc->calcnt = 0;
370 txc->errcnt = 0;
371 txc->stbcnt = 0;
399 write_sequnlock_irq(&xtime_lock); 372 write_sequnlock_irq(&xtime_lock);
400 do_gettimeofday(&txc->time); 373 do_gettimeofday(&txc->time);
401 notify_arch_cmos_timer(); 374 notify_arch_cmos_timer();
diff --git a/kernel/timer.c b/kernel/timer.c
index 2410c18dbeb1..ab189dd187cb 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -86,7 +86,8 @@ struct tvec_t_base_s {
86} ____cacheline_aligned_in_smp; 86} ____cacheline_aligned_in_smp;
87 87
88typedef struct tvec_t_base_s tvec_base_t; 88typedef struct tvec_t_base_s tvec_base_t;
89static DEFINE_PER_CPU(tvec_base_t, tvec_bases); 89static DEFINE_PER_CPU(tvec_base_t *, tvec_bases);
90static tvec_base_t boot_tvec_bases;
90 91
91static inline void set_running_timer(tvec_base_t *base, 92static inline void set_running_timer(tvec_base_t *base,
92 struct timer_list *timer) 93 struct timer_list *timer)
@@ -157,7 +158,7 @@ EXPORT_SYMBOL(__init_timer_base);
157void fastcall init_timer(struct timer_list *timer) 158void fastcall init_timer(struct timer_list *timer)
158{ 159{
159 timer->entry.next = NULL; 160 timer->entry.next = NULL;
160 timer->base = &per_cpu(tvec_bases, raw_smp_processor_id()).t_base; 161 timer->base = &per_cpu(tvec_bases, raw_smp_processor_id())->t_base;
161} 162}
162EXPORT_SYMBOL(init_timer); 163EXPORT_SYMBOL(init_timer);
163 164
@@ -218,7 +219,7 @@ int __mod_timer(struct timer_list *timer, unsigned long expires)
218 ret = 1; 219 ret = 1;
219 } 220 }
220 221
221 new_base = &__get_cpu_var(tvec_bases); 222 new_base = __get_cpu_var(tvec_bases);
222 223
223 if (base != &new_base->t_base) { 224 if (base != &new_base->t_base) {
224 /* 225 /*
@@ -258,7 +259,7 @@ EXPORT_SYMBOL(__mod_timer);
258 */ 259 */
259void add_timer_on(struct timer_list *timer, int cpu) 260void add_timer_on(struct timer_list *timer, int cpu)
260{ 261{
261 tvec_base_t *base = &per_cpu(tvec_bases, cpu); 262 tvec_base_t *base = per_cpu(tvec_bases, cpu);
262 unsigned long flags; 263 unsigned long flags;
263 264
264 BUG_ON(timer_pending(timer) || !timer->function); 265 BUG_ON(timer_pending(timer) || !timer->function);
@@ -504,7 +505,7 @@ unsigned long next_timer_interrupt(void)
504 } 505 }
505 hr_expires += jiffies; 506 hr_expires += jiffies;
506 507
507 base = &__get_cpu_var(tvec_bases); 508 base = __get_cpu_var(tvec_bases);
508 spin_lock(&base->t_base.lock); 509 spin_lock(&base->t_base.lock);
509 expires = base->timer_jiffies + (LONG_MAX >> 1); 510 expires = base->timer_jiffies + (LONG_MAX >> 1);
510 list = NULL; 511 list = NULL;
@@ -696,18 +697,9 @@ static void second_overflow(void)
696 697
697 /* 698 /*
698 * Compute the frequency estimate and additional phase adjustment due 699 * Compute the frequency estimate and additional phase adjustment due
699 * to frequency error for the next second. When the PPS signal is 700 * to frequency error for the next second.
700 * engaged, gnaw on the watchdog counter and update the frequency
701 * computed by the pll and the PPS signal.
702 */ 701 */
703 pps_valid++; 702 ltemp = time_freq;
704 if (pps_valid == PPS_VALID) { /* PPS signal lost */
705 pps_jitter = MAXTIME;
706 pps_stabil = MAXFREQ;
707 time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
708 STA_PPSWANDER | STA_PPSERROR);
709 }
710 ltemp = time_freq + pps_freq;
711 time_adj += shift_right(ltemp,(SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE)); 703 time_adj += shift_right(ltemp,(SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE));
712 704
713#if HZ == 100 705#if HZ == 100
@@ -901,7 +893,7 @@ EXPORT_SYMBOL(xtime_lock);
901 */ 893 */
902static void run_timer_softirq(struct softirq_action *h) 894static void run_timer_softirq(struct softirq_action *h)
903{ 895{
904 tvec_base_t *base = &__get_cpu_var(tvec_bases); 896 tvec_base_t *base = __get_cpu_var(tvec_bases);
905 897
906 hrtimer_run_queues(); 898 hrtimer_run_queues();
907 if (time_after_eq(jiffies, base->timer_jiffies)) 899 if (time_after_eq(jiffies, base->timer_jiffies))
@@ -914,6 +906,7 @@ static void run_timer_softirq(struct softirq_action *h)
914void run_local_timers(void) 906void run_local_timers(void)
915{ 907{
916 raise_softirq(TIMER_SOFTIRQ); 908 raise_softirq(TIMER_SOFTIRQ);
909 softlockup_tick();
917} 910}
918 911
919/* 912/*
@@ -944,7 +937,6 @@ void do_timer(struct pt_regs *regs)
944 /* prevent loading jiffies before storing new jiffies_64 value. */ 937 /* prevent loading jiffies before storing new jiffies_64 value. */
945 barrier(); 938 barrier();
946 update_times(); 939 update_times();
947 softlockup_tick(regs);
948} 940}
949 941
950#ifdef __ARCH_WANT_SYS_ALARM 942#ifdef __ARCH_WANT_SYS_ALARM
@@ -955,19 +947,7 @@ void do_timer(struct pt_regs *regs)
955 */ 947 */
956asmlinkage unsigned long sys_alarm(unsigned int seconds) 948asmlinkage unsigned long sys_alarm(unsigned int seconds)
957{ 949{
958 struct itimerval it_new, it_old; 950 return alarm_setitimer(seconds);
959 unsigned int oldalarm;
960
961 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
962 it_new.it_value.tv_sec = seconds;
963 it_new.it_value.tv_usec = 0;
964 do_setitimer(ITIMER_REAL, &it_new, &it_old);
965 oldalarm = it_old.it_value.tv_sec;
966 /* ehhh.. We can't return 0 if we have an alarm pending.. */
967 /* And we'd better return too much than too little anyway */
968 if ((!oldalarm && it_old.it_value.tv_usec) || it_old.it_value.tv_usec >= 500000)
969 oldalarm++;
970 return oldalarm;
971} 951}
972 952
973#endif 953#endif
@@ -1256,12 +1236,32 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
1256 return 0; 1236 return 0;
1257} 1237}
1258 1238
1259static void __devinit init_timers_cpu(int cpu) 1239static int __devinit init_timers_cpu(int cpu)
1260{ 1240{
1261 int j; 1241 int j;
1262 tvec_base_t *base; 1242 tvec_base_t *base;
1263 1243
1264 base = &per_cpu(tvec_bases, cpu); 1244 base = per_cpu(tvec_bases, cpu);
1245 if (!base) {
1246 static char boot_done;
1247
1248 /*
1249 * Cannot do allocation in init_timers as that runs before the
1250 * allocator initializes (and would waste memory if there are
1251 * more possible CPUs than will ever be installed/brought up).
1252 */
1253 if (boot_done) {
1254 base = kmalloc_node(sizeof(*base), GFP_KERNEL,
1255 cpu_to_node(cpu));
1256 if (!base)
1257 return -ENOMEM;
1258 memset(base, 0, sizeof(*base));
1259 } else {
1260 base = &boot_tvec_bases;
1261 boot_done = 1;
1262 }
1263 per_cpu(tvec_bases, cpu) = base;
1264 }
1265 spin_lock_init(&base->t_base.lock); 1265 spin_lock_init(&base->t_base.lock);
1266 for (j = 0; j < TVN_SIZE; j++) { 1266 for (j = 0; j < TVN_SIZE; j++) {
1267 INIT_LIST_HEAD(base->tv5.vec + j); 1267 INIT_LIST_HEAD(base->tv5.vec + j);
@@ -1273,6 +1273,7 @@ static void __devinit init_timers_cpu(int cpu)
1273 INIT_LIST_HEAD(base->tv1.vec + j); 1273 INIT_LIST_HEAD(base->tv1.vec + j);
1274 1274
1275 base->timer_jiffies = jiffies; 1275 base->timer_jiffies = jiffies;
1276 return 0;
1276} 1277}
1277 1278
1278#ifdef CONFIG_HOTPLUG_CPU 1279#ifdef CONFIG_HOTPLUG_CPU
@@ -1295,8 +1296,8 @@ static void __devinit migrate_timers(int cpu)
1295 int i; 1296 int i;
1296 1297
1297 BUG_ON(cpu_online(cpu)); 1298 BUG_ON(cpu_online(cpu));
1298 old_base = &per_cpu(tvec_bases, cpu); 1299 old_base = per_cpu(tvec_bases, cpu);
1299 new_base = &get_cpu_var(tvec_bases); 1300 new_base = get_cpu_var(tvec_bases);
1300 1301
1301 local_irq_disable(); 1302 local_irq_disable();
1302 spin_lock(&new_base->t_base.lock); 1303 spin_lock(&new_base->t_base.lock);
@@ -1326,7 +1327,8 @@ static int __devinit timer_cpu_notify(struct notifier_block *self,
1326 long cpu = (long)hcpu; 1327 long cpu = (long)hcpu;
1327 switch(action) { 1328 switch(action) {
1328 case CPU_UP_PREPARE: 1329 case CPU_UP_PREPARE:
1329 init_timers_cpu(cpu); 1330 if (init_timers_cpu(cpu) < 0)
1331 return NOTIFY_BAD;
1330 break; 1332 break;
1331#ifdef CONFIG_HOTPLUG_CPU 1333#ifdef CONFIG_HOTPLUG_CPU
1332 case CPU_DEAD: 1334 case CPU_DEAD:
diff --git a/kernel/user.c b/kernel/user.c
index d9deae43a9ab..2116642f42c6 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -105,15 +105,19 @@ void free_uid(struct user_struct *up)
105{ 105{
106 unsigned long flags; 106 unsigned long flags;
107 107
108 if (!up)
109 return;
110
108 local_irq_save(flags); 111 local_irq_save(flags);
109 if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) { 112 if (atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
110 uid_hash_remove(up); 113 uid_hash_remove(up);
114 spin_unlock_irqrestore(&uidhash_lock, flags);
111 key_put(up->uid_keyring); 115 key_put(up->uid_keyring);
112 key_put(up->session_keyring); 116 key_put(up->session_keyring);
113 kmem_cache_free(uid_cachep, up); 117 kmem_cache_free(uid_cachep, up);
114 spin_unlock(&uidhash_lock); 118 } else {
119 local_irq_restore(flags);
115 } 120 }
116 local_irq_restore(flags);
117} 121}
118 122
119struct user_struct * alloc_uid(uid_t uid) 123struct user_struct * alloc_uid(uid_t uid)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a314e663d517..7e70ab13e191 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -78,13 +78,17 @@ config SCHEDSTATS
78 this adds. 78 this adds.
79 79
80config DEBUG_SLAB 80config DEBUG_SLAB
81 bool "Debug memory allocations" 81 bool "Debug slab memory allocations"
82 depends on DEBUG_KERNEL && SLAB 82 depends on DEBUG_KERNEL && SLAB
83 help 83 help
84 Say Y here to have the kernel do limited verification on memory 84 Say Y here to have the kernel do limited verification on memory
85 allocation as well as poisoning memory on free to catch use of freed 85 allocation as well as poisoning memory on free to catch use of freed
86 memory. This can make kmalloc/kfree-intensive workloads much slower. 86 memory. This can make kmalloc/kfree-intensive workloads much slower.
87 87
88config DEBUG_SLAB_LEAK
89 bool "Memory leak debugging"
90 depends on DEBUG_SLAB
91
88config DEBUG_PREEMPT 92config DEBUG_PREEMPT
89 bool "Debug preemptible kernel" 93 bool "Debug preemptible kernel"
90 depends on DEBUG_KERNEL && PREEMPT 94 depends on DEBUG_KERNEL && PREEMPT
@@ -195,6 +199,16 @@ config FRAME_POINTER
195 some architectures or if you use external debuggers. 199 some architectures or if you use external debuggers.
196 If you don't debug the kernel, you can say N. 200 If you don't debug the kernel, you can say N.
197 201
202config UNWIND_INFO
203 bool "Compile the kernel with frame unwind information"
204 depends on !IA64
205 depends on !MODULES || !(MIPS || PARISC || PPC || SUPERH || SPARC64 || V850)
206 help
207 If you say Y here the resulting kernel image will be slightly larger
208 but not slower, and it will give very useful debugging information.
209 If you don't debug the kernel, you can say N, but we may not be able
210 to solve problems without frame unwind information or frame pointers.
211
198config FORCED_INLINING 212config FORCED_INLINING
199 bool "Force gcc to inline functions marked 'inline'" 213 bool "Force gcc to inline functions marked 'inline'"
200 depends on DEBUG_KERNEL 214 depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 648b2c1242fd..f827e3c24ec0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -7,6 +7,8 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \ 7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 sha1.o 8 sha1.o
9 9
10lib-$(CONFIG_SMP) += cpumask.o
11
10lib-y += kobject.o kref.o kobject_uevent.o klist.o 12lib-y += kobject.o kref.o kobject_uevent.o klist.o
11 13
12obj-y += sort.o parser.o halfmd4.o iomap_copy.o 14obj-y += sort.o parser.o halfmd4.o iomap_copy.o
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 48e708381d44..8acab0e176ef 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -676,84 +676,143 @@ int bitmap_bitremap(int oldbit, const unsigned long *old,
676} 676}
677EXPORT_SYMBOL(bitmap_bitremap); 677EXPORT_SYMBOL(bitmap_bitremap);
678 678
679/** 679/*
680 * bitmap_find_free_region - find a contiguous aligned mem region 680 * Common code for bitmap_*_region() routines.
681 * @bitmap: an array of unsigned longs corresponding to the bitmap 681 * bitmap: array of unsigned longs corresponding to the bitmap
682 * @bits: number of bits in the bitmap 682 * pos: the beginning of the region
683 * @order: region size to find (size is actually 1<<order) 683 * order: region size (log base 2 of number of bits)
684 * reg_op: operation(s) to perform on that region of bitmap
684 * 685 *
685 * This is used to allocate a memory region from a bitmap. The idea is 686 * Can set, verify and/or release a region of bits in a bitmap,
686 * that the region has to be 1<<order sized and 1<<order aligned (this 687 * depending on which combination of REG_OP_* flag bits is set.
687 * makes the search algorithm much faster).
688 * 688 *
689 * The region is marked as set bits in the bitmap if a free one is 689 * A region of a bitmap is a sequence of bits in the bitmap, of
690 * found. 690 * some size '1 << order' (a power of two), aligned to that same
691 * '1 << order' power of two.
691 * 692 *
692 * Returns either beginning of region or negative error 693 * Returns 1 if REG_OP_ISFREE succeeds (region is all zero bits).
694 * Returns 0 in all other cases and reg_ops.
693 */ 695 */
694int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
695{
696 unsigned long mask;
697 int pages = 1 << order;
698 int i;
699 696
700 if(pages > BITS_PER_LONG) 697enum {
701 return -EINVAL; 698 REG_OP_ISFREE, /* true if region is all zero bits */
699 REG_OP_ALLOC, /* set all bits in region */
700 REG_OP_RELEASE, /* clear all bits in region */
701};
702 702
703 /* make a mask of the order */ 703static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op)
704 mask = (1ul << (pages - 1)); 704{
705 int nbits_reg; /* number of bits in region */
706 int index; /* index first long of region in bitmap */
707 int offset; /* bit offset region in bitmap[index] */
708 int nlongs_reg; /* num longs spanned by region in bitmap */
709 int nbitsinlong; /* num bits of region in each spanned long */
710 unsigned long mask; /* bitmask for one long of region */
711 int i; /* scans bitmap by longs */
712 int ret = 0; /* return value */
713
714 /*
715 * Either nlongs_reg == 1 (for small orders that fit in one long)
716 * or (offset == 0 && mask == ~0UL) (for larger multiword orders.)
717 */
718 nbits_reg = 1 << order;
719 index = pos / BITS_PER_LONG;
720 offset = pos - (index * BITS_PER_LONG);
721 nlongs_reg = BITS_TO_LONGS(nbits_reg);
722 nbitsinlong = min(nbits_reg, BITS_PER_LONG);
723
724 /*
725 * Can't do "mask = (1UL << nbitsinlong) - 1", as that
726 * overflows if nbitsinlong == BITS_PER_LONG.
727 */
728 mask = (1UL << (nbitsinlong - 1));
705 mask += mask - 1; 729 mask += mask - 1;
730 mask <<= offset;
706 731
707 /* run up the bitmap pages bits at a time */ 732 switch (reg_op) {
708 for (i = 0; i < bits; i += pages) { 733 case REG_OP_ISFREE:
709 int index = i/BITS_PER_LONG; 734 for (i = 0; i < nlongs_reg; i++) {
710 int offset = i - (index * BITS_PER_LONG); 735 if (bitmap[index + i] & mask)
711 if((bitmap[index] & (mask << offset)) == 0) { 736 goto done;
712 /* set region in bimap */
713 bitmap[index] |= (mask << offset);
714 return i;
715 } 737 }
738 ret = 1; /* all bits in region free (zero) */
739 break;
740
741 case REG_OP_ALLOC:
742 for (i = 0; i < nlongs_reg; i++)
743 bitmap[index + i] |= mask;
744 break;
745
746 case REG_OP_RELEASE:
747 for (i = 0; i < nlongs_reg; i++)
748 bitmap[index + i] &= ~mask;
749 break;
716 } 750 }
717 return -ENOMEM; 751done:
752 return ret;
753}
754
755/**
756 * bitmap_find_free_region - find a contiguous aligned mem region
757 * @bitmap: array of unsigned longs corresponding to the bitmap
758 * @bits: number of bits in the bitmap
759 * @order: region size (log base 2 of number of bits) to find
760 *
761 * Find a region of free (zero) bits in a @bitmap of @bits bits and
762 * allocate them (set them to one). Only consider regions of length
763 * a power (@order) of two, aligned to that power of two, which
764 * makes the search algorithm much faster.
765 *
766 * Return the bit offset in bitmap of the allocated region,
767 * or -errno on failure.
768 */
769int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
770{
771 int pos; /* scans bitmap by regions of size order */
772
773 for (pos = 0; pos < bits; pos += (1 << order))
774 if (__reg_op(bitmap, pos, order, REG_OP_ISFREE))
775 break;
776 if (pos == bits)
777 return -ENOMEM;
778 __reg_op(bitmap, pos, order, REG_OP_ALLOC);
779 return pos;
718} 780}
719EXPORT_SYMBOL(bitmap_find_free_region); 781EXPORT_SYMBOL(bitmap_find_free_region);
720 782
721/** 783/**
722 * bitmap_release_region - release allocated bitmap region 784 * bitmap_release_region - release allocated bitmap region
723 * @bitmap: a pointer to the bitmap 785 * @bitmap: array of unsigned longs corresponding to the bitmap
724 * @pos: the beginning of the region 786 * @pos: beginning of bit region to release
725 * @order: the order of the bits to release (number is 1<<order) 787 * @order: region size (log base 2 of number of bits) to release
726 * 788 *
727 * This is the complement to __bitmap_find_free_region and releases 789 * This is the complement to __bitmap_find_free_region and releases
728 * the found region (by clearing it in the bitmap). 790 * the found region (by clearing it in the bitmap).
791 *
792 * No return value.
729 */ 793 */
730void bitmap_release_region(unsigned long *bitmap, int pos, int order) 794void bitmap_release_region(unsigned long *bitmap, int pos, int order)
731{ 795{
732 int pages = 1 << order; 796 __reg_op(bitmap, pos, order, REG_OP_RELEASE);
733 unsigned long mask = (1ul << (pages - 1));
734 int index = pos/BITS_PER_LONG;
735 int offset = pos - (index * BITS_PER_LONG);
736 mask += mask - 1;
737 bitmap[index] &= ~(mask << offset);
738} 797}
739EXPORT_SYMBOL(bitmap_release_region); 798EXPORT_SYMBOL(bitmap_release_region);
740 799
800/**
801 * bitmap_allocate_region - allocate bitmap region
802 * @bitmap: array of unsigned longs corresponding to the bitmap
803 * @pos: beginning of bit region to allocate
804 * @order: region size (log base 2 of number of bits) to allocate
805 *
806 * Allocate (set bits in) a specified region of a bitmap.
807 *
808 * Return 0 on success, or -EBUSY if specified region wasn't
809 * free (not all bits were zero).
810 */
741int bitmap_allocate_region(unsigned long *bitmap, int pos, int order) 811int bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
742{ 812{
743 int pages = 1 << order; 813 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
744 unsigned long mask = (1ul << (pages - 1));
745 int index = pos/BITS_PER_LONG;
746 int offset = pos - (index * BITS_PER_LONG);
747
748 /* We don't do regions of pages > BITS_PER_LONG. The
749 * algorithm would be a simple look for multiple zeros in the
750 * array, but there's no driver today that needs this. If you
751 * trip this BUG(), you get to code it... */
752 BUG_ON(pages > BITS_PER_LONG);
753 mask += mask - 1;
754 if (bitmap[index] & (mask << offset))
755 return -EBUSY; 814 return -EBUSY;
756 bitmap[index] |= (mask << offset); 815 __reg_op(bitmap, pos, order, REG_OP_ALLOC);
757 return 0; 816 return 0;
758} 817}
759EXPORT_SYMBOL(bitmap_allocate_region); 818EXPORT_SYMBOL(bitmap_allocate_region);
diff --git a/lib/cpumask.c b/lib/cpumask.c
new file mode 100644
index 000000000000..3a67dc5ada7d
--- /dev/null
+++ b/lib/cpumask.c
@@ -0,0 +1,45 @@
1#include <linux/kernel.h>
2#include <linux/bitops.h>
3#include <linux/cpumask.h>
4#include <linux/module.h>
5
6int __first_cpu(const cpumask_t *srcp)
7{
8 return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
9}
10EXPORT_SYMBOL(__first_cpu);
11
12int __next_cpu(int n, const cpumask_t *srcp)
13{
14 return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
15}
16EXPORT_SYMBOL(__next_cpu);
17
18/*
19 * Find the highest possible smp_processor_id()
20 *
21 * Note: if we're prepared to assume that cpu_possible_map never changes
22 * (reasonable) then this function should cache its return value.
23 */
24int highest_possible_processor_id(void)
25{
26 unsigned int cpu;
27 unsigned highest = 0;
28
29 for_each_cpu_mask(cpu, cpu_possible_map)
30 highest = cpu;
31 return highest;
32}
33EXPORT_SYMBOL(highest_possible_processor_id);
34
35int __any_online_cpu(const cpumask_t *mask)
36{
37 int cpu;
38
39 for_each_cpu_mask(cpu, *mask) {
40 if (cpu_online(cpu))
41 break;
42 }
43 return cpu;
44}
45EXPORT_SYMBOL(__any_online_cpu);
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 1e5b17dc7e3d..7097bb239e40 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -37,7 +37,6 @@
37#else 37#else
38#define RADIX_TREE_MAP_SHIFT 3 /* For more stressful testing */ 38#define RADIX_TREE_MAP_SHIFT 3 /* For more stressful testing */
39#endif 39#endif
40#define RADIX_TREE_TAGS 2
41 40
42#define RADIX_TREE_MAP_SIZE (1UL << RADIX_TREE_MAP_SHIFT) 41#define RADIX_TREE_MAP_SIZE (1UL << RADIX_TREE_MAP_SHIFT)
43#define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1) 42#define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1)
@@ -48,7 +47,7 @@
48struct radix_tree_node { 47struct radix_tree_node {
49 unsigned int count; 48 unsigned int count;
50 void *slots[RADIX_TREE_MAP_SIZE]; 49 void *slots[RADIX_TREE_MAP_SIZE];
51 unsigned long tags[RADIX_TREE_TAGS][RADIX_TREE_TAG_LONGS]; 50 unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS];
52}; 51};
53 52
54struct radix_tree_path { 53struct radix_tree_path {
@@ -135,17 +134,20 @@ out:
135 return ret; 134 return ret;
136} 135}
137 136
138static inline void tag_set(struct radix_tree_node *node, int tag, int offset) 137static inline void tag_set(struct radix_tree_node *node, unsigned int tag,
138 int offset)
139{ 139{
140 __set_bit(offset, node->tags[tag]); 140 __set_bit(offset, node->tags[tag]);
141} 141}
142 142
143static inline void tag_clear(struct radix_tree_node *node, int tag, int offset) 143static inline void tag_clear(struct radix_tree_node *node, unsigned int tag,
144 int offset)
144{ 145{
145 __clear_bit(offset, node->tags[tag]); 146 __clear_bit(offset, node->tags[tag]);
146} 147}
147 148
148static inline int tag_get(struct radix_tree_node *node, int tag, int offset) 149static inline int tag_get(struct radix_tree_node *node, unsigned int tag,
150 int offset)
149{ 151{
150 return test_bit(offset, node->tags[tag]); 152 return test_bit(offset, node->tags[tag]);
151} 153}
@@ -154,7 +156,7 @@ static inline int tag_get(struct radix_tree_node *node, int tag, int offset)
154 * Returns 1 if any slot in the node has this tag set. 156 * Returns 1 if any slot in the node has this tag set.
155 * Otherwise returns 0. 157 * Otherwise returns 0.
156 */ 158 */
157static inline int any_tag_set(struct radix_tree_node *node, int tag) 159static inline int any_tag_set(struct radix_tree_node *node, unsigned int tag)
158{ 160{
159 int idx; 161 int idx;
160 for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) { 162 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)
180{ 182{
181 struct radix_tree_node *node; 183 struct radix_tree_node *node;
182 unsigned int height; 184 unsigned int height;
183 char tags[RADIX_TREE_TAGS]; 185 char tags[RADIX_TREE_MAX_TAGS];
184 int tag; 186 int tag;
185 187
186 /* Figure out what the height should be. */ 188 /* Figure out what the height should be. */
@@ -197,7 +199,7 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
197 * Prepare the tag status of the top-level node for propagation 199 * Prepare the tag status of the top-level node for propagation
198 * into the newly-pushed top-level node(s) 200 * into the newly-pushed top-level node(s)
199 */ 201 */
200 for (tag = 0; tag < RADIX_TREE_TAGS; tag++) { 202 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
201 tags[tag] = 0; 203 tags[tag] = 0;
202 if (any_tag_set(root->rnode, tag)) 204 if (any_tag_set(root->rnode, tag))
203 tags[tag] = 1; 205 tags[tag] = 1;
@@ -211,7 +213,7 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
211 node->slots[0] = root->rnode; 213 node->slots[0] = root->rnode;
212 214
213 /* Propagate the aggregated tag info into the new root */ 215 /* Propagate the aggregated tag info into the new root */
214 for (tag = 0; tag < RADIX_TREE_TAGS; tag++) { 216 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
215 if (tags[tag]) 217 if (tags[tag])
216 tag_set(node, tag, 0); 218 tag_set(node, tag, 0);
217 } 219 }
@@ -349,14 +351,15 @@ EXPORT_SYMBOL(radix_tree_lookup);
349 * @index: index key 351 * @index: index key
350 * @tag: tag index 352 * @tag: tag index
351 * 353 *
352 * Set the search tag corresponging to @index in the radix tree. From 354 * Set the search tag (which must be < RADIX_TREE_MAX_TAGS)
355 * corresponding to @index in the radix tree. From
353 * the root all the way down to the leaf node. 356 * the root all the way down to the leaf node.
354 * 357 *
355 * Returns the address of the tagged item. Setting a tag on a not-present 358 * Returns the address of the tagged item. Setting a tag on a not-present
356 * item is a bug. 359 * item is a bug.
357 */ 360 */
358void *radix_tree_tag_set(struct radix_tree_root *root, 361void *radix_tree_tag_set(struct radix_tree_root *root,
359 unsigned long index, int tag) 362 unsigned long index, unsigned int tag)
360{ 363{
361 unsigned int height, shift; 364 unsigned int height, shift;
362 struct radix_tree_node *slot; 365 struct radix_tree_node *slot;
@@ -390,7 +393,8 @@ EXPORT_SYMBOL(radix_tree_tag_set);
390 * @index: index key 393 * @index: index key
391 * @tag: tag index 394 * @tag: tag index
392 * 395 *
393 * Clear the search tag corresponging to @index in the radix tree. If 396 * Clear the search tag (which must be < RADIX_TREE_MAX_TAGS)
397 * corresponding to @index in the radix tree. If
394 * this causes the leaf node to have no tags set then clear the tag in the 398 * this causes the leaf node to have no tags set then clear the tag in the
395 * next-to-leaf node, etc. 399 * next-to-leaf node, etc.
396 * 400 *
@@ -398,7 +402,7 @@ EXPORT_SYMBOL(radix_tree_tag_set);
398 * has the same return value and semantics as radix_tree_lookup(). 402 * has the same return value and semantics as radix_tree_lookup().
399 */ 403 */
400void *radix_tree_tag_clear(struct radix_tree_root *root, 404void *radix_tree_tag_clear(struct radix_tree_root *root,
401 unsigned long index, int tag) 405 unsigned long index, unsigned int tag)
402{ 406{
403 struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path; 407 struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path;
404 struct radix_tree_node *slot; 408 struct radix_tree_node *slot;
@@ -450,7 +454,7 @@ EXPORT_SYMBOL(radix_tree_tag_clear);
450 * radix_tree_tag_get - get a tag on a radix tree node 454 * radix_tree_tag_get - get a tag on a radix tree node
451 * @root: radix tree root 455 * @root: radix tree root
452 * @index: index key 456 * @index: index key
453 * @tag: tag index 457 * @tag: tag index (< RADIX_TREE_MAX_TAGS)
454 * 458 *
455 * Return values: 459 * Return values:
456 * 460 *
@@ -459,7 +463,7 @@ EXPORT_SYMBOL(radix_tree_tag_clear);
459 * -1: tag present, unset 463 * -1: tag present, unset
460 */ 464 */
461int radix_tree_tag_get(struct radix_tree_root *root, 465int radix_tree_tag_get(struct radix_tree_root *root,
462 unsigned long index, int tag) 466 unsigned long index, unsigned int tag)
463{ 467{
464 unsigned int height, shift; 468 unsigned int height, shift;
465 struct radix_tree_node *slot; 469 struct radix_tree_node *slot;
@@ -592,7 +596,7 @@ EXPORT_SYMBOL(radix_tree_gang_lookup);
592 */ 596 */
593static unsigned int 597static unsigned int
594__lookup_tag(struct radix_tree_root *root, void **results, unsigned long index, 598__lookup_tag(struct radix_tree_root *root, void **results, unsigned long index,
595 unsigned int max_items, unsigned long *next_index, int tag) 599 unsigned int max_items, unsigned long *next_index, unsigned int tag)
596{ 600{
597 unsigned int nr_found = 0; 601 unsigned int nr_found = 0;
598 unsigned int shift; 602 unsigned int shift;
@@ -646,7 +650,7 @@ out:
646 * @results: where the results of the lookup are placed 650 * @results: where the results of the lookup are placed
647 * @first_index: start the lookup from this key 651 * @first_index: start the lookup from this key
648 * @max_items: place up to this many items at *results 652 * @max_items: place up to this many items at *results
649 * @tag: the tag index 653 * @tag: the tag index (< RADIX_TREE_MAX_TAGS)
650 * 654 *
651 * Performs an index-ascending scan of the tree for present items which 655 * Performs an index-ascending scan of the tree for present items which
652 * have the tag indexed by @tag set. Places the items at *@results and 656 * have the tag indexed by @tag set. Places the items at *@results and
@@ -654,7 +658,8 @@ out:
654 */ 658 */
655unsigned int 659unsigned int
656radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, 660radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
657 unsigned long first_index, unsigned int max_items, int tag) 661 unsigned long first_index, unsigned int max_items,
662 unsigned int tag)
658{ 663{
659 const unsigned long max_index = radix_tree_maxindex(root->height); 664 const unsigned long max_index = radix_tree_maxindex(root->height);
660 unsigned long cur_index = first_index; 665 unsigned long cur_index = first_index;
@@ -716,7 +721,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
716 struct radix_tree_node *slot; 721 struct radix_tree_node *slot;
717 unsigned int height, shift; 722 unsigned int height, shift;
718 void *ret = NULL; 723 void *ret = NULL;
719 char tags[RADIX_TREE_TAGS]; 724 char tags[RADIX_TREE_MAX_TAGS];
720 int nr_cleared_tags; 725 int nr_cleared_tags;
721 int tag; 726 int tag;
722 int offset; 727 int offset;
@@ -751,7 +756,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
751 * Clear all tags associated with the just-deleted item 756 * Clear all tags associated with the just-deleted item
752 */ 757 */
753 nr_cleared_tags = 0; 758 nr_cleared_tags = 0;
754 for (tag = 0; tag < RADIX_TREE_TAGS; tag++) { 759 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
755 tags[tag] = 1; 760 tags[tag] = 1;
756 if (tag_get(pathp->node, tag, pathp->offset)) { 761 if (tag_get(pathp->node, tag, pathp->offset)) {
757 tag_clear(pathp->node, tag, pathp->offset); 762 tag_clear(pathp->node, tag, pathp->offset);
@@ -763,7 +768,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
763 } 768 }
764 769
765 for (pathp--; nr_cleared_tags && pathp->node; pathp--) { 770 for (pathp--; nr_cleared_tags && pathp->node; pathp--) {
766 for (tag = 0; tag < RADIX_TREE_TAGS; tag++) { 771 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
767 if (tags[tag]) 772 if (tags[tag])
768 continue; 773 continue;
769 774
@@ -801,7 +806,7 @@ EXPORT_SYMBOL(radix_tree_delete);
801 * @root: radix tree root 806 * @root: radix tree root
802 * @tag: tag to test 807 * @tag: tag to test
803 */ 808 */
804int radix_tree_tagged(struct radix_tree_root *root, int tag) 809int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
805{ 810{
806 struct radix_tree_node *rnode; 811 struct radix_tree_node *rnode;
807 rnode = root->rnode; 812 rnode = root->rnode;
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 0af497b6b9a8..10625785eefd 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)
296 else 296 else
297 stride = 1; 297 stride = 1;
298 298
299 if (!nslots) 299 BUG_ON(!nslots);
300 BUG();
301 300
302 /* 301 /*
303 * Find suitable number of IO TLB entries size that will fit this 302 * 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,
416 case SYNC_FOR_CPU: 415 case SYNC_FOR_CPU:
417 if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) 416 if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
418 memcpy(buffer, dma_addr, size); 417 memcpy(buffer, dma_addr, size);
419 else if (dir != DMA_TO_DEVICE) 418 else
420 BUG(); 419 BUG_ON(dir != DMA_TO_DEVICE);
421 break; 420 break;
422 case SYNC_FOR_DEVICE: 421 case SYNC_FOR_DEVICE:
423 if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)) 422 if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
424 memcpy(dma_addr, buffer, size); 423 memcpy(dma_addr, buffer, size);
425 else if (dir != DMA_FROM_DEVICE) 424 else
426 BUG(); 425 BUG_ON(dir != DMA_FROM_DEVICE);
427 break; 426 break;
428 default: 427 default:
429 BUG(); 428 BUG();
@@ -529,8 +528,7 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
529 unsigned long dev_addr = virt_to_phys(ptr); 528 unsigned long dev_addr = virt_to_phys(ptr);
530 void *map; 529 void *map;
531 530
532 if (dir == DMA_NONE) 531 BUG_ON(dir == DMA_NONE);
533 BUG();
534 /* 532 /*
535 * If the pointer passed in happens to be in the device's DMA window, 533 * If the pointer passed in happens to be in the device's DMA window,
536 * we can safely return the device addr and not worry about bounce 534 * 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,
592{ 590{
593 char *dma_addr = phys_to_virt(dev_addr); 591 char *dma_addr = phys_to_virt(dev_addr);
594 592
595 if (dir == DMA_NONE) 593 BUG_ON(dir == DMA_NONE);
596 BUG();
597 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 594 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
598 unmap_single(hwdev, dma_addr, size, dir); 595 unmap_single(hwdev, dma_addr, size, dir);
599 else if (dir == DMA_FROM_DEVICE) 596 else if (dir == DMA_FROM_DEVICE)
@@ -616,8 +613,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
616{ 613{
617 char *dma_addr = phys_to_virt(dev_addr); 614 char *dma_addr = phys_to_virt(dev_addr);
618 615
619 if (dir == DMA_NONE) 616 BUG_ON(dir == DMA_NONE);
620 BUG();
621 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 617 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
622 sync_single(hwdev, dma_addr, size, dir, target); 618 sync_single(hwdev, dma_addr, size, dir, target);
623 else if (dir == DMA_FROM_DEVICE) 619 else if (dir == DMA_FROM_DEVICE)
@@ -648,8 +644,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
648{ 644{
649 char *dma_addr = phys_to_virt(dev_addr) + offset; 645 char *dma_addr = phys_to_virt(dev_addr) + offset;
650 646
651 if (dir == DMA_NONE) 647 BUG_ON(dir == DMA_NONE);
652 BUG();
653 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 648 if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
654 sync_single(hwdev, dma_addr, size, dir, target); 649 sync_single(hwdev, dma_addr, size, dir, target);
655 else if (dir == DMA_FROM_DEVICE) 650 else if (dir == DMA_FROM_DEVICE)
@@ -696,8 +691,7 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
696 unsigned long dev_addr; 691 unsigned long dev_addr;
697 int i; 692 int i;
698 693
699 if (dir == DMA_NONE) 694 BUG_ON(dir == DMA_NONE);
700 BUG();
701 695
702 for (i = 0; i < nelems; i++, sg++) { 696 for (i = 0; i < nelems; i++, sg++) {
703 addr = SG_ENT_VIRT_ADDRESS(sg); 697 addr = SG_ENT_VIRT_ADDRESS(sg);
@@ -730,8 +724,7 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
730{ 724{
731 int i; 725 int i;
732 726
733 if (dir == DMA_NONE) 727 BUG_ON(dir == DMA_NONE);
734 BUG();
735 728
736 for (i = 0; i < nelems; i++, sg++) 729 for (i = 0; i < nelems; i++, sg++)
737 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) 730 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
@@ -753,8 +746,7 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
753{ 746{
754 int i; 747 int i;
755 748
756 if (dir == DMA_NONE) 749 BUG_ON(dir == DMA_NONE);
757 BUG();
758 750
759 for (i = 0; i < nelems; i++, sg++) 751 for (i = 0; i < nelems; i++, sg++)
760 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) 752 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
diff --git a/mm/Kconfig b/mm/Kconfig
index bd80460360db..332f5c29b53a 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -138,8 +138,8 @@ config SPLIT_PTLOCK_CPUS
138# 138#
139config MIGRATION 139config MIGRATION
140 bool "Page migration" 140 bool "Page migration"
141 def_bool y if NUMA || SPARSEMEM || DISCONTIGMEM 141 def_bool y if NUMA
142 depends on SWAP 142 depends on SWAP && NUMA
143 help 143 help
144 Allows the migration of the physical location of pages of processes 144 Allows the migration of the physical location of pages of processes
145 while the virtual addresses are not changed. This is useful for 145 while the virtual addresses are not changed. This is useful for
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 35c32290f717..b55bd39fc5dd 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -152,7 +152,7 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
152 * 152 *
153 * NOTE: This function is _not_ reentrant. 153 * NOTE: This function is _not_ reentrant.
154 */ 154 */
155static void * __init 155void * __init
156__alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size, 156__alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
157 unsigned long align, unsigned long goal, unsigned long limit) 157 unsigned long align, unsigned long goal, unsigned long limit)
158{ 158{
diff --git a/mm/fadvise.c b/mm/fadvise.c
index d257c89e7704..907c39257ca0 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -15,6 +15,7 @@
15#include <linux/backing-dev.h> 15#include <linux/backing-dev.h>
16#include <linux/pagevec.h> 16#include <linux/pagevec.h>
17#include <linux/fadvise.h> 17#include <linux/fadvise.h>
18#include <linux/writeback.h>
18#include <linux/syscalls.h> 19#include <linux/syscalls.h>
19 20
20#include <asm/unistd.h> 21#include <asm/unistd.h>
@@ -22,13 +23,36 @@
22/* 23/*
23 * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could 24 * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
24 * deactivate the pages and clear PG_Referenced. 25 * deactivate the pages and clear PG_Referenced.
26 *
27 * LINUX_FADV_ASYNC_WRITE: start async writeout of any dirty pages between file
28 * offsets `offset' and `offset+len' inclusive. Any pages which are currently
29 * under writeout are skipped, whether or not they are dirty.
30 *
31 * LINUX_FADV_WRITE_WAIT: wait upon writeout of any dirty pages between file
32 * offsets `offset' and `offset+len'.
33 *
34 * By combining these two operations the application may do several things:
35 *
36 * LINUX_FADV_ASYNC_WRITE: push some or all of the dirty pages at the disk.
37 *
38 * LINUX_FADV_WRITE_WAIT, LINUX_FADV_ASYNC_WRITE: push all of the currently
39 * dirty pages at the disk.
40 *
41 * LINUX_FADV_WRITE_WAIT, LINUX_FADV_ASYNC_WRITE, LINUX_FADV_WRITE_WAIT: push
42 * all of the currently dirty pages at the disk, wait until they have been
43 * written.
44 *
45 * It should be noted that none of these operations write out the file's
46 * metadata. So unless the application is strictly performing overwrites of
47 * already-instantiated disk blocks, there are no guarantees here that the data
48 * will be available after a crash.
25 */ 49 */
26asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) 50asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
27{ 51{
28 struct file *file = fget(fd); 52 struct file *file = fget(fd);
29 struct address_space *mapping; 53 struct address_space *mapping;
30 struct backing_dev_info *bdi; 54 struct backing_dev_info *bdi;
31 loff_t endbyte; 55 loff_t endbyte; /* inclusive */
32 pgoff_t start_index; 56 pgoff_t start_index;
33 pgoff_t end_index; 57 pgoff_t end_index;
34 unsigned long nrpages; 58 unsigned long nrpages;
@@ -56,6 +80,8 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
56 endbyte = offset + len; 80 endbyte = offset + len;
57 if (!len || endbyte < len) 81 if (!len || endbyte < len)
58 endbyte = -1; 82 endbyte = -1;
83 else
84 endbyte--; /* inclusive */
59 85
60 bdi = mapping->backing_dev_info; 86 bdi = mapping->backing_dev_info;
61 87
@@ -78,7 +104,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
78 104
79 /* First and last PARTIAL page! */ 105 /* First and last PARTIAL page! */
80 start_index = offset >> PAGE_CACHE_SHIFT; 106 start_index = offset >> PAGE_CACHE_SHIFT;
81 end_index = (endbyte-1) >> PAGE_CACHE_SHIFT; 107 end_index = endbyte >> PAGE_CACHE_SHIFT;
82 108
83 /* Careful about overflow on the "+1" */ 109 /* Careful about overflow on the "+1" */
84 nrpages = end_index - start_index + 1; 110 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)
96 filemap_flush(mapping); 122 filemap_flush(mapping);
97 123
98 /* First and last FULL page! */ 124 /* First and last FULL page! */
99 start_index = (offset + (PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT; 125 start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT;
100 end_index = (endbyte >> PAGE_CACHE_SHIFT); 126 end_index = (endbyte >> PAGE_CACHE_SHIFT);
101 127
102 if (end_index > start_index) 128 if (end_index >= start_index)
103 invalidate_mapping_pages(mapping, start_index, end_index-1); 129 invalidate_mapping_pages(mapping, start_index,
130 end_index);
131 break;
132 case LINUX_FADV_ASYNC_WRITE:
133 ret = __filemap_fdatawrite_range(mapping, offset, endbyte,
134 WB_SYNC_NONE);
135 break;
136 case LINUX_FADV_WRITE_WAIT:
137 ret = wait_on_page_writeback_range(mapping,
138 offset >> PAGE_CACHE_SHIFT,
139 endbyte >> PAGE_CACHE_SHIFT);
104 break; 140 break;
105 default: 141 default:
106 ret = -EINVAL; 142 ret = -EINVAL;
diff --git a/mm/filemap.c b/mm/filemap.c
index e8f58f7dd7a5..3ef20739e725 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -29,6 +29,7 @@
29#include <linux/blkdev.h> 29#include <linux/blkdev.h>
30#include <linux/security.h> 30#include <linux/security.h>
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32#include <linux/cpuset.h>
32#include "filemap.h" 33#include "filemap.h"
33#include "internal.h" 34#include "internal.h"
34 35
@@ -174,7 +175,7 @@ static int sync_page(void *word)
174 * dirty pages that lie within the byte offsets <start, end> 175 * dirty pages that lie within the byte offsets <start, end>
175 * @mapping: address space structure to write 176 * @mapping: address space structure to write
176 * @start: offset in bytes where the range starts 177 * @start: offset in bytes where the range starts
177 * @end: offset in bytes where the range ends 178 * @end: offset in bytes where the range ends (inclusive)
178 * @sync_mode: enable synchronous operation 179 * @sync_mode: enable synchronous operation
179 * 180 *
180 * If sync_mode is WB_SYNC_ALL then this is a "data integrity" operation, as 181 * 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)
182 * these two operations is that if a dirty page/buffer is encountered, it must 183 * these two operations is that if a dirty page/buffer is encountered, it must
183 * be waited upon, and not just skipped over. 184 * be waited upon, and not just skipped over.
184 */ 185 */
185static int __filemap_fdatawrite_range(struct address_space *mapping, 186int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
186 loff_t start, loff_t end, int sync_mode) 187 loff_t end, int sync_mode)
187{ 188{
188 int ret; 189 int ret;
189 struct writeback_control wbc = { 190 struct writeback_control wbc = {
@@ -212,8 +213,8 @@ int filemap_fdatawrite(struct address_space *mapping)
212} 213}
213EXPORT_SYMBOL(filemap_fdatawrite); 214EXPORT_SYMBOL(filemap_fdatawrite);
214 215
215static int filemap_fdatawrite_range(struct address_space *mapping, 216static int filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
216 loff_t start, loff_t end) 217 loff_t end)
217{ 218{
218 return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL); 219 return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL);
219} 220}
@@ -232,7 +233,7 @@ EXPORT_SYMBOL(filemap_flush);
232 * Wait for writeback to complete against pages indexed by start->end 233 * Wait for writeback to complete against pages indexed by start->end
233 * inclusive 234 * inclusive
234 */ 235 */
235static int wait_on_page_writeback_range(struct address_space *mapping, 236int wait_on_page_writeback_range(struct address_space *mapping,
236 pgoff_t start, pgoff_t end) 237 pgoff_t start, pgoff_t end)
237{ 238{
238 struct pagevec pvec; 239 struct pagevec pvec;
@@ -367,6 +368,12 @@ int filemap_write_and_wait(struct address_space *mapping)
367} 368}
368EXPORT_SYMBOL(filemap_write_and_wait); 369EXPORT_SYMBOL(filemap_write_and_wait);
369 370
371/*
372 * Write out and wait upon file offsets lstart->lend, inclusive.
373 *
374 * Note that `lend' is inclusive (describes the last byte to be written) so
375 * that this function can be used to write to the very end-of-file (end = -1).
376 */
370int filemap_write_and_wait_range(struct address_space *mapping, 377int filemap_write_and_wait_range(struct address_space *mapping,
371 loff_t lstart, loff_t lend) 378 loff_t lstart, loff_t lend)
372{ 379{
@@ -427,6 +434,28 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
427 return ret; 434 return ret;
428} 435}
429 436
437#ifdef CONFIG_NUMA
438struct page *page_cache_alloc(struct address_space *x)
439{
440 if (cpuset_do_page_mem_spread()) {
441 int n = cpuset_mem_spread_node();
442 return alloc_pages_node(n, mapping_gfp_mask(x), 0);
443 }
444 return alloc_pages(mapping_gfp_mask(x), 0);
445}
446EXPORT_SYMBOL(page_cache_alloc);
447
448struct page *page_cache_alloc_cold(struct address_space *x)
449{
450 if (cpuset_do_page_mem_spread()) {
451 int n = cpuset_mem_spread_node();
452 return alloc_pages_node(n, mapping_gfp_mask(x)|__GFP_COLD, 0);
453 }
454 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
455}
456EXPORT_SYMBOL(page_cache_alloc_cold);
457#endif
458
430/* 459/*
431 * In order to wait for pages to become available there must be 460 * In order to wait for pages to become available there must be
432 * waitqueues associated with pages. By using a hash table of 461 * waitqueues associated with pages. By using a hash table of
diff --git a/mm/memory.c b/mm/memory.c
index 80c3fb370f91..e347e106ca3a 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_
395 return NULL; 395 return NULL;
396 } 396 }
397 397
398#ifdef CONFIG_DEBUG_VM 398 /*
399 * Add some anal sanity checks for now. Eventually,
400 * we should just do "return pfn_to_page(pfn)", but
401 * in the meantime we check that we get a valid pfn,
402 * and that the resulting page looks ok.
403 */
399 if (unlikely(!pfn_valid(pfn))) { 404 if (unlikely(!pfn_valid(pfn))) {
400 print_bad_pte(vma, pte, addr); 405 print_bad_pte(vma, pte, addr);
401 return NULL; 406 return NULL;
402 } 407 }
403#endif
404 408
405 /* 409 /*
406 * NOTE! We still have PageReserved() pages in the page 410 * NOTE! We still have PageReserved() pages in the page
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e93cc740c22b..4f71cfd29c6f 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -422,6 +422,37 @@ static int contextualize_policy(int mode, nodemask_t *nodes)
422 return mpol_check_policy(mode, nodes); 422 return mpol_check_policy(mode, nodes);
423} 423}
424 424
425
426/*
427 * Update task->flags PF_MEMPOLICY bit: set iff non-default
428 * mempolicy. Allows more rapid checking of this (combined perhaps
429 * with other PF_* flag bits) on memory allocation hot code paths.
430 *
431 * If called from outside this file, the task 'p' should -only- be
432 * a newly forked child not yet visible on the task list, because
433 * manipulating the task flags of a visible task is not safe.
434 *
435 * The above limitation is why this routine has the funny name
436 * mpol_fix_fork_child_flag().
437 *
438 * It is also safe to call this with a task pointer of current,
439 * which the static wrapper mpol_set_task_struct_flag() does,
440 * for use within this file.
441 */
442
443void mpol_fix_fork_child_flag(struct task_struct *p)
444{
445 if (p->mempolicy)
446 p->flags |= PF_MEMPOLICY;
447 else
448 p->flags &= ~PF_MEMPOLICY;
449}
450
451static void mpol_set_task_struct_flag(void)
452{
453 mpol_fix_fork_child_flag(current);
454}
455
425/* Set the process memory policy */ 456/* Set the process memory policy */
426long do_set_mempolicy(int mode, nodemask_t *nodes) 457long do_set_mempolicy(int mode, nodemask_t *nodes)
427{ 458{
@@ -434,6 +465,7 @@ long do_set_mempolicy(int mode, nodemask_t *nodes)
434 return PTR_ERR(new); 465 return PTR_ERR(new);
435 mpol_free(current->mempolicy); 466 mpol_free(current->mempolicy);
436 current->mempolicy = new; 467 current->mempolicy = new;
468 mpol_set_task_struct_flag();
437 if (new && new->policy == MPOL_INTERLEAVE) 469 if (new && new->policy == MPOL_INTERLEAVE)
438 current->il_next = first_node(new->v.nodes); 470 current->il_next = first_node(new->v.nodes);
439 return 0; 471 return 0;
diff --git a/mm/mmap.c b/mm/mmap.c
index 0eb9894db6de..4f5b5709136a 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1040,12 +1040,11 @@ munmap_back:
1040 * specific mapper. the address has already been validated, but 1040 * specific mapper. the address has already been validated, but
1041 * not unmapped, but the maps are removed from the list. 1041 * not unmapped, but the maps are removed from the list.
1042 */ 1042 */
1043 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 1043 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
1044 if (!vma) { 1044 if (!vma) {
1045 error = -ENOMEM; 1045 error = -ENOMEM;
1046 goto unacct_error; 1046 goto unacct_error;
1047 } 1047 }
1048 memset(vma, 0, sizeof(*vma));
1049 1048
1050 vma->vm_mm = mm; 1049 vma->vm_mm = mm;
1051 vma->vm_start = addr; 1050 vma->vm_start = addr;
@@ -1896,12 +1895,11 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
1896 /* 1895 /*
1897 * create a vma struct for an anonymous mapping 1896 * create a vma struct for an anonymous mapping
1898 */ 1897 */
1899 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 1898 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
1900 if (!vma) { 1899 if (!vma) {
1901 vm_unacct_memory(len >> PAGE_SHIFT); 1900 vm_unacct_memory(len >> PAGE_SHIFT);
1902 return -ENOMEM; 1901 return -ENOMEM;
1903 } 1902 }
1904 memset(vma, 0, sizeof(*vma));
1905 1903
1906 vma->vm_mm = mm; 1904 vma->vm_mm = mm;
1907 vma->vm_start = addr; 1905 vma->vm_start = addr;
diff --git a/mm/msync.c b/mm/msync.c
index 3563a56e1a51..bc6c95376366 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -9,20 +9,24 @@
9 */ 9 */
10#include <linux/slab.h> 10#include <linux/slab.h>
11#include <linux/pagemap.h> 11#include <linux/pagemap.h>
12#include <linux/fs.h>
12#include <linux/mm.h> 13#include <linux/mm.h>
13#include <linux/mman.h> 14#include <linux/mman.h>
14#include <linux/hugetlb.h> 15#include <linux/hugetlb.h>
16#include <linux/writeback.h>
17#include <linux/file.h>
15#include <linux/syscalls.h> 18#include <linux/syscalls.h>
16 19
17#include <asm/pgtable.h> 20#include <asm/pgtable.h>
18#include <asm/tlbflush.h> 21#include <asm/tlbflush.h>
19 22
20static void msync_pte_range(struct vm_area_struct *vma, pmd_t *pmd, 23static unsigned long msync_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
21 unsigned long addr, unsigned long end) 24 unsigned long addr, unsigned long end)
22{ 25{
23 pte_t *pte; 26 pte_t *pte;
24 spinlock_t *ptl; 27 spinlock_t *ptl;
25 int progress = 0; 28 int progress = 0;
29 unsigned long ret = 0;
26 30
27again: 31again:
28 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 32 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
@@ -43,58 +47,64 @@ again:
43 if (!page) 47 if (!page)
44 continue; 48 continue;
45 if (ptep_clear_flush_dirty(vma, addr, pte) || 49 if (ptep_clear_flush_dirty(vma, addr, pte) ||
46 page_test_and_clear_dirty(page)) 50 page_test_and_clear_dirty(page))
47 set_page_dirty(page); 51 ret += set_page_dirty(page);
48 progress += 3; 52 progress += 3;
49 } while (pte++, addr += PAGE_SIZE, addr != end); 53 } while (pte++, addr += PAGE_SIZE, addr != end);
50 pte_unmap_unlock(pte - 1, ptl); 54 pte_unmap_unlock(pte - 1, ptl);
51 cond_resched(); 55 cond_resched();
52 if (addr != end) 56 if (addr != end)
53 goto again; 57 goto again;
58 return ret;
54} 59}
55 60
56static inline void msync_pmd_range(struct vm_area_struct *vma, pud_t *pud, 61static inline unsigned long msync_pmd_range(struct vm_area_struct *vma,
57 unsigned long addr, unsigned long end) 62 pud_t *pud, unsigned long addr, unsigned long end)
58{ 63{
59 pmd_t *pmd; 64 pmd_t *pmd;
60 unsigned long next; 65 unsigned long next;
66 unsigned long ret = 0;
61 67
62 pmd = pmd_offset(pud, addr); 68 pmd = pmd_offset(pud, addr);
63 do { 69 do {
64 next = pmd_addr_end(addr, end); 70 next = pmd_addr_end(addr, end);
65 if (pmd_none_or_clear_bad(pmd)) 71 if (pmd_none_or_clear_bad(pmd))
66 continue; 72 continue;
67 msync_pte_range(vma, pmd, addr, next); 73 ret += msync_pte_range(vma, pmd, addr, next);
68 } while (pmd++, addr = next, addr != end); 74 } while (pmd++, addr = next, addr != end);
75 return ret;
69} 76}
70 77
71static inline void msync_pud_range(struct vm_area_struct *vma, pgd_t *pgd, 78static inline unsigned long msync_pud_range(struct vm_area_struct *vma,
72 unsigned long addr, unsigned long end) 79 pgd_t *pgd, unsigned long addr, unsigned long end)
73{ 80{
74 pud_t *pud; 81 pud_t *pud;
75 unsigned long next; 82 unsigned long next;
83 unsigned long ret = 0;
76 84
77 pud = pud_offset(pgd, addr); 85 pud = pud_offset(pgd, addr);
78 do { 86 do {
79 next = pud_addr_end(addr, end); 87 next = pud_addr_end(addr, end);
80 if (pud_none_or_clear_bad(pud)) 88 if (pud_none_or_clear_bad(pud))
81 continue; 89 continue;
82 msync_pmd_range(vma, pud, addr, next); 90 ret += msync_pmd_range(vma, pud, addr, next);
83 } while (pud++, addr = next, addr != end); 91 } while (pud++, addr = next, addr != end);
92 return ret;
84} 93}
85 94
86static void msync_page_range(struct vm_area_struct *vma, 95static unsigned long msync_page_range(struct vm_area_struct *vma,
87 unsigned long addr, unsigned long end) 96 unsigned long addr, unsigned long end)
88{ 97{
89 pgd_t *pgd; 98 pgd_t *pgd;
90 unsigned long next; 99 unsigned long next;
100 unsigned long ret = 0;
91 101
92 /* For hugepages we can't go walking the page table normally, 102 /* For hugepages we can't go walking the page table normally,
93 * but that's ok, hugetlbfs is memory based, so we don't need 103 * but that's ok, hugetlbfs is memory based, so we don't need
94 * to do anything more on an msync(). 104 * to do anything more on an msync().
95 */ 105 */
96 if (vma->vm_flags & VM_HUGETLB) 106 if (vma->vm_flags & VM_HUGETLB)
97 return; 107 return 0;
98 108
99 BUG_ON(addr >= end); 109 BUG_ON(addr >= end);
100 pgd = pgd_offset(vma->vm_mm, addr); 110 pgd = pgd_offset(vma->vm_mm, addr);
@@ -103,8 +113,9 @@ static void msync_page_range(struct vm_area_struct *vma,
103 next = pgd_addr_end(addr, end); 113 next = pgd_addr_end(addr, end);
104 if (pgd_none_or_clear_bad(pgd)) 114 if (pgd_none_or_clear_bad(pgd))
105 continue; 115 continue;
106 msync_pud_range(vma, pgd, addr, next); 116 ret += msync_pud_range(vma, pgd, addr, next);
107 } while (pgd++, addr = next, addr != end); 117 } while (pgd++, addr = next, addr != end);
118 return ret;
108} 119}
109 120
110/* 121/*
@@ -115,53 +126,31 @@ static void msync_page_range(struct vm_area_struct *vma,
115 * write out the dirty pages and wait on the writeout and check the result. 126 * write out the dirty pages and wait on the writeout and check the result.
116 * Or the application may run fadvise(FADV_DONTNEED) against the fd to start 127 * Or the application may run fadvise(FADV_DONTNEED) against the fd to start
117 * async writeout immediately. 128 * async writeout immediately.
118 * So my _not_ starting I/O in MS_ASYNC we provide complete flexibility to 129 * So by _not_ starting I/O in MS_ASYNC we provide complete flexibility to
119 * applications. 130 * applications.
120 */ 131 */
121static int msync_interval(struct vm_area_struct *vma, 132static int msync_interval(struct vm_area_struct *vma, unsigned long addr,
122 unsigned long addr, unsigned long end, int flags) 133 unsigned long end, int flags,
134 unsigned long *nr_pages_dirtied)
123{ 135{
124 int ret = 0;
125 struct file *file = vma->vm_file; 136 struct file *file = vma->vm_file;
126 137
127 if ((flags & MS_INVALIDATE) && (vma->vm_flags & VM_LOCKED)) 138 if ((flags & MS_INVALIDATE) && (vma->vm_flags & VM_LOCKED))
128 return -EBUSY; 139 return -EBUSY;
129 140
130 if (file && (vma->vm_flags & VM_SHARED)) { 141 if (file && (vma->vm_flags & VM_SHARED))
131 msync_page_range(vma, addr, end); 142 *nr_pages_dirtied = msync_page_range(vma, addr, end);
132 143 return 0;
133 if (flags & MS_SYNC) {
134 struct address_space *mapping = file->f_mapping;
135 int err;
136
137 ret = filemap_fdatawrite(mapping);
138 if (file->f_op && file->f_op->fsync) {
139 /*
140 * We don't take i_mutex here because mmap_sem
141 * is already held.
142 */
143 err = file->f_op->fsync(file,file->f_dentry,1);
144 if (err && !ret)
145 ret = err;
146 }
147 err = filemap_fdatawait(mapping);
148 if (!ret)
149 ret = err;
150 }
151 }
152 return ret;
153} 144}
154 145
155asmlinkage long sys_msync(unsigned long start, size_t len, int flags) 146asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
156{ 147{
157 unsigned long end; 148 unsigned long end;
158 struct vm_area_struct *vma; 149 struct vm_area_struct *vma;
159 int unmapped_error, error = -EINVAL; 150 int unmapped_error = 0;
160 151 int error = -EINVAL;
161 if (flags & MS_SYNC) 152 int done = 0;
162 current->flags |= PF_SYNCWRITE;
163 153
164 down_read(&current->mm->mmap_sem);
165 if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC)) 154 if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
166 goto out; 155 goto out;
167 if (start & ~PAGE_MASK) 156 if (start & ~PAGE_MASK)
@@ -180,13 +169,18 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
180 * If the interval [start,end) covers some unmapped address ranges, 169 * If the interval [start,end) covers some unmapped address ranges,
181 * just ignore them, but return -ENOMEM at the end. 170 * just ignore them, but return -ENOMEM at the end.
182 */ 171 */
172 down_read(&current->mm->mmap_sem);
173 if (flags & MS_SYNC)
174 current->flags |= PF_SYNCWRITE;
183 vma = find_vma(current->mm, start); 175 vma = find_vma(current->mm, start);
184 unmapped_error = 0; 176 if (!vma) {
185 for (;;) {
186 /* Still start < end. */
187 error = -ENOMEM; 177 error = -ENOMEM;
188 if (!vma) 178 goto out_unlock;
189 goto out; 179 }
180 do {
181 unsigned long nr_pages_dirtied = 0;
182 struct file *file;
183
190 /* Here start < vma->vm_end. */ 184 /* Here start < vma->vm_end. */
191 if (start < vma->vm_start) { 185 if (start < vma->vm_start) {
192 unmapped_error = -ENOMEM; 186 unmapped_error = -ENOMEM;
@@ -195,22 +189,47 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
195 /* Here vma->vm_start <= start < vma->vm_end. */ 189 /* Here vma->vm_start <= start < vma->vm_end. */
196 if (end <= vma->vm_end) { 190 if (end <= vma->vm_end) {
197 if (start < end) { 191 if (start < end) {
198 error = msync_interval(vma, start, end, flags); 192 error = msync_interval(vma, start, end, flags,
193 &nr_pages_dirtied);
199 if (error) 194 if (error)
200 goto out; 195 goto out_unlock;
201 } 196 }
202 error = unmapped_error; 197 error = unmapped_error;
203 goto out; 198 done = 1;
199 } else {
200 /* Here vma->vm_start <= start < vma->vm_end < end. */
201 error = msync_interval(vma, start, vma->vm_end, flags,
202 &nr_pages_dirtied);
203 if (error)
204 goto out_unlock;
204 } 205 }
205 /* Here vma->vm_start <= start < vma->vm_end < end. */ 206 file = vma->vm_file;
206 error = msync_interval(vma, start, vma->vm_end, flags);
207 if (error)
208 goto out;
209 start = vma->vm_end; 207 start = vma->vm_end;
210 vma = vma->vm_next; 208 if ((flags & MS_ASYNC) && file && nr_pages_dirtied) {
211 } 209 get_file(file);
212out: 210 up_read(&current->mm->mmap_sem);
213 up_read(&current->mm->mmap_sem); 211 balance_dirty_pages_ratelimited_nr(file->f_mapping,
212 nr_pages_dirtied);
213 fput(file);
214 down_read(&current->mm->mmap_sem);
215 vma = find_vma(current->mm, start);
216 } else if ((flags & MS_SYNC) && file &&
217 (vma->vm_flags & VM_SHARED)) {
218 get_file(file);
219 up_read(&current->mm->mmap_sem);
220 error = do_fsync(file, 0);
221 fput(file);
222 down_read(&current->mm->mmap_sem);
223 if (error)
224 goto out_unlock;
225 vma = find_vma(current->mm, start);
226 } else {
227 vma = vma->vm_next;
228 }
229 } while (vma && !done);
230out_unlock:
214 current->flags &= ~PF_SYNCWRITE; 231 current->flags &= ~PF_SYNCWRITE;
232 up_read(&current->mm->mmap_sem);
233out:
215 return error; 234 return error;
216} 235}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 945559fb63d2..893d7677579e 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -75,12 +75,12 @@ int vm_dirty_ratio = 40;
75 * The interval between `kupdate'-style writebacks, in centiseconds 75 * The interval between `kupdate'-style writebacks, in centiseconds
76 * (hundredths of a second) 76 * (hundredths of a second)
77 */ 77 */
78int dirty_writeback_centisecs = 5 * 100; 78int dirty_writeback_interval = 5 * HZ;
79 79
80/* 80/*
81 * The longest number of centiseconds for which data is allowed to remain dirty 81 * The longest number of centiseconds for which data is allowed to remain dirty
82 */ 82 */
83int dirty_expire_centisecs = 30 * 100; 83int dirty_expire_interval = 30 * HZ;
84 84
85/* 85/*
86 * Flag that makes the machine dump writes/reads and block dirtyings. 86 * Flag that makes the machine dump writes/reads and block dirtyings.
@@ -88,7 +88,8 @@ int dirty_expire_centisecs = 30 * 100;
88int block_dump; 88int block_dump;
89 89
90/* 90/*
91 * Flag that puts the machine in "laptop mode". 91 * Flag that puts the machine in "laptop mode". Doubles as a timeout in jiffies:
92 * a full sync is triggered after this time elapses without any disk activity.
92 */ 93 */
93int laptop_mode; 94int laptop_mode;
94 95
@@ -255,8 +256,9 @@ static void balance_dirty_pages(struct address_space *mapping)
255} 256}
256 257
257/** 258/**
258 * balance_dirty_pages_ratelimited - balance dirty memory state 259 * balance_dirty_pages_ratelimited_nr - balance dirty memory state
259 * @mapping: address_space which was dirtied 260 * @mapping: address_space which was dirtied
261 * @nr_pages: number of pages which the caller has just dirtied
260 * 262 *
261 * Processes which are dirtying memory should call in here once for each page 263 * Processes which are dirtying memory should call in here once for each page
262 * which was newly dirtied. The function will periodically check the system's 264 * 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)
267 * limit we decrease the ratelimiting by a lot, to prevent individual processes 269 * limit we decrease the ratelimiting by a lot, to prevent individual processes
268 * from overshooting the limit by (ratelimit_pages) each. 270 * from overshooting the limit by (ratelimit_pages) each.
269 */ 271 */
270void balance_dirty_pages_ratelimited(struct address_space *mapping) 272void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
273 unsigned long nr_pages_dirtied)
271{ 274{
272 static DEFINE_PER_CPU(int, ratelimits) = 0; 275 static DEFINE_PER_CPU(unsigned long, ratelimits) = 0;
273 long ratelimit; 276 unsigned long ratelimit;
277 unsigned long *p;
274 278
275 ratelimit = ratelimit_pages; 279 ratelimit = ratelimit_pages;
276 if (dirty_exceeded) 280 if (dirty_exceeded)
@@ -280,15 +284,18 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping)
280 * Check the rate limiting. Also, we do not want to throttle real-time 284 * Check the rate limiting. Also, we do not want to throttle real-time
281 * tasks in balance_dirty_pages(). Period. 285 * tasks in balance_dirty_pages(). Period.
282 */ 286 */
283 if (get_cpu_var(ratelimits)++ >= ratelimit) { 287 preempt_disable();
284 __get_cpu_var(ratelimits) = 0; 288 p = &__get_cpu_var(ratelimits);
285 put_cpu_var(ratelimits); 289 *p += nr_pages_dirtied;
290 if (unlikely(*p >= ratelimit)) {
291 *p = 0;
292 preempt_enable();
286 balance_dirty_pages(mapping); 293 balance_dirty_pages(mapping);
287 return; 294 return;
288 } 295 }
289 put_cpu_var(ratelimits); 296 preempt_enable();
290} 297}
291EXPORT_SYMBOL(balance_dirty_pages_ratelimited); 298EXPORT_SYMBOL(balance_dirty_pages_ratelimited_nr);
292 299
293void throttle_vm_writeout(void) 300void throttle_vm_writeout(void)
294{ 301{
@@ -380,8 +387,8 @@ static DEFINE_TIMER(laptop_mode_wb_timer, laptop_timer_fn, 0, 0);
380 * just walks the superblock inode list, writing back any inodes which are 387 * just walks the superblock inode list, writing back any inodes which are
381 * older than a specific point in time. 388 * older than a specific point in time.
382 * 389 *
383 * Try to run once per dirty_writeback_centisecs. But if a writeback event 390 * Try to run once per dirty_writeback_interval. But if a writeback event
384 * takes longer than a dirty_writeback_centisecs interval, then leave a 391 * takes longer than a dirty_writeback_interval interval, then leave a
385 * one-second gap. 392 * one-second gap.
386 * 393 *
387 * older_than_this takes precedence over nr_to_write. So we'll only write back 394 * 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)
406 sync_supers(); 413 sync_supers();
407 414
408 get_writeback_state(&wbs); 415 get_writeback_state(&wbs);
409 oldest_jif = jiffies - (dirty_expire_centisecs * HZ) / 100; 416 oldest_jif = jiffies - dirty_expire_interval;
410 start_jif = jiffies; 417 start_jif = jiffies;
411 next_jif = start_jif + (dirty_writeback_centisecs * HZ) / 100; 418 next_jif = start_jif + dirty_writeback_interval;
412 nr_to_write = wbs.nr_dirty + wbs.nr_unstable + 419 nr_to_write = wbs.nr_dirty + wbs.nr_unstable +
413 (inodes_stat.nr_inodes - inodes_stat.nr_unused); 420 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
414 while (nr_to_write > 0) { 421 while (nr_to_write > 0) {
@@ -425,7 +432,7 @@ static void wb_kupdate(unsigned long arg)
425 } 432 }
426 if (time_before(next_jif, jiffies + HZ)) 433 if (time_before(next_jif, jiffies + HZ))
427 next_jif = jiffies + HZ; 434 next_jif = jiffies + HZ;
428 if (dirty_writeback_centisecs) 435 if (dirty_writeback_interval)
429 mod_timer(&wb_timer, next_jif); 436 mod_timer(&wb_timer, next_jif);
430} 437}
431 438
@@ -435,11 +442,11 @@ static void wb_kupdate(unsigned long arg)
435int dirty_writeback_centisecs_handler(ctl_table *table, int write, 442int dirty_writeback_centisecs_handler(ctl_table *table, int write,
436 struct file *file, void __user *buffer, size_t *length, loff_t *ppos) 443 struct file *file, void __user *buffer, size_t *length, loff_t *ppos)
437{ 444{
438 proc_dointvec(table, write, file, buffer, length, ppos); 445 proc_dointvec_userhz_jiffies(table, write, file, buffer, length, ppos);
439 if (dirty_writeback_centisecs) { 446 if (dirty_writeback_interval) {
440 mod_timer(&wb_timer, 447 mod_timer(&wb_timer,
441 jiffies + (dirty_writeback_centisecs * HZ) / 100); 448 jiffies + dirty_writeback_interval);
442 } else { 449 } else {
443 del_timer(&wb_timer); 450 del_timer(&wb_timer);
444 } 451 }
445 return 0; 452 return 0;
@@ -468,7 +475,7 @@ static void laptop_timer_fn(unsigned long unused)
468 */ 475 */
469void laptop_io_completion(void) 476void laptop_io_completion(void)
470{ 477{
471 mod_timer(&laptop_mode_wb_timer, jiffies + laptop_mode * HZ); 478 mod_timer(&laptop_mode_wb_timer, jiffies + laptop_mode);
472} 479}
473 480
474/* 481/*
@@ -544,7 +551,7 @@ void __init page_writeback_init(void)
544 if (vm_dirty_ratio <= 0) 551 if (vm_dirty_ratio <= 0)
545 vm_dirty_ratio = 1; 552 vm_dirty_ratio = 1;
546 } 553 }
547 mod_timer(&wb_timer, jiffies + (dirty_writeback_centisecs * HZ) / 100); 554 mod_timer(&wb_timer, jiffies + dirty_writeback_interval);
548 set_ratelimit(); 555 set_ratelimit();
549 register_cpu_notifier(&ratelimit_nb); 556 register_cpu_notifier(&ratelimit_nb);
550} 557}
@@ -621,8 +628,6 @@ EXPORT_SYMBOL(write_one_page);
621 */ 628 */
622int __set_page_dirty_nobuffers(struct page *page) 629int __set_page_dirty_nobuffers(struct page *page)
623{ 630{
624 int ret = 0;
625
626 if (!TestSetPageDirty(page)) { 631 if (!TestSetPageDirty(page)) {
627 struct address_space *mapping = page_mapping(page); 632 struct address_space *mapping = page_mapping(page);
628 struct address_space *mapping2; 633 struct address_space *mapping2;
@@ -644,8 +649,9 @@ int __set_page_dirty_nobuffers(struct page *page)
644 I_DIRTY_PAGES); 649 I_DIRTY_PAGES);
645 } 650 }
646 } 651 }
652 return 1;
647 } 653 }
648 return ret; 654 return 0;
649} 655}
650EXPORT_SYMBOL(__set_page_dirty_nobuffers); 656EXPORT_SYMBOL(__set_page_dirty_nobuffers);
651 657
@@ -675,8 +681,10 @@ int fastcall set_page_dirty(struct page *page)
675 return (*spd)(page); 681 return (*spd)(page);
676 return __set_page_dirty_buffers(page); 682 return __set_page_dirty_buffers(page);
677 } 683 }
678 if (!PageDirty(page)) 684 if (!PageDirty(page)) {
679 SetPageDirty(page); 685 if (!TestSetPageDirty(page))
686 return 1;
687 }
680 return 0; 688 return 0;
681} 689}
682EXPORT_SYMBOL(set_page_dirty); 690EXPORT_SYMBOL(set_page_dirty);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b7f14a4799a5..338a02bb004d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -943,7 +943,8 @@ restart:
943 goto got_pg; 943 goto got_pg;
944 944
945 do { 945 do {
946 wakeup_kswapd(*z, order); 946 if (cpuset_zone_allowed(*z, gfp_mask))
947 wakeup_kswapd(*z, order);
947 } while (*(++z)); 948 } while (*(++z));
948 949
949 /* 950 /*
@@ -2028,8 +2029,9 @@ static __meminit void zone_pcp_init(struct zone *zone)
2028 setup_pageset(zone_pcp(zone,cpu), batch); 2029 setup_pageset(zone_pcp(zone,cpu), batch);
2029#endif 2030#endif
2030 } 2031 }
2031 printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n", 2032 if (zone->present_pages)
2032 zone->name, zone->present_pages, batch); 2033 printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n",
2034 zone->name, zone->present_pages, batch);
2033} 2035}
2034 2036
2035static __meminit void init_currently_empty_zone(struct zone *zone, 2037static __meminit void init_currently_empty_zone(struct zone *zone,
@@ -2700,8 +2702,7 @@ void *__init alloc_large_system_hash(const char *tablename,
2700 else 2702 else
2701 numentries <<= (PAGE_SHIFT - scale); 2703 numentries <<= (PAGE_SHIFT - scale);
2702 } 2704 }
2703 /* rounded up to nearest power of 2 in size */ 2705 numentries = roundup_pow_of_two(numentries);
2704 numentries = 1UL << (long_log2(numentries) + 1);
2705 2706
2706 /* limit allocation size to 1/16 total memory by default */ 2707 /* limit allocation size to 1/16 total memory by default */
2707 if (max == 0) { 2708 if (max == 0) {
diff --git a/mm/slab.c b/mm/slab.c
index 1c8f5ee230d5..681837499d7d 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -94,6 +94,7 @@
94#include <linux/interrupt.h> 94#include <linux/interrupt.h>
95#include <linux/init.h> 95#include <linux/init.h>
96#include <linux/compiler.h> 96#include <linux/compiler.h>
97#include <linux/cpuset.h>
97#include <linux/seq_file.h> 98#include <linux/seq_file.h>
98#include <linux/notifier.h> 99#include <linux/notifier.h>
99#include <linux/kallsyms.h> 100#include <linux/kallsyms.h>
@@ -173,12 +174,12 @@
173 SLAB_CACHE_DMA | \ 174 SLAB_CACHE_DMA | \
174 SLAB_MUST_HWCACHE_ALIGN | SLAB_STORE_USER | \ 175 SLAB_MUST_HWCACHE_ALIGN | SLAB_STORE_USER | \
175 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ 176 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
176 SLAB_DESTROY_BY_RCU) 177 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD)
177#else 178#else
178# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \ 179# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \
179 SLAB_CACHE_DMA | SLAB_MUST_HWCACHE_ALIGN | \ 180 SLAB_CACHE_DMA | SLAB_MUST_HWCACHE_ALIGN | \
180 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ 181 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
181 SLAB_DESTROY_BY_RCU) 182 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD)
182#endif 183#endif
183 184
184/* 185/*
@@ -203,7 +204,8 @@
203typedef unsigned int kmem_bufctl_t; 204typedef unsigned int kmem_bufctl_t;
204#define BUFCTL_END (((kmem_bufctl_t)(~0U))-0) 205#define BUFCTL_END (((kmem_bufctl_t)(~0U))-0)
205#define BUFCTL_FREE (((kmem_bufctl_t)(~0U))-1) 206#define BUFCTL_FREE (((kmem_bufctl_t)(~0U))-1)
206#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-2) 207#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2)
208#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3)
207 209
208/* Max number of objs-per-slab for caches which use off-slab slabs. 210/* Max number of objs-per-slab for caches which use off-slab slabs.
209 * Needed to avoid a possible looping condition in cache_grow(). 211 * Needed to avoid a possible looping condition in cache_grow().
@@ -896,8 +898,33 @@ static struct array_cache *alloc_arraycache(int node, int entries,
896 return nc; 898 return nc;
897} 899}
898 900
901/*
902 * Transfer objects in one arraycache to another.
903 * Locking must be handled by the caller.
904 *
905 * Return the number of entries transferred.
906 */
907static int transfer_objects(struct array_cache *to,
908 struct array_cache *from, unsigned int max)
909{
910 /* Figure out how many entries to transfer */
911 int nr = min(min(from->avail, max), to->limit - to->avail);
912
913 if (!nr)
914 return 0;
915
916 memcpy(to->entry + to->avail, from->entry + from->avail -nr,
917 sizeof(void *) *nr);
918
919 from->avail -= nr;
920 to->avail += nr;
921 to->touched = 1;
922 return nr;
923}
924
899#ifdef CONFIG_NUMA 925#ifdef CONFIG_NUMA
900static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int); 926static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
927static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
901 928
902static struct array_cache **alloc_alien_cache(int node, int limit) 929static struct array_cache **alloc_alien_cache(int node, int limit)
903{ 930{
@@ -944,6 +971,13 @@ static void __drain_alien_cache(struct kmem_cache *cachep,
944 971
945 if (ac->avail) { 972 if (ac->avail) {
946 spin_lock(&rl3->list_lock); 973 spin_lock(&rl3->list_lock);
974 /*
975 * Stuff objects into the remote nodes shared array first.
976 * That way we could avoid the overhead of putting the objects
977 * into the free lists and getting them back later.
978 */
979 transfer_objects(rl3->shared, ac, ac->limit);
980
947 free_block(cachep, ac->entry, ac->avail, node); 981 free_block(cachep, ac->entry, ac->avail, node);
948 ac->avail = 0; 982 ac->avail = 0;
949 spin_unlock(&rl3->list_lock); 983 spin_unlock(&rl3->list_lock);
@@ -959,8 +993,8 @@ static void reap_alien(struct kmem_cache *cachep, struct kmem_list3 *l3)
959 993
960 if (l3->alien) { 994 if (l3->alien) {
961 struct array_cache *ac = l3->alien[node]; 995 struct array_cache *ac = l3->alien[node];
962 if (ac && ac->avail) { 996
963 spin_lock_irq(&ac->lock); 997 if (ac && ac->avail && spin_trylock_irq(&ac->lock)) {
964 __drain_alien_cache(cachep, ac, node); 998 __drain_alien_cache(cachep, ac, node);
965 spin_unlock_irq(&ac->lock); 999 spin_unlock_irq(&ac->lock);
966 } 1000 }
@@ -1987,10 +2021,9 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1987 align = ralign; 2021 align = ralign;
1988 2022
1989 /* Get cache's description obj. */ 2023 /* Get cache's description obj. */
1990 cachep = kmem_cache_alloc(&cache_cache, SLAB_KERNEL); 2024 cachep = kmem_cache_zalloc(&cache_cache, SLAB_KERNEL);
1991 if (!cachep) 2025 if (!cachep)
1992 goto oops; 2026 goto oops;
1993 memset(cachep, 0, sizeof(struct kmem_cache));
1994 2027
1995#if DEBUG 2028#if DEBUG
1996 cachep->obj_size = size; 2029 cachep->obj_size = size;
@@ -2397,7 +2430,7 @@ static void slab_put_obj(struct kmem_cache *cachep, struct slab *slabp,
2397 /* Verify that the slab belongs to the intended node */ 2430 /* Verify that the slab belongs to the intended node */
2398 WARN_ON(slabp->nodeid != nodeid); 2431 WARN_ON(slabp->nodeid != nodeid);
2399 2432
2400 if (slab_bufctl(slabp)[objnr] != BUFCTL_FREE) { 2433 if (slab_bufctl(slabp)[objnr] + 1 <= SLAB_LIMIT + 1) {
2401 printk(KERN_ERR "slab: double free detected in cache " 2434 printk(KERN_ERR "slab: double free detected in cache "
2402 "'%s', objp %p\n", cachep->name, objp); 2435 "'%s', objp %p\n", cachep->name, objp);
2403 BUG(); 2436 BUG();
@@ -2603,6 +2636,9 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
2603 */ 2636 */
2604 cachep->dtor(objp + obj_offset(cachep), cachep, 0); 2637 cachep->dtor(objp + obj_offset(cachep), cachep, 0);
2605 } 2638 }
2639#ifdef CONFIG_DEBUG_SLAB_LEAK
2640 slab_bufctl(slabp)[objnr] = BUFCTL_FREE;
2641#endif
2606 if (cachep->flags & SLAB_POISON) { 2642 if (cachep->flags & SLAB_POISON) {
2607#ifdef CONFIG_DEBUG_PAGEALLOC 2643#ifdef CONFIG_DEBUG_PAGEALLOC
2608 if ((cachep->buffer_size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) { 2644 if ((cachep->buffer_size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) {
@@ -2675,20 +2711,10 @@ retry:
2675 BUG_ON(ac->avail > 0 || !l3); 2711 BUG_ON(ac->avail > 0 || !l3);
2676 spin_lock(&l3->list_lock); 2712 spin_lock(&l3->list_lock);
2677 2713
2678 if (l3->shared) { 2714 /* See if we can refill from the shared array */
2679 struct array_cache *shared_array = l3->shared; 2715 if (l3->shared && transfer_objects(ac, l3->shared, batchcount))
2680 if (shared_array->avail) { 2716 goto alloc_done;
2681 if (batchcount > shared_array->avail) 2717
2682 batchcount = shared_array->avail;
2683 shared_array->avail -= batchcount;
2684 ac->avail = batchcount;
2685 memcpy(ac->entry,
2686 &(shared_array->entry[shared_array->avail]),
2687 sizeof(void *) * batchcount);
2688 shared_array->touched = 1;
2689 goto alloc_done;
2690 }
2691 }
2692 while (batchcount > 0) { 2718 while (batchcount > 0) {
2693 struct list_head *entry; 2719 struct list_head *entry;
2694 struct slab *slabp; 2720 struct slab *slabp;
@@ -2786,6 +2812,16 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
2786 *dbg_redzone1(cachep, objp) = RED_ACTIVE; 2812 *dbg_redzone1(cachep, objp) = RED_ACTIVE;
2787 *dbg_redzone2(cachep, objp) = RED_ACTIVE; 2813 *dbg_redzone2(cachep, objp) = RED_ACTIVE;
2788 } 2814 }
2815#ifdef CONFIG_DEBUG_SLAB_LEAK
2816 {
2817 struct slab *slabp;
2818 unsigned objnr;
2819
2820 slabp = page_get_slab(virt_to_page(objp));
2821 objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size;
2822 slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE;
2823 }
2824#endif
2789 objp += obj_offset(cachep); 2825 objp += obj_offset(cachep);
2790 if (cachep->ctor && cachep->flags & SLAB_POISON) { 2826 if (cachep->ctor && cachep->flags & SLAB_POISON) {
2791 unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR; 2827 unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR;
@@ -2807,11 +2843,10 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
2807 struct array_cache *ac; 2843 struct array_cache *ac;
2808 2844
2809#ifdef CONFIG_NUMA 2845#ifdef CONFIG_NUMA
2810 if (unlikely(current->mempolicy && !in_interrupt())) { 2846 if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) {
2811 int nid = slab_node(current->mempolicy); 2847 objp = alternate_node_alloc(cachep, flags);
2812 2848 if (objp != NULL)
2813 if (nid != numa_node_id()) 2849 return objp;
2814 return __cache_alloc_node(cachep, flags, nid);
2815 } 2850 }
2816#endif 2851#endif
2817 2852
@@ -2847,6 +2882,28 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
2847 2882
2848#ifdef CONFIG_NUMA 2883#ifdef CONFIG_NUMA
2849/* 2884/*
2885 * Try allocating on another node if PF_SPREAD_SLAB|PF_MEMPOLICY.
2886 *
2887 * If we are in_interrupt, then process context, including cpusets and
2888 * mempolicy, may not apply and should not be used for allocation policy.
2889 */
2890static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
2891{
2892 int nid_alloc, nid_here;
2893
2894 if (in_interrupt())
2895 return NULL;
2896 nid_alloc = nid_here = numa_node_id();
2897 if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
2898 nid_alloc = cpuset_mem_spread_node();
2899 else if (current->mempolicy)
2900 nid_alloc = slab_node(current->mempolicy);
2901 if (nid_alloc != nid_here)
2902 return __cache_alloc_node(cachep, flags, nid_alloc);
2903 return NULL;
2904}
2905
2906/*
2850 * A interface to enable slab creation on nodeid 2907 * A interface to enable slab creation on nodeid
2851 */ 2908 */
2852static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, 2909static 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)
3071EXPORT_SYMBOL(kmem_cache_alloc); 3128EXPORT_SYMBOL(kmem_cache_alloc);
3072 3129
3073/** 3130/**
3131 * kmem_cache_alloc - Allocate an object. The memory is set to zero.
3132 * @cache: The cache to allocate from.
3133 * @flags: See kmalloc().
3134 *
3135 * Allocate an object from this cache and set the allocated memory to zero.
3136 * The flags are only relevant if the cache has no available objects.
3137 */
3138void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
3139{
3140 void *ret = __cache_alloc(cache, flags, __builtin_return_address(0));
3141 if (ret)
3142 memset(ret, 0, obj_size(cache));
3143 return ret;
3144}
3145EXPORT_SYMBOL(kmem_cache_zalloc);
3146
3147/**
3074 * kmem_ptr_validate - check if an untrusted pointer might 3148 * kmem_ptr_validate - check if an untrusted pointer might
3075 * be a slab entry. 3149 * be a slab entry.
3076 * @cachep: the cache we're checking against 3150 * @cachep: the cache we're checking against
@@ -3197,22 +3271,23 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
3197 return __cache_alloc(cachep, flags, caller); 3271 return __cache_alloc(cachep, flags, caller);
3198} 3272}
3199 3273
3200#ifndef CONFIG_DEBUG_SLAB
3201 3274
3202void *__kmalloc(size_t size, gfp_t flags) 3275void *__kmalloc(size_t size, gfp_t flags)
3203{ 3276{
3277#ifndef CONFIG_DEBUG_SLAB
3204 return __do_kmalloc(size, flags, NULL); 3278 return __do_kmalloc(size, flags, NULL);
3279#else
3280 return __do_kmalloc(size, flags, __builtin_return_address(0));
3281#endif
3205} 3282}
3206EXPORT_SYMBOL(__kmalloc); 3283EXPORT_SYMBOL(__kmalloc);
3207 3284
3208#else 3285#ifdef CONFIG_DEBUG_SLAB
3209
3210void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller) 3286void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller)
3211{ 3287{
3212 return __do_kmalloc(size, flags, caller); 3288 return __do_kmalloc(size, flags, caller);
3213} 3289}
3214EXPORT_SYMBOL(__kmalloc_track_caller); 3290EXPORT_SYMBOL(__kmalloc_track_caller);
3215
3216#endif 3291#endif
3217 3292
3218#ifdef CONFIG_SMP 3293#ifdef CONFIG_SMP
@@ -3343,63 +3418,86 @@ const char *kmem_cache_name(struct kmem_cache *cachep)
3343EXPORT_SYMBOL_GPL(kmem_cache_name); 3418EXPORT_SYMBOL_GPL(kmem_cache_name);
3344 3419
3345/* 3420/*
3346 * This initializes kmem_list3 for all nodes. 3421 * This initializes kmem_list3 or resizes varioius caches for all nodes.
3347 */ 3422 */
3348static int alloc_kmemlist(struct kmem_cache *cachep) 3423static int alloc_kmemlist(struct kmem_cache *cachep)
3349{ 3424{
3350 int node; 3425 int node;
3351 struct kmem_list3 *l3; 3426 struct kmem_list3 *l3;
3352 int err = 0; 3427 struct array_cache *new_shared;
3428 struct array_cache **new_alien;
3353 3429
3354 for_each_online_node(node) { 3430 for_each_online_node(node) {
3355 struct array_cache *nc = NULL, *new; 3431
3356 struct array_cache **new_alien = NULL;
3357#ifdef CONFIG_NUMA
3358 new_alien = alloc_alien_cache(node, cachep->limit); 3432 new_alien = alloc_alien_cache(node, cachep->limit);
3359 if (!new_alien) 3433 if (!new_alien)
3360 goto fail; 3434 goto fail;
3361#endif 3435
3362 new = alloc_arraycache(node, cachep->shared*cachep->batchcount, 3436 new_shared = alloc_arraycache(node,
3437 cachep->shared*cachep->batchcount,
3363 0xbaadf00d); 3438 0xbaadf00d);
3364 if (!new) 3439 if (!new_shared) {
3440 free_alien_cache(new_alien);
3365 goto fail; 3441 goto fail;
3442 }
3443
3366 l3 = cachep->nodelists[node]; 3444 l3 = cachep->nodelists[node];
3367 if (l3) { 3445 if (l3) {
3446 struct array_cache *shared = l3->shared;
3447
3368 spin_lock_irq(&l3->list_lock); 3448 spin_lock_irq(&l3->list_lock);
3369 3449
3370 nc = cachep->nodelists[node]->shared; 3450 if (shared)
3371 if (nc) 3451 free_block(cachep, shared->entry,
3372 free_block(cachep, nc->entry, nc->avail, node); 3452 shared->avail, node);
3373 3453
3374 l3->shared = new; 3454 l3->shared = new_shared;
3375 if (!cachep->nodelists[node]->alien) { 3455 if (!l3->alien) {
3376 l3->alien = new_alien; 3456 l3->alien = new_alien;
3377 new_alien = NULL; 3457 new_alien = NULL;
3378 } 3458 }
3379 l3->free_limit = (1 + nr_cpus_node(node)) * 3459 l3->free_limit = (1 + nr_cpus_node(node)) *
3380 cachep->batchcount + cachep->num; 3460 cachep->batchcount + cachep->num;
3381 spin_unlock_irq(&l3->list_lock); 3461 spin_unlock_irq(&l3->list_lock);
3382 kfree(nc); 3462 kfree(shared);
3383 free_alien_cache(new_alien); 3463 free_alien_cache(new_alien);
3384 continue; 3464 continue;
3385 } 3465 }
3386 l3 = kmalloc_node(sizeof(struct kmem_list3), GFP_KERNEL, node); 3466 l3 = kmalloc_node(sizeof(struct kmem_list3), GFP_KERNEL, node);
3387 if (!l3) 3467 if (!l3) {
3468 free_alien_cache(new_alien);
3469 kfree(new_shared);
3388 goto fail; 3470 goto fail;
3471 }
3389 3472
3390 kmem_list3_init(l3); 3473 kmem_list3_init(l3);
3391 l3->next_reap = jiffies + REAPTIMEOUT_LIST3 + 3474 l3->next_reap = jiffies + REAPTIMEOUT_LIST3 +
3392 ((unsigned long)cachep) % REAPTIMEOUT_LIST3; 3475 ((unsigned long)cachep) % REAPTIMEOUT_LIST3;
3393 l3->shared = new; 3476 l3->shared = new_shared;
3394 l3->alien = new_alien; 3477 l3->alien = new_alien;
3395 l3->free_limit = (1 + nr_cpus_node(node)) * 3478 l3->free_limit = (1 + nr_cpus_node(node)) *
3396 cachep->batchcount + cachep->num; 3479 cachep->batchcount + cachep->num;
3397 cachep->nodelists[node] = l3; 3480 cachep->nodelists[node] = l3;
3398 } 3481 }
3399 return err; 3482 return 0;
3483
3400fail: 3484fail:
3401 err = -ENOMEM; 3485 if (!cachep->next.next) {
3402 return err; 3486 /* Cache is not active yet. Roll back what we did */
3487 node--;
3488 while (node >= 0) {
3489 if (cachep->nodelists[node]) {
3490 l3 = cachep->nodelists[node];
3491
3492 kfree(l3->shared);
3493 free_alien_cache(l3->alien);
3494 kfree(l3);
3495 cachep->nodelists[node] = NULL;
3496 }
3497 node--;
3498 }
3499 }
3500 return -ENOMEM;
3403} 3501}
3404 3502
3405struct ccupdate_struct { 3503struct ccupdate_struct {
@@ -3876,6 +3974,159 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer,
3876 res = count; 3974 res = count;
3877 return res; 3975 return res;
3878} 3976}
3977
3978#ifdef CONFIG_DEBUG_SLAB_LEAK
3979
3980static void *leaks_start(struct seq_file *m, loff_t *pos)
3981{
3982 loff_t n = *pos;
3983 struct list_head *p;
3984
3985 mutex_lock(&cache_chain_mutex);
3986 p = cache_chain.next;
3987 while (n--) {
3988 p = p->next;
3989 if (p == &cache_chain)
3990 return NULL;
3991 }
3992 return list_entry(p, struct kmem_cache, next);
3993}
3994
3995static inline int add_caller(unsigned long *n, unsigned long v)
3996{
3997 unsigned long *p;
3998 int l;
3999 if (!v)
4000 return 1;
4001 l = n[1];
4002 p = n + 2;
4003 while (l) {
4004 int i = l/2;
4005 unsigned long *q = p + 2 * i;
4006 if (*q == v) {
4007 q[1]++;
4008 return 1;
4009 }
4010 if (*q > v) {
4011 l = i;
4012 } else {
4013 p = q + 2;
4014 l -= i + 1;
4015 }
4016 }
4017 if (++n[1] == n[0])
4018 return 0;
4019 memmove(p + 2, p, n[1] * 2 * sizeof(unsigned long) - ((void *)p - (void *)n));
4020 p[0] = v;
4021 p[1] = 1;
4022 return 1;
4023}
4024
4025static void handle_slab(unsigned long *n, struct kmem_cache *c, struct slab *s)
4026{
4027 void *p;
4028 int i;
4029 if (n[0] == n[1])
4030 return;
4031 for (i = 0, p = s->s_mem; i < c->num; i++, p += c->buffer_size) {
4032 if (slab_bufctl(s)[i] != BUFCTL_ACTIVE)
4033 continue;
4034 if (!add_caller(n, (unsigned long)*dbg_userword(c, p)))
4035 return;
4036 }
4037}
4038
4039static void show_symbol(struct seq_file *m, unsigned long address)
4040{
4041#ifdef CONFIG_KALLSYMS
4042 char *modname;
4043 const char *name;
4044 unsigned long offset, size;
4045 char namebuf[KSYM_NAME_LEN+1];
4046
4047 name = kallsyms_lookup(address, &size, &offset, &modname, namebuf);
4048
4049 if (name) {
4050 seq_printf(m, "%s+%#lx/%#lx", name, offset, size);
4051 if (modname)
4052 seq_printf(m, " [%s]", modname);
4053 return;
4054 }
4055#endif
4056 seq_printf(m, "%p", (void *)address);
4057}
4058
4059static int leaks_show(struct seq_file *m, void *p)
4060{
4061 struct kmem_cache *cachep = p;
4062 struct list_head *q;
4063 struct slab *slabp;
4064 struct kmem_list3 *l3;
4065 const char *name;
4066 unsigned long *n = m->private;
4067 int node;
4068 int i;
4069
4070 if (!(cachep->flags & SLAB_STORE_USER))
4071 return 0;
4072 if (!(cachep->flags & SLAB_RED_ZONE))
4073 return 0;
4074
4075 /* OK, we can do it */
4076
4077 n[1] = 0;
4078
4079 for_each_online_node(node) {
4080 l3 = cachep->nodelists[node];
4081 if (!l3)
4082 continue;
4083
4084 check_irq_on();
4085 spin_lock_irq(&l3->list_lock);
4086
4087 list_for_each(q, &l3->slabs_full) {
4088 slabp = list_entry(q, struct slab, list);
4089 handle_slab(n, cachep, slabp);
4090 }
4091 list_for_each(q, &l3->slabs_partial) {
4092 slabp = list_entry(q, struct slab, list);
4093 handle_slab(n, cachep, slabp);
4094 }
4095 spin_unlock_irq(&l3->list_lock);
4096 }
4097 name = cachep->name;
4098 if (n[0] == n[1]) {
4099 /* Increase the buffer size */
4100 mutex_unlock(&cache_chain_mutex);
4101 m->private = kzalloc(n[0] * 4 * sizeof(unsigned long), GFP_KERNEL);
4102 if (!m->private) {
4103 /* Too bad, we are really out */
4104 m->private = n;
4105 mutex_lock(&cache_chain_mutex);
4106 return -ENOMEM;
4107 }
4108 *(unsigned long *)m->private = n[0] * 2;
4109 kfree(n);
4110 mutex_lock(&cache_chain_mutex);
4111 /* Now make sure this entry will be retried */
4112 m->count = m->size;
4113 return 0;
4114 }
4115 for (i = 0; i < n[1]; i++) {
4116 seq_printf(m, "%s: %lu ", name, n[2*i+3]);
4117 show_symbol(m, n[2*i+2]);
4118 seq_putc(m, '\n');
4119 }
4120 return 0;
4121}
4122
4123struct seq_operations slabstats_op = {
4124 .start = leaks_start,
4125 .next = s_next,
4126 .stop = s_stop,
4127 .show = leaks_show,
4128};
4129#endif
3879#endif 4130#endif
3880 4131
3881/** 4132/**
diff --git a/mm/slob.c b/mm/slob.c
index a1f42bdc0245..9bcc7e2cabfd 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -294,6 +294,16 @@ void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags)
294} 294}
295EXPORT_SYMBOL(kmem_cache_alloc); 295EXPORT_SYMBOL(kmem_cache_alloc);
296 296
297void *kmem_cache_zalloc(struct kmem_cache *c, gfp_t flags)
298{
299 void *ret = kmem_cache_alloc(c, flags);
300 if (ret)
301 memset(ret, 0, c->size);
302
303 return ret;
304}
305EXPORT_SYMBOL(kmem_cache_zalloc);
306
297void kmem_cache_free(struct kmem_cache *c, void *b) 307void kmem_cache_free(struct kmem_cache *c, void *b)
298{ 308{
299 if (c->dtor) 309 if (c->dtor)
diff --git a/mm/util.c b/mm/util.c
index 5f4bb59da63c..7368479220b3 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1,20 +1,22 @@
1#include <linux/slab.h> 1#include <linux/slab.h>
2#include <linux/string.h> 2#include <linux/string.h>
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/err.h>
5#include <asm/uaccess.h>
4 6
5/** 7/**
6 * kzalloc - allocate memory. The memory is set to zero. 8 * __kzalloc - allocate memory. The memory is set to zero.
7 * @size: how many bytes of memory are required. 9 * @size: how many bytes of memory are required.
8 * @flags: the type of memory to allocate. 10 * @flags: the type of memory to allocate.
9 */ 11 */
10void *kzalloc(size_t size, gfp_t flags) 12void *__kzalloc(size_t size, gfp_t flags)
11{ 13{
12 void *ret = kmalloc(size, flags); 14 void *ret = ____kmalloc(size, flags);
13 if (ret) 15 if (ret)
14 memset(ret, 0, size); 16 memset(ret, 0, size);
15 return ret; 17 return ret;
16} 18}
17EXPORT_SYMBOL(kzalloc); 19EXPORT_SYMBOL(__kzalloc);
18 20
19/* 21/*
20 * kstrdup - allocate space for and copy an existing string 22 * kstrdup - allocate space for and copy an existing string
@@ -31,9 +33,44 @@ char *kstrdup(const char *s, gfp_t gfp)
31 return NULL; 33 return NULL;
32 34
33 len = strlen(s) + 1; 35 len = strlen(s) + 1;
34 buf = kmalloc(len, gfp); 36 buf = ____kmalloc(len, gfp);
35 if (buf) 37 if (buf)
36 memcpy(buf, s, len); 38 memcpy(buf, s, len);
37 return buf; 39 return buf;
38} 40}
39EXPORT_SYMBOL(kstrdup); 41EXPORT_SYMBOL(kstrdup);
42
43/*
44 * strndup_user - duplicate an existing string from user space
45 *
46 * @s: The string to duplicate
47 * @n: Maximum number of bytes to copy, including the trailing NUL.
48 */
49char *strndup_user(const char __user *s, long n)
50{
51 char *p;
52 long length;
53
54 length = strnlen_user(s, n);
55
56 if (!length)
57 return ERR_PTR(-EFAULT);
58
59 if (length > n)
60 return ERR_PTR(-EINVAL);
61
62 p = kmalloc(length, GFP_KERNEL);
63
64 if (!p)
65 return ERR_PTR(-ENOMEM);
66
67 if (copy_from_user(p, s, length)) {
68 kfree(p);
69 return ERR_PTR(-EFAULT);
70 }
71
72 p[length - 1] = '\0';
73
74 return p;
75}
76EXPORT_SYMBOL(strndup_user);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index fd572bbdc9f5..78865c849f8f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1356,7 +1356,9 @@ static int __init kswapd_init(void)
1356 1356
1357 pid = kernel_thread(kswapd, pgdat, CLONE_KERNEL); 1357 pid = kernel_thread(kswapd, pgdat, CLONE_KERNEL);
1358 BUG_ON(pid < 0); 1358 BUG_ON(pid < 0);
1359 read_lock(&tasklist_lock);
1359 pgdat->kswapd = find_task_by_pid(pid); 1360 pgdat->kswapd = find_task_by_pid(pid);
1361 read_unlock(&tasklist_lock);
1360 } 1362 }
1361 total_memory = nr_free_pagecache_pages(); 1363 total_memory = nr_free_pagecache_pages();
1362 hotcpu_notifier(cpu_callback, 0); 1364 hotcpu_notifier(cpu_callback, 0);
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index fb031fe9be9e..469eda0f0dfd 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
238 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 238 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
239 mask |= POLLERR; 239 mask |= POLLERR;
240 240
241 if (sk->sk_shutdown & RCV_SHUTDOWN)
242 mask |= POLLRDHUP;
243
241 if (sk->sk_shutdown == SHUTDOWN_MASK) 244 if (sk->sk_shutdown == SHUTDOWN_MASK)
242 mask |= POLLHUP; 245 mask |= POLLHUP;
243 246
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 8934a54792be..a7ba0cce0b46 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -19,6 +19,7 @@
19#include <linux/llc.h> 19#include <linux/llc.h>
20#include <net/llc.h> 20#include <net/llc.h>
21#include <net/llc_pdu.h> 21#include <net/llc_pdu.h>
22#include <asm/unaligned.h>
22 23
23#include "br_private.h" 24#include "br_private.h"
24#include "br_private_stp.h" 25#include "br_private_stp.h"
@@ -59,12 +60,12 @@ static inline void br_set_ticks(unsigned char *dest, int j)
59{ 60{
60 unsigned long ticks = (STP_HZ * j)/ HZ; 61 unsigned long ticks = (STP_HZ * j)/ HZ;
61 62
62 *((__be16 *) dest) = htons(ticks); 63 put_unaligned(htons(ticks), (__be16 *)dest);
63} 64}
64 65
65static inline int br_get_ticks(const unsigned char *src) 66static inline int br_get_ticks(const unsigned char *src)
66{ 67{
67 unsigned long ticks = ntohs(*(__be16 *)src); 68 unsigned long ticks = ntohs(get_unaligned((__be16 *)src));
68 69
69 return (ticks * HZ + STP_HZ - 1) / STP_HZ; 70 return (ticks * HZ + STP_HZ - 1) / STP_HZ;
70} 71}
diff --git a/net/core/datagram.c b/net/core/datagram.c
index b8ce6bf81188..aecddcc30401 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,
500 /* exceptional events? */ 500 /* exceptional events? */
501 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 501 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
502 mask |= POLLERR; 502 mask |= POLLERR;
503 if (sk->sk_shutdown & RCV_SHUTDOWN)
504 mask |= POLLRDHUP;
503 if (sk->sk_shutdown == SHUTDOWN_MASK) 505 if (sk->sk_shutdown == SHUTDOWN_MASK)
504 mask |= POLLHUP; 506 mask |= POLLHUP;
505 507
diff --git a/net/core/dev.c b/net/core/dev.c
index 08dec6eb922b..e0489ca731c5 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -977,7 +977,12 @@ int register_netdevice_notifier(struct notifier_block *nb)
977 977
978int unregister_netdevice_notifier(struct notifier_block *nb) 978int unregister_netdevice_notifier(struct notifier_block *nb)
979{ 979{
980 return notifier_chain_unregister(&netdev_chain, nb); 980 int err;
981
982 rtnl_lock();
983 err = notifier_chain_unregister(&netdev_chain, nb);
984 rtnl_unlock();
985 return err;
981} 986}
982 987
983/** 988/**
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c9f878454531..09464fa8d72f 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,
149 149
150 /* Get the DATA. Size must match skb_add_mtu(). */ 150 /* Get the DATA. Size must match skb_add_mtu(). */
151 size = SKB_DATA_ALIGN(size); 151 size = SKB_DATA_ALIGN(size);
152 data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask); 152 data = ____kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
153 if (!data) 153 if (!data)
154 goto nodata; 154 goto nodata;
155 155
diff --git a/net/core/sock.c b/net/core/sock.c
index 1a7e6eac90b0..e110b9004147 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -404,8 +404,9 @@ set_rcvbuf:
404 if (!valbool) { 404 if (!valbool) {
405 sk->sk_bound_dev_if = 0; 405 sk->sk_bound_dev_if = 0;
406 } else { 406 } else {
407 if (optlen > IFNAMSIZ) 407 if (optlen > IFNAMSIZ - 1)
408 optlen = IFNAMSIZ; 408 optlen = IFNAMSIZ - 1;
409 memset(devname, 0, sizeof(devname));
409 if (copy_from_user(devname, optval, optlen)) { 410 if (copy_from_user(devname, optval, optlen)) {
410 ret = -EFAULT; 411 ret = -EFAULT;
411 break; 412 break;
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index d4b293e16283..1ff7328b0e17 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,
350 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED) 350 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED)
351 mask |= POLLHUP; 351 mask |= POLLHUP;
352 if (sk->sk_shutdown & RCV_SHUTDOWN) 352 if (sk->sk_shutdown & RCV_SHUTDOWN)
353 mask |= POLLIN | POLLRDNORM; 353 mask |= POLLIN | POLLRDNORM | POLLRDHUP;
354 354
355 /* Connected? */ 355 /* Connected? */
356 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) { 356 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) {
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index e7bbff4340bb..9831fd2c73a0 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -753,7 +753,7 @@ static void icmp_redirect(struct sk_buff *skb)
753 case ICMP_REDIR_HOST: 753 case ICMP_REDIR_HOST:
754 case ICMP_REDIR_HOSTTOS: 754 case ICMP_REDIR_HOSTTOS:
755 ip_rt_redirect(skb->nh.iph->saddr, ip, skb->h.icmph->un.gateway, 755 ip_rt_redirect(skb->nh.iph->saddr, ip, skb->h.icmph->un.gateway,
756 iph->saddr, iph->tos, skb->dev); 756 iph->saddr, skb->dev);
757 break; 757 break;
758 } 758 }
759out: 759out:
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 33228115cda4..ef7366fc132f 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -315,7 +315,7 @@ ok:
315 spin_unlock(&head->lock); 315 spin_unlock(&head->lock);
316 316
317 if (tw) { 317 if (tw) {
318 inet_twsk_deschedule(tw, death_row);; 318 inet_twsk_deschedule(tw, death_row);
319 inet_twsk_put(tw); 319 inet_twsk_put(tw);
320 } 320 }
321 321
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index ab1f88fa21ec..380aef3d7865 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)
394 ret = nf_register_hook(&ip_nat_local_out_ops); 394 ret = nf_register_hook(&ip_nat_local_out_ops);
395 if (ret < 0) { 395 if (ret < 0) {
396 printk("ip_nat_init: can't register local out hook.\n"); 396 printk("ip_nat_init: can't register local out hook.\n");
397 goto cleanup_adjustout_ops;; 397 goto cleanup_adjustout_ops;
398 } 398 }
399 ret = nf_register_hook(&ip_nat_local_in_ops); 399 ret = nf_register_hook(&ip_nat_local_in_ops);
400 if (ret < 0) { 400 if (ret < 0) {
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index fca5fe0cf94a..94fcbc5e5a1b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -55,6 +55,8 @@
55 * Robert Olsson : Added rt_cache statistics 55 * Robert Olsson : Added rt_cache statistics
56 * Arnaldo C. Melo : Convert proc stuff to seq_file 56 * Arnaldo C. Melo : Convert proc stuff to seq_file
57 * Eric Dumazet : hashed spinlocks and rt_check_expire() fixes. 57 * Eric Dumazet : hashed spinlocks and rt_check_expire() fixes.
58 * Ilia Sotnikov : Ignore TOS on PMTUD and Redirect
59 * Ilia Sotnikov : Removed TOS from hash calculations
58 * 60 *
59 * This program is free software; you can redistribute it and/or 61 * This program is free software; you can redistribute it and/or
60 * modify it under the terms of the GNU General Public License 62 * 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);
247static int rt_intern_hash(unsigned hash, struct rtable *rth, 249static int rt_intern_hash(unsigned hash, struct rtable *rth,
248 struct rtable **res); 250 struct rtable **res);
249 251
250static unsigned int rt_hash_code(u32 daddr, u32 saddr, u8 tos) 252static unsigned int rt_hash_code(u32 daddr, u32 saddr)
251{ 253{
252 return (jhash_3words(daddr, saddr, (u32) tos, rt_hash_rnd) 254 return (jhash_2words(daddr, saddr, rt_hash_rnd)
253 & rt_hash_mask); 255 & rt_hash_mask);
254} 256}
255 257
@@ -1111,7 +1113,7 @@ static void rt_del(unsigned hash, struct rtable *rt)
1111} 1113}
1112 1114
1113void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw, 1115void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
1114 u32 saddr, u8 tos, struct net_device *dev) 1116 u32 saddr, struct net_device *dev)
1115{ 1117{
1116 int i, k; 1118 int i, k;
1117 struct in_device *in_dev = in_dev_get(dev); 1119 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,
1119 u32 skeys[2] = { saddr, 0 }; 1121 u32 skeys[2] = { saddr, 0 };
1120 int ikeys[2] = { dev->ifindex, 0 }; 1122 int ikeys[2] = { dev->ifindex, 0 };
1121 1123
1122 tos &= IPTOS_RT_MASK;
1123
1124 if (!in_dev) 1124 if (!in_dev)
1125 return; 1125 return;
1126 1126
@@ -1141,8 +1141,7 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
1141 for (i = 0; i < 2; i++) { 1141 for (i = 0; i < 2; i++) {
1142 for (k = 0; k < 2; k++) { 1142 for (k = 0; k < 2; k++) {
1143 unsigned hash = rt_hash_code(daddr, 1143 unsigned hash = rt_hash_code(daddr,
1144 skeys[i] ^ (ikeys[k] << 5), 1144 skeys[i] ^ (ikeys[k] << 5));
1145 tos);
1146 1145
1147 rthp=&rt_hash_table[hash].chain; 1146 rthp=&rt_hash_table[hash].chain;
1148 1147
@@ -1152,7 +1151,6 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
1152 1151
1153 if (rth->fl.fl4_dst != daddr || 1152 if (rth->fl.fl4_dst != daddr ||
1154 rth->fl.fl4_src != skeys[i] || 1153 rth->fl.fl4_src != skeys[i] ||
1155 rth->fl.fl4_tos != tos ||
1156 rth->fl.oif != ikeys[k] || 1154 rth->fl.oif != ikeys[k] ||
1157 rth->fl.iif != 0) { 1155 rth->fl.iif != 0) {
1158 rthp = &rth->u.rt_next; 1156 rthp = &rth->u.rt_next;
@@ -1232,10 +1230,9 @@ reject_redirect:
1232 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) 1230 if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
1233 printk(KERN_INFO "Redirect from %u.%u.%u.%u on %s about " 1231 printk(KERN_INFO "Redirect from %u.%u.%u.%u on %s about "
1234 "%u.%u.%u.%u ignored.\n" 1232 "%u.%u.%u.%u ignored.\n"
1235 " Advised path = %u.%u.%u.%u -> %u.%u.%u.%u, " 1233 " Advised path = %u.%u.%u.%u -> %u.%u.%u.%u\n",
1236 "tos %02x\n",
1237 NIPQUAD(old_gw), dev->name, NIPQUAD(new_gw), 1234 NIPQUAD(old_gw), dev->name, NIPQUAD(new_gw),
1238 NIPQUAD(saddr), NIPQUAD(daddr), tos); 1235 NIPQUAD(saddr), NIPQUAD(daddr));
1239#endif 1236#endif
1240 in_dev_put(in_dev); 1237 in_dev_put(in_dev);
1241} 1238}
@@ -1253,8 +1250,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1253 rt->u.dst.expires) { 1250 rt->u.dst.expires) {
1254 unsigned hash = rt_hash_code(rt->fl.fl4_dst, 1251 unsigned hash = rt_hash_code(rt->fl.fl4_dst,
1255 rt->fl.fl4_src ^ 1252 rt->fl.fl4_src ^
1256 (rt->fl.oif << 5), 1253 (rt->fl.oif << 5));
1257 rt->fl.fl4_tos);
1258#if RT_CACHE_DEBUG >= 1 1254#if RT_CACHE_DEBUG >= 1
1259 printk(KERN_DEBUG "ip_rt_advice: redirect to " 1255 printk(KERN_DEBUG "ip_rt_advice: redirect to "
1260 "%u.%u.%u.%u/%02x dropped\n", 1256 "%u.%u.%u.%u/%02x dropped\n",
@@ -1391,14 +1387,13 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
1391 struct rtable *rth; 1387 struct rtable *rth;
1392 u32 skeys[2] = { iph->saddr, 0, }; 1388 u32 skeys[2] = { iph->saddr, 0, };
1393 u32 daddr = iph->daddr; 1389 u32 daddr = iph->daddr;
1394 u8 tos = iph->tos & IPTOS_RT_MASK;
1395 unsigned short est_mtu = 0; 1390 unsigned short est_mtu = 0;
1396 1391
1397 if (ipv4_config.no_pmtu_disc) 1392 if (ipv4_config.no_pmtu_disc)
1398 return 0; 1393 return 0;
1399 1394
1400 for (i = 0; i < 2; i++) { 1395 for (i = 0; i < 2; i++) {
1401 unsigned hash = rt_hash_code(daddr, skeys[i], tos); 1396 unsigned hash = rt_hash_code(daddr, skeys[i]);
1402 1397
1403 rcu_read_lock(); 1398 rcu_read_lock();
1404 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 1399 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)
1407 rth->fl.fl4_src == skeys[i] && 1402 rth->fl.fl4_src == skeys[i] &&
1408 rth->rt_dst == daddr && 1403 rth->rt_dst == daddr &&
1409 rth->rt_src == iph->saddr && 1404 rth->rt_src == iph->saddr &&
1410 rth->fl.fl4_tos == tos &&
1411 rth->fl.iif == 0 && 1405 rth->fl.iif == 0 &&
1412 !(dst_metric_locked(&rth->u.dst, RTAX_MTU))) { 1406 !(dst_metric_locked(&rth->u.dst, RTAX_MTU))) {
1413 unsigned short mtu = new_mtu; 1407 unsigned short mtu = new_mtu;
@@ -1658,7 +1652,7 @@ static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr,
1658 RT_CACHE_STAT_INC(in_slow_mc); 1652 RT_CACHE_STAT_INC(in_slow_mc);
1659 1653
1660 in_dev_put(in_dev); 1654 in_dev_put(in_dev);
1661 hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5), tos); 1655 hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5));
1662 return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); 1656 return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst);
1663 1657
1664e_nobufs: 1658e_nobufs:
@@ -1823,7 +1817,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
1823 return err; 1817 return err;
1824 1818
1825 /* put it into the cache */ 1819 /* put it into the cache */
1826 hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); 1820 hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5));
1827 return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); 1821 return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
1828} 1822}
1829 1823
@@ -1864,7 +1858,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
1864 return err; 1858 return err;
1865 1859
1866 /* put it into the cache */ 1860 /* put it into the cache */
1867 hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); 1861 hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5));
1868 err = rt_intern_hash(hash, rth, &rtres); 1862 err = rt_intern_hash(hash, rth, &rtres);
1869 if (err) 1863 if (err)
1870 return err; 1864 return err;
@@ -2041,7 +2035,7 @@ local_input:
2041 rth->rt_flags &= ~RTCF_LOCAL; 2035 rth->rt_flags &= ~RTCF_LOCAL;
2042 } 2036 }
2043 rth->rt_type = res.type; 2037 rth->rt_type = res.type;
2044 hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5), tos); 2038 hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5));
2045 err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); 2039 err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
2046 goto done; 2040 goto done;
2047 2041
@@ -2088,7 +2082,7 @@ int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr,
2088 int iif = dev->ifindex; 2082 int iif = dev->ifindex;
2089 2083
2090 tos &= IPTOS_RT_MASK; 2084 tos &= IPTOS_RT_MASK;
2091 hash = rt_hash_code(daddr, saddr ^ (iif << 5), tos); 2085 hash = rt_hash_code(daddr, saddr ^ (iif << 5));
2092 2086
2093 rcu_read_lock(); 2087 rcu_read_lock();
2094 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 2088 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -2286,10 +2280,8 @@ static inline int ip_mkroute_output_def(struct rtable **rp,
2286 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); 2280 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
2287 unsigned hash; 2281 unsigned hash;
2288 if (err == 0) { 2282 if (err == 0) {
2289 u32 tos = RT_FL_TOS(oldflp);
2290
2291 hash = rt_hash_code(oldflp->fl4_dst, 2283 hash = rt_hash_code(oldflp->fl4_dst,
2292 oldflp->fl4_src ^ (oldflp->oif << 5), tos); 2284 oldflp->fl4_src ^ (oldflp->oif << 5));
2293 err = rt_intern_hash(hash, rth, rp); 2285 err = rt_intern_hash(hash, rth, rp);
2294 } 2286 }
2295 2287
@@ -2304,7 +2296,6 @@ static inline int ip_mkroute_output(struct rtable** rp,
2304 unsigned flags) 2296 unsigned flags)
2305{ 2297{
2306#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED 2298#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
2307 u32 tos = RT_FL_TOS(oldflp);
2308 unsigned char hop; 2299 unsigned char hop;
2309 unsigned hash; 2300 unsigned hash;
2310 int err = -EINVAL; 2301 int err = -EINVAL;
@@ -2334,7 +2325,7 @@ static inline int ip_mkroute_output(struct rtable** rp,
2334 2325
2335 hash = rt_hash_code(oldflp->fl4_dst, 2326 hash = rt_hash_code(oldflp->fl4_dst,
2336 oldflp->fl4_src ^ 2327 oldflp->fl4_src ^
2337 (oldflp->oif << 5), tos); 2328 (oldflp->oif << 5));
2338 err = rt_intern_hash(hash, rth, rp); 2329 err = rt_intern_hash(hash, rth, rp);
2339 2330
2340 /* forward hop information to multipath impl. */ 2331 /* forward hop information to multipath impl. */
@@ -2563,7 +2554,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
2563 unsigned hash; 2554 unsigned hash;
2564 struct rtable *rth; 2555 struct rtable *rth;
2565 2556
2566 hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5), flp->fl4_tos); 2557 hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5));
2567 2558
2568 rcu_read_lock_bh(); 2559 rcu_read_lock_bh();
2569 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 2560 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4b0272c92d66..87f68e787d0c 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -257,6 +257,7 @@
257#include <linux/fs.h> 257#include <linux/fs.h>
258#include <linux/random.h> 258#include <linux/random.h>
259#include <linux/bootmem.h> 259#include <linux/bootmem.h>
260#include <linux/cache.h>
260 261
261#include <net/icmp.h> 262#include <net/icmp.h>
262#include <net/tcp.h> 263#include <net/tcp.h>
@@ -275,9 +276,9 @@ atomic_t tcp_orphan_count = ATOMIC_INIT(0);
275 276
276EXPORT_SYMBOL_GPL(tcp_orphan_count); 277EXPORT_SYMBOL_GPL(tcp_orphan_count);
277 278
278int sysctl_tcp_mem[3]; 279int sysctl_tcp_mem[3] __read_mostly;
279int sysctl_tcp_wmem[3] = { 4 * 1024, 16 * 1024, 128 * 1024 }; 280int sysctl_tcp_wmem[3] __read_mostly;
280int sysctl_tcp_rmem[3] = { 4 * 1024, 87380, 87380 * 2 }; 281int sysctl_tcp_rmem[3] __read_mostly;
281 282
282EXPORT_SYMBOL(sysctl_tcp_mem); 283EXPORT_SYMBOL(sysctl_tcp_mem);
283EXPORT_SYMBOL(sysctl_tcp_rmem); 284EXPORT_SYMBOL(sysctl_tcp_rmem);
@@ -365,7 +366,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
365 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == TCP_CLOSE) 366 if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == TCP_CLOSE)
366 mask |= POLLHUP; 367 mask |= POLLHUP;
367 if (sk->sk_shutdown & RCV_SHUTDOWN) 368 if (sk->sk_shutdown & RCV_SHUTDOWN)
368 mask |= POLLIN | POLLRDNORM; 369 mask |= POLLIN | POLLRDNORM | POLLRDHUP;
369 370
370 /* Connected? */ 371 /* Connected? */
371 if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) { 372 if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) {
@@ -2081,7 +2082,8 @@ __setup("thash_entries=", set_thash_entries);
2081void __init tcp_init(void) 2082void __init tcp_init(void)
2082{ 2083{
2083 struct sk_buff *skb = NULL; 2084 struct sk_buff *skb = NULL;
2084 int order, i; 2085 unsigned long limit;
2086 int order, i, max_share;
2085 2087
2086 if (sizeof(struct tcp_skb_cb) > sizeof(skb->cb)) 2088 if (sizeof(struct tcp_skb_cb) > sizeof(skb->cb))
2087 __skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb), 2089 __skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb),
@@ -2155,12 +2157,16 @@ void __init tcp_init(void)
2155 sysctl_tcp_mem[1] = 1024 << order; 2157 sysctl_tcp_mem[1] = 1024 << order;
2156 sysctl_tcp_mem[2] = 1536 << order; 2158 sysctl_tcp_mem[2] = 1536 << order;
2157 2159
2158 if (order < 3) { 2160 limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
2159 sysctl_tcp_wmem[2] = 64 * 1024; 2161 max_share = min(4UL*1024*1024, limit);
2160 sysctl_tcp_rmem[0] = PAGE_SIZE; 2162
2161 sysctl_tcp_rmem[1] = 43689; 2163 sysctl_tcp_wmem[0] = SK_STREAM_MEM_QUANTUM;
2162 sysctl_tcp_rmem[2] = 2 * 43689; 2164 sysctl_tcp_wmem[1] = 16*1024;
2163 } 2165 sysctl_tcp_wmem[2] = max(64*1024, max_share);
2166
2167 sysctl_tcp_rmem[0] = SK_STREAM_MEM_QUANTUM;
2168 sysctl_tcp_rmem[1] = 87380;
2169 sysctl_tcp_rmem[2] = max(87380, max_share);
2164 2170
2165 printk(KERN_INFO "TCP: Hash tables configured " 2171 printk(KERN_INFO "TCP: Hash tables configured "
2166 "(established %d bind %d)\n", 2172 "(established %d bind %d)\n",
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 0a29a24d9a72..a657ab5394c3 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -21,10 +21,12 @@
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
24#include <linux/mutex.h>
24 25
25#include <linux/netfilter/x_tables.h> 26#include <linux/netfilter/x_tables.h>
26#include <linux/netfilter_arp.h> 27#include <linux/netfilter_arp.h>
27 28
29
28MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
29MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 31MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
30MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module"); 32MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
@@ -32,7 +34,7 @@ MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
32#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1)) 34#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
33 35
34struct xt_af { 36struct xt_af {
35 struct semaphore mutex; 37 struct mutex mutex;
36 struct list_head match; 38 struct list_head match;
37 struct list_head target; 39 struct list_head target;
38 struct list_head tables; 40 struct list_head tables;
@@ -64,11 +66,11 @@ xt_register_target(struct xt_target *target)
64{ 66{
65 int ret, af = target->family; 67 int ret, af = target->family;
66 68
67 ret = down_interruptible(&xt[af].mutex); 69 ret = mutex_lock_interruptible(&xt[af].mutex);
68 if (ret != 0) 70 if (ret != 0)
69 return ret; 71 return ret;
70 list_add(&target->list, &xt[af].target); 72 list_add(&target->list, &xt[af].target);
71 up(&xt[af].mutex); 73 mutex_unlock(&xt[af].mutex);
72 return ret; 74 return ret;
73} 75}
74EXPORT_SYMBOL(xt_register_target); 76EXPORT_SYMBOL(xt_register_target);
@@ -78,9 +80,9 @@ xt_unregister_target(struct xt_target *target)
78{ 80{
79 int af = target->family; 81 int af = target->family;
80 82
81 down(&xt[af].mutex); 83 mutex_lock(&xt[af].mutex);
82 LIST_DELETE(&xt[af].target, target); 84 LIST_DELETE(&xt[af].target, target);
83 up(&xt[af].mutex); 85 mutex_unlock(&xt[af].mutex);
84} 86}
85EXPORT_SYMBOL(xt_unregister_target); 87EXPORT_SYMBOL(xt_unregister_target);
86 88
@@ -89,12 +91,12 @@ xt_register_match(struct xt_match *match)
89{ 91{
90 int ret, af = match->family; 92 int ret, af = match->family;
91 93
92 ret = down_interruptible(&xt[af].mutex); 94 ret = mutex_lock_interruptible(&xt[af].mutex);
93 if (ret != 0) 95 if (ret != 0)
94 return ret; 96 return ret;
95 97
96 list_add(&match->list, &xt[af].match); 98 list_add(&match->list, &xt[af].match);
97 up(&xt[af].mutex); 99 mutex_unlock(&xt[af].mutex);
98 100
99 return ret; 101 return ret;
100} 102}
@@ -105,9 +107,9 @@ xt_unregister_match(struct xt_match *match)
105{ 107{
106 int af = match->family; 108 int af = match->family;
107 109
108 down(&xt[af].mutex); 110 mutex_lock(&xt[af].mutex);
109 LIST_DELETE(&xt[af].match, match); 111 LIST_DELETE(&xt[af].match, match);
110 up(&xt[af].mutex); 112 mutex_unlock(&xt[af].mutex);
111} 113}
112EXPORT_SYMBOL(xt_unregister_match); 114EXPORT_SYMBOL(xt_unregister_match);
113 115
@@ -124,21 +126,21 @@ struct xt_match *xt_find_match(int af, const char *name, u8 revision)
124 struct xt_match *m; 126 struct xt_match *m;
125 int err = 0; 127 int err = 0;
126 128
127 if (down_interruptible(&xt[af].mutex) != 0) 129 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
128 return ERR_PTR(-EINTR); 130 return ERR_PTR(-EINTR);
129 131
130 list_for_each_entry(m, &xt[af].match, list) { 132 list_for_each_entry(m, &xt[af].match, list) {
131 if (strcmp(m->name, name) == 0) { 133 if (strcmp(m->name, name) == 0) {
132 if (m->revision == revision) { 134 if (m->revision == revision) {
133 if (try_module_get(m->me)) { 135 if (try_module_get(m->me)) {
134 up(&xt[af].mutex); 136 mutex_unlock(&xt[af].mutex);
135 return m; 137 return m;
136 } 138 }
137 } else 139 } else
138 err = -EPROTOTYPE; /* Found something. */ 140 err = -EPROTOTYPE; /* Found something. */
139 } 141 }
140 } 142 }
141 up(&xt[af].mutex); 143 mutex_unlock(&xt[af].mutex);
142 return ERR_PTR(err); 144 return ERR_PTR(err);
143} 145}
144EXPORT_SYMBOL(xt_find_match); 146EXPORT_SYMBOL(xt_find_match);
@@ -149,21 +151,21 @@ struct xt_target *xt_find_target(int af, const char *name, u8 revision)
149 struct xt_target *t; 151 struct xt_target *t;
150 int err = 0; 152 int err = 0;
151 153
152 if (down_interruptible(&xt[af].mutex) != 0) 154 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
153 return ERR_PTR(-EINTR); 155 return ERR_PTR(-EINTR);
154 156
155 list_for_each_entry(t, &xt[af].target, list) { 157 list_for_each_entry(t, &xt[af].target, list) {
156 if (strcmp(t->name, name) == 0) { 158 if (strcmp(t->name, name) == 0) {
157 if (t->revision == revision) { 159 if (t->revision == revision) {
158 if (try_module_get(t->me)) { 160 if (try_module_get(t->me)) {
159 up(&xt[af].mutex); 161 mutex_unlock(&xt[af].mutex);
160 return t; 162 return t;
161 } 163 }
162 } else 164 } else
163 err = -EPROTOTYPE; /* Found something. */ 165 err = -EPROTOTYPE; /* Found something. */
164 } 166 }
165 } 167 }
166 up(&xt[af].mutex); 168 mutex_unlock(&xt[af].mutex);
167 return ERR_PTR(err); 169 return ERR_PTR(err);
168} 170}
169EXPORT_SYMBOL(xt_find_target); 171EXPORT_SYMBOL(xt_find_target);
@@ -218,7 +220,7 @@ int xt_find_revision(int af, const char *name, u8 revision, int target,
218{ 220{
219 int have_rev, best = -1; 221 int have_rev, best = -1;
220 222
221 if (down_interruptible(&xt[af].mutex) != 0) { 223 if (mutex_lock_interruptible(&xt[af].mutex) != 0) {
222 *err = -EINTR; 224 *err = -EINTR;
223 return 1; 225 return 1;
224 } 226 }
@@ -226,7 +228,7 @@ int xt_find_revision(int af, const char *name, u8 revision, int target,
226 have_rev = target_revfn(af, name, revision, &best); 228 have_rev = target_revfn(af, name, revision, &best);
227 else 229 else
228 have_rev = match_revfn(af, name, revision, &best); 230 have_rev = match_revfn(af, name, revision, &best);
229 up(&xt[af].mutex); 231 mutex_unlock(&xt[af].mutex);
230 232
231 /* Nothing at all? Return 0 to try loading module. */ 233 /* Nothing at all? Return 0 to try loading module. */
232 if (best == -1) { 234 if (best == -1) {
@@ -352,20 +354,20 @@ struct xt_table *xt_find_table_lock(int af, const char *name)
352{ 354{
353 struct xt_table *t; 355 struct xt_table *t;
354 356
355 if (down_interruptible(&xt[af].mutex) != 0) 357 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
356 return ERR_PTR(-EINTR); 358 return ERR_PTR(-EINTR);
357 359
358 list_for_each_entry(t, &xt[af].tables, list) 360 list_for_each_entry(t, &xt[af].tables, list)
359 if (strcmp(t->name, name) == 0 && try_module_get(t->me)) 361 if (strcmp(t->name, name) == 0 && try_module_get(t->me))
360 return t; 362 return t;
361 up(&xt[af].mutex); 363 mutex_unlock(&xt[af].mutex);
362 return NULL; 364 return NULL;
363} 365}
364EXPORT_SYMBOL_GPL(xt_find_table_lock); 366EXPORT_SYMBOL_GPL(xt_find_table_lock);
365 367
366void xt_table_unlock(struct xt_table *table) 368void xt_table_unlock(struct xt_table *table)
367{ 369{
368 up(&xt[table->af].mutex); 370 mutex_unlock(&xt[table->af].mutex);
369} 371}
370EXPORT_SYMBOL_GPL(xt_table_unlock); 372EXPORT_SYMBOL_GPL(xt_table_unlock);
371 373
@@ -405,7 +407,7 @@ int xt_register_table(struct xt_table *table,
405 int ret; 407 int ret;
406 struct xt_table_info *private; 408 struct xt_table_info *private;
407 409
408 ret = down_interruptible(&xt[table->af].mutex); 410 ret = mutex_lock_interruptible(&xt[table->af].mutex);
409 if (ret != 0) 411 if (ret != 0)
410 return ret; 412 return ret;
411 413
@@ -431,7 +433,7 @@ int xt_register_table(struct xt_table *table,
431 433
432 ret = 0; 434 ret = 0;
433 unlock: 435 unlock:
434 up(&xt[table->af].mutex); 436 mutex_unlock(&xt[table->af].mutex);
435 return ret; 437 return ret;
436} 438}
437EXPORT_SYMBOL_GPL(xt_register_table); 439EXPORT_SYMBOL_GPL(xt_register_table);
@@ -440,10 +442,10 @@ void *xt_unregister_table(struct xt_table *table)
440{ 442{
441 struct xt_table_info *private; 443 struct xt_table_info *private;
442 444
443 down(&xt[table->af].mutex); 445 mutex_lock(&xt[table->af].mutex);
444 private = table->private; 446 private = table->private;
445 LIST_DELETE(&xt[table->af].tables, table); 447 LIST_DELETE(&xt[table->af].tables, table);
446 up(&xt[table->af].mutex); 448 mutex_unlock(&xt[table->af].mutex);
447 449
448 return private; 450 return private;
449} 451}
@@ -507,7 +509,7 @@ static void *xt_tgt_seq_start(struct seq_file *seq, loff_t *pos)
507 if (!list) 509 if (!list)
508 return NULL; 510 return NULL;
509 511
510 if (down_interruptible(&xt[af].mutex) != 0) 512 if (mutex_lock_interruptible(&xt[af].mutex) != 0)
511 return NULL; 513 return NULL;
512 514
513 return xt_get_idx(list, seq, *pos); 515 return xt_get_idx(list, seq, *pos);
@@ -536,7 +538,7 @@ static void xt_tgt_seq_stop(struct seq_file *seq, void *v)
536 struct proc_dir_entry *pde = seq->private; 538 struct proc_dir_entry *pde = seq->private;
537 u_int16_t af = (unsigned long)pde->data & 0xffff; 539 u_int16_t af = (unsigned long)pde->data & 0xffff;
538 540
539 up(&xt[af].mutex); 541 mutex_unlock(&xt[af].mutex);
540} 542}
541 543
542static int xt_name_seq_show(struct seq_file *seq, void *v) 544static int xt_name_seq_show(struct seq_file *seq, void *v)
@@ -668,7 +670,7 @@ static int __init xt_init(void)
668 return -ENOMEM; 670 return -ENOMEM;
669 671
670 for (i = 0; i < NPROTO; i++) { 672 for (i = 0; i < NPROTO; i++) {
671 init_MUTEX(&xt[i].mutex); 673 mutex_init(&xt[i].mutex);
672 INIT_LIST_HEAD(&xt[i].target); 674 INIT_LIST_HEAD(&xt[i].target);
673 INIT_LIST_HEAD(&xt[i].match); 675 INIT_LIST_HEAD(&xt[i].match);
674 INIT_LIST_HEAD(&xt[i].tables); 676 INIT_LIST_HEAD(&xt[i].tables);
diff --git a/net/rxrpc/main.c b/net/rxrpc/main.c
index 36fdcbcd80d1..48cbd065bb45 100644
--- a/net/rxrpc/main.c
+++ b/net/rxrpc/main.c
@@ -79,8 +79,8 @@ static int __init rxrpc_initialise(void)
79 error_sysctl: 79 error_sysctl:
80#ifdef CONFIG_SYSCTL 80#ifdef CONFIG_SYSCTL
81 rxrpc_sysctl_cleanup(); 81 rxrpc_sysctl_cleanup();
82#endif
83 error_proc: 82 error_proc:
83#endif
84#ifdef CONFIG_PROC_FS 84#ifdef CONFIG_PROC_FS
85 rxrpc_proc_cleanup(); 85 rxrpc_proc_cleanup();
86#endif 86#endif
diff --git a/net/sctp/input.c b/net/sctp/input.c
index cb78b50868ee..d117ebc75cf8 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -127,7 +127,6 @@ int sctp_rcv(struct sk_buff *skb)
127 union sctp_addr dest; 127 union sctp_addr dest;
128 int family; 128 int family;
129 struct sctp_af *af; 129 struct sctp_af *af;
130 int ret = 0;
131 130
132 if (skb->pkt_type!=PACKET_HOST) 131 if (skb->pkt_type!=PACKET_HOST)
133 goto discard_it; 132 goto discard_it;
@@ -227,16 +226,13 @@ int sctp_rcv(struct sk_buff *skb)
227 goto discard_release; 226 goto discard_release;
228 nf_reset(skb); 227 nf_reset(skb);
229 228
230 ret = sk_filter(sk, skb, 1); 229 if (sk_filter(sk, skb, 1))
231 if (ret)
232 goto discard_release; 230 goto discard_release;
233 231
234 /* Create an SCTP packet structure. */ 232 /* Create an SCTP packet structure. */
235 chunk = sctp_chunkify(skb, asoc, sk); 233 chunk = sctp_chunkify(skb, asoc, sk);
236 if (!chunk) { 234 if (!chunk)
237 ret = -ENOMEM;
238 goto discard_release; 235 goto discard_release;
239 }
240 SCTP_INPUT_CB(skb)->chunk = chunk; 236 SCTP_INPUT_CB(skb)->chunk = chunk;
241 237
242 /* Remember what endpoint is to handle this packet. */ 238 /* Remember what endpoint is to handle this packet. */
@@ -277,11 +273,11 @@ int sctp_rcv(struct sk_buff *skb)
277 sctp_bh_unlock_sock(sk); 273 sctp_bh_unlock_sock(sk);
278 sock_put(sk); 274 sock_put(sk);
279 275
280 return ret; 276 return 0;
281 277
282discard_it: 278discard_it:
283 kfree_skb(skb); 279 kfree_skb(skb);
284 return ret; 280 return 0;
285 281
286discard_release: 282discard_release:
287 /* Release any structures we may be holding. */ 283 /* Release any structures we may be holding. */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 0ea947eb6813..b6e4b89539b3 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)
4894 /* Is there any exceptional events? */ 4894 /* Is there any exceptional events? */
4895 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 4895 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
4896 mask |= POLLERR; 4896 mask |= POLLERR;
4897 if (sk->sk_shutdown & RCV_SHUTDOWN)
4898 mask |= POLLRDHUP;
4897 if (sk->sk_shutdown == SHUTDOWN_MASK) 4899 if (sk->sk_shutdown == SHUTDOWN_MASK)
4898 mask |= POLLHUP; 4900 mask |= POLLHUP;
4899 4901
diff --git a/net/socket.c b/net/socket.c
index e2d5bae994de..5211ba270375 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -319,7 +319,8 @@ static int init_inodecache(void)
319{ 319{
320 sock_inode_cachep = kmem_cache_create("sock_inode_cache", 320 sock_inode_cachep = kmem_cache_create("sock_inode_cache",
321 sizeof(struct socket_alloc), 321 sizeof(struct socket_alloc),
322 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 322 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
323 SLAB_MEM_SPREAD),
323 init_once, NULL); 324 init_once, NULL);
324 if (sock_inode_cachep == NULL) 325 if (sock_inode_cachep == NULL)
325 return -ENOMEM; 326 return -ENOMEM;
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 391d2bfc71aa..aa4158be9900 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -852,9 +852,10 @@ init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
852int register_rpc_pipefs(void) 852int register_rpc_pipefs(void)
853{ 853{
854 rpc_inode_cachep = kmem_cache_create("rpc_inode_cache", 854 rpc_inode_cachep = kmem_cache_create("rpc_inode_cache",
855 sizeof(struct rpc_inode), 855 sizeof(struct rpc_inode),
856 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, 856 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
857 init_once, NULL); 857 SLAB_MEM_SPREAD),
858 init_once, NULL);
858 if (!rpc_inode_cachep) 859 if (!rpc_inode_cachep)
859 return -ENOMEM; 860 return -ENOMEM;
860 register_filesystem(&rpc_pipe_fs_type); 861 register_filesystem(&rpc_pipe_fs_type);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 910b37e5083d..784b24b6d102 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,
1629 tipc_msg_print(TIPC_CONS, buf_msg(buf), ">RETR>"); 1629 tipc_msg_print(TIPC_CONS, buf_msg(buf), ">RETR>");
1630 info("...Retransmitted %u times\n", 1630 info("...Retransmitted %u times\n",
1631 l_ptr->stale_count); 1631 l_ptr->stale_count);
1632 link_print(l_ptr, TIPC_CONS, "Resetting Link\n");; 1632 link_print(l_ptr, TIPC_CONS, "Resetting Link\n");
1633 tipc_link_reset(l_ptr); 1633 tipc_link_reset(l_ptr);
1634 break; 1634 break;
1635 } 1635 }
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 2b4cc2eea5b3..d901465ce013 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
1878 mask |= POLLERR; 1878 mask |= POLLERR;
1879 if (sk->sk_shutdown == SHUTDOWN_MASK) 1879 if (sk->sk_shutdown == SHUTDOWN_MASK)
1880 mask |= POLLHUP; 1880 mask |= POLLHUP;
1881 if (sk->sk_shutdown & RCV_SHUTDOWN)
1882 mask |= POLLRDHUP;
1881 1883
1882 /* readable? */ 1884 /* readable? */
1883 if (!skb_queue_empty(&sk->sk_receive_queue) || 1885 if (!skb_queue_empty(&sk->sk_receive_queue) ||
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 0168d6c37075..59620b1554e0 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -44,6 +44,43 @@ define filechk
44 fi 44 fi
45endef 45endef
46 46
47######
48# gcc support functions
49# See documentation in Documentation/kbuild/makefiles.txt
50
51# as-option
52# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
53
54as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
55 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
56 else echo "$(2)"; fi ;)
57
58# cc-option
59# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
60
61cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
62 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
63
64# cc-option-yn
65# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
66cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
67 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
68
69# cc-option-align
70# Prefix align with either -falign or -malign
71cc-option-align = $(subst -functions=0,,\
72 $(call cc-option,-falign-functions=0,-malign-functions=0))
73
74# cc-version
75# Usage gcc-ver := $(call cc-version, $(CC))
76cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
77 $(if $(1), $(1), $(CC)))
78
79# cc-ifversion
80# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
81cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
82 echo $(3); fi;)
83
47### 84###
48# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= 85# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
49# Usage: 86# Usage:
@@ -51,8 +88,7 @@ endef
51build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj 88build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
52 89
53# If quiet is set, only print short version of command 90# If quiet is set, only print short version of command
54cmd = @$(if $($(quiet)cmd_$(1)),\ 91cmd = @$(echo-cmd) $(cmd_$(1))
55 echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
56 92
57# Add $(obj)/ for paths that is not absolute 93# Add $(obj)/ for paths that is not absolute
58objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) 94objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -75,30 +111,33 @@ endif
75echo-cmd = $(if $($(quiet)cmd_$(1)), \ 111echo-cmd = $(if $($(quiet)cmd_$(1)), \
76 echo ' $(call escsq,$($(quiet)cmd_$(1)))';) 112 echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
77 113
114make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
115
78# function to only execute the passed command if necessary 116# function to only execute the passed command if necessary
79# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file 117# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
80# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars 118# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
81# 119#
82if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 120if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
121 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
83 @set -e; \ 122 @set -e; \
84 $(echo-cmd) \ 123 $(echo-cmd) $(cmd_$(1)); \
85 $(cmd_$(1)); \ 124 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
86 echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
87 125
88# execute the command and also postprocess generated .d dependencies 126# execute the command and also postprocess generated .d dependencies
89# file 127# file
90if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ 128if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
91 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 129 $(filter-out FORCE $(wildcard $^),$^) \
130 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
92 @set -e; \ 131 @set -e; \
93 $(echo-cmd) \ 132 $(echo-cmd) $(cmd_$(1)); \
94 $(cmd_$(1)); \ 133 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
95 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
96 rm -f $(depfile); \ 134 rm -f $(depfile); \
97 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) 135 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
98 136
99# Usage: $(call if_changed_rule,foo) 137# Usage: $(call if_changed_rule,foo)
100# will check if $(cmd_foo) changed, or any of the prequisites changed, 138# will check if $(cmd_foo) changed, or any of the prequisites changed,
101# and if so will execute $(rule_foo) 139# and if so will execute $(rule_foo)
102if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ 140if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
141 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
103 @set -e; \ 142 @set -e; \
104 $(rule_$(1))) 143 $(rule_$(1)))
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index c33e62bde6b0..e48e60da3040 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -4,17 +4,18 @@
4 4
5src := $(obj) 5src := $(obj)
6 6
7.PHONY: __build 7PHONY := __build
8__build: 8__build:
9 9
10# Read .config if it exist, otherwise ignore 10# Read .config if it exist, otherwise ignore
11-include .config 11-include .config
12 12
13include scripts/Kbuild.include
14
13# The filename Kbuild has precedence over Makefile 15# The filename Kbuild has precedence over Makefile
14kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 16kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
15include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) 17include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
16 18
17include scripts/Kbuild.include
18include scripts/Makefile.lib 19include scripts/Makefile.lib
19 20
20ifdef host-progs 21ifdef host-progs
@@ -128,7 +129,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi)
128$(multi-objs-y:.o=.lst) : modname = $(modname-multi) 129$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
129 130
130quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 131quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
131cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< 132cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
132 133
133%.s: %.c FORCE 134%.s: %.c FORCE
134 $(call if_changed_dep,cc_s_c) 135 $(call if_changed_dep,cc_s_c)
@@ -165,7 +166,7 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
165cmd_modversions = \ 166cmd_modversions = \
166 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ 167 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
167 $(CPP) -D__GENKSYMS__ $(c_flags) $< \ 168 $(CPP) -D__GENKSYMS__ $(c_flags) $< \
168 | $(GENKSYMS) \ 169 | $(GENKSYMS) -a $(ARCH) \
169 > $(@D)/.tmp_$(@F:.o=.ver); \ 170 > $(@D)/.tmp_$(@F:.o=.ver); \
170 \ 171 \
171 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ 172 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
@@ -177,12 +178,10 @@ cmd_modversions = \
177endif 178endif
178 179
179define rule_cc_o_c 180define rule_cc_o_c
180 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ 181 $(call echo-cmd,checksrc) $(cmd_checksrc) \
181 $(cmd_checksrc) \ 182 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
182 $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \
183 $(cmd_cc_o_c); \
184 $(cmd_modversions) \ 183 $(cmd_modversions) \
185 scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \ 184 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \
186 rm -f $(depfile); \ 185 rm -f $(depfile); \
187 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd 186 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
188endef 187endef
@@ -309,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m)
309# Descending 308# Descending
310# --------------------------------------------------------------------------- 309# ---------------------------------------------------------------------------
311 310
312.PHONY: $(subdir-ym) 311PHONY += $(subdir-ym)
313$(subdir-ym): 312$(subdir-ym):
314 $(Q)$(MAKE) $(build)=$@ 313 $(Q)$(MAKE) $(build)=$@
315 314
316# Add FORCE to the prequisites of a target to force it to be always rebuilt. 315# Add FORCE to the prequisites of a target to force it to be always rebuilt.
317# --------------------------------------------------------------------------- 316# ---------------------------------------------------------------------------
318 317
319.PHONY: FORCE 318PHONY += FORCE
320 319
321FORCE: 320FORCE:
322 321
@@ -331,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
331ifneq ($(cmd_files),) 330ifneq ($(cmd_files),)
332 include $(cmd_files) 331 include $(cmd_files)
333endif 332endif
333
334
335# Declare the contents of the .PHONY variable as phony. We keep that
336# information in a variable se we can use it in if_changed and friends.
337
338.PHONY: $(PHONY)
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 8974ea5fc878..cff33498fa16 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -4,7 +4,7 @@
4 4
5src := $(obj) 5src := $(obj)
6 6
7.PHONY: __clean 7PHONY := __clean
8__clean: 8__clean:
9 9
10# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir 10# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
@@ -87,10 +87,16 @@ endif
87# Descending 87# Descending
88# --------------------------------------------------------------------------- 88# ---------------------------------------------------------------------------
89 89
90.PHONY: $(subdir-ymn) 90PHONY += $(subdir-ymn)
91$(subdir-ymn): 91$(subdir-ymn):
92 $(Q)$(MAKE) $(clean)=$@ 92 $(Q)$(MAKE) $(clean)=$@
93 93
94# If quiet is set, only print short version of command 94# If quiet is set, only print short version of command
95 95
96cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) 96cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
97
98
99# Declare the contents of the .PHONY variable as phony. We keep that
100# information in a variable se we can use it in if_changed and friends.
101
102.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 23fd1bdc25ce..2686dd5dce8c 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -2,7 +2,7 @@
2# Installing modules 2# Installing modules
3# ========================================================================== 3# ==========================================================================
4 4
5.PHONY: __modinst 5PHONY := __modinst
6__modinst: 6__modinst:
7 7
8include scripts/Kbuild.include 8include scripts/Kbuild.include
@@ -12,7 +12,7 @@ include scripts/Kbuild.include
12__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 12__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
13modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) 13modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
14 14
15.PHONY: $(modules) 15PHONY += $(modules)
16__modinst: $(modules) 16__modinst: $(modules)
17 @: 17 @:
18 18
@@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
27 27
28$(modules): 28$(modules):
29 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) 29 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
30
31
32# Declare the contents of the .PHONY variable as phony. We keep that
33# information in a variable se we can use it in if_changed and friends.
34
35.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index bf96a61d4b86..0e056cffffdb 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -4,7 +4,7 @@
4# 4#
5# Stage one of module building created the following: 5# Stage one of module building created the following:
6# a) The individual .o files used for the module 6# a) The individual .o files used for the module
7# b) A <module>.o file wich is the .o files above linked together 7# b) A <module>.o file which is the .o files above linked together
8# c) A <module>.mod file in $(MODVERDIR)/, listing the name of the 8# c) A <module>.mod file in $(MODVERDIR)/, listing the name of the
9# the preliminary <module>.o file, plus all .o files 9# the preliminary <module>.o file, plus all .o files
10 10
@@ -32,14 +32,15 @@
32# Step 4 is solely used to allow module versioning in external modules, 32# Step 4 is solely used to allow module versioning in external modules,
33# where the CRC of each module is retrieved from the Module.symers file. 33# where the CRC of each module is retrieved from the Module.symers file.
34 34
35.PHONY: _modpost 35PHONY := _modpost
36_modpost: __modpost 36_modpost: __modpost
37 37
38include .config 38include .config
39include scripts/Kbuild.include 39include scripts/Kbuild.include
40include scripts/Makefile.lib 40include scripts/Makefile.lib
41 41
42symverfile := $(objtree)/Module.symvers 42kernelsymfile := $(objtree)/Module.symvers
43modulesymfile := $(KBUILD_EXTMOD)/Modules.symvers
43 44
44# Step 1), find all modules listed in $(MODVERDIR)/ 45# Step 1), find all modules listed in $(MODVERDIR)/
45__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 46__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
@@ -54,10 +55,12 @@ quiet_cmd_modpost = MODPOST
54 cmd_modpost = scripts/mod/modpost \ 55 cmd_modpost = scripts/mod/modpost \
55 $(if $(CONFIG_MODVERSIONS),-m) \ 56 $(if $(CONFIG_MODVERSIONS),-m) \
56 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ 57 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
57 $(if $(KBUILD_EXTMOD),-i,-o) $(symverfile) \ 58 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
59 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
60 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
58 $(filter-out FORCE,$^) 61 $(filter-out FORCE,$^)
59 62
60.PHONY: __modpost 63PHONY += __modpost
61__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE 64__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
62 $(call cmd,modpost) 65 $(call cmd,modpost)
63 66
@@ -94,7 +97,7 @@ targets += $(modules)
94# Add FORCE to the prequisites of a target to force it to be always rebuilt. 97# Add FORCE to the prequisites of a target to force it to be always rebuilt.
95# --------------------------------------------------------------------------- 98# ---------------------------------------------------------------------------
96 99
97.PHONY: FORCE 100PHONY += FORCE
98 101
99FORCE: 102FORCE:
100 103
@@ -109,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
109ifneq ($(cmd_files),) 112ifneq ($(cmd_files),)
110 include $(cmd_files) 113 include $(cmd_files)
111endif 114endif
115
116
117# Declare the contents of the .PHONY variable as phony. We keep that
118# information in a variable se we can use it in if_changed and friends.
119
120.PHONY: $(PHONY)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 679124b11e12..668a11a8b383 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -132,20 +132,10 @@ void usage(void)
132 132
133/* 133/*
134 * Print out the commandline prefixed with cmd_<target filename> := 134 * Print out the commandline prefixed with cmd_<target filename> :=
135 * If commandline contains '#' escape with '\' so make to not see 135 */
136 * the '#' as a start-of-comment symbol
137 **/
138void print_cmdline(void) 136void print_cmdline(void)
139{ 137{
140 char *p = cmdline; 138 printf("cmd_%s := %s\n\n", target, cmdline);
141
142 printf("cmd_%s := ", target);
143 for (; *p; p++) {
144 if (*p == '#')
145 printf("\\");
146 printf("%c", *p);
147 }
148 printf("\n\n");
149} 139}
150 140
151char * str_config = NULL; 141char * str_config = NULL;
diff --git a/scripts/checkconfig.pl b/scripts/checkconfig.pl
deleted file mode 100755
index ca1f231b15a6..000000000000
--- a/scripts/checkconfig.pl
+++ /dev/null
@@ -1,65 +0,0 @@
1#! /usr/bin/perl
2#
3# checkconfig: find uses of CONFIG_* names without matching definitions.
4# Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
5
6use integer;
7
8$| = 1;
9
10foreach $file (@ARGV)
11{
12 # Open this file.
13 open(FILE, $file) || die "Can't open $file: $!\n";
14
15 # Initialize variables.
16 my $fInComment = 0;
17 my $fInString = 0;
18 my $fUseConfig = 0;
19 my $iLinuxConfig = 0;
20 my %configList = ();
21
22 LINE: while ( <FILE> )
23 {
24 # Strip comments.
25 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
26 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
27
28 # Pick up definitions.
29 if ( m/^\s*#/o )
30 {
31 $iLinuxConfig = $. if m/^\s*#\s*include\s*"linux\/config\.h"/o;
32 $configList{uc $1} = 1 if m/^\s*#\s*include\s*"config\/(\S*)\.h"/o;
33 }
34
35 # Strip strings.
36 $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
37 m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
38
39 # Pick up definitions.
40 if ( m/^\s*#/o )
41 {
42 $iLinuxConfig = $. if m/^\s*#\s*include\s*<linux\/config\.h>/o;
43 $configList{uc $1} = 1 if m/^\s*#\s*include\s*<config\/(\S*)\.h>/o;
44 $configList{$1} = 1 if m/^\s*#\s*define\s+CONFIG_(\w*)/o;
45 $configList{$1} = 1 if m/^\s*#\s*undef\s+CONFIG_(\w*)/o;
46 }
47
48 # Look for usages.
49 next unless m/CONFIG_/o;
50 WORD: while ( m/\bCONFIG_(\w+)/og )
51 {
52 $fUseConfig = 1;
53 last LINE if $iLinuxConfig;
54 next WORD if exists $configList{$1};
55 print "$file: $.: need CONFIG_$1.\n";
56 $configList{$1} = 0;
57 }
58 }
59
60 # Report superfluous includes.
61 if ( $iLinuxConfig && ! $fUseConfig )
62 { print "$file: $iLinuxConfig: linux/config.h not needed.\n"; }
63
64 close(FILE);
65}
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index d9f9f34b22ab..8187e6f0dc2f 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -4,6 +4,7 @@
4# $arg1 is [b]zImage filename 4# $arg1 is [b]zImage filename
5 5
6binoffset="./scripts/binoffset" 6binoffset="./scripts/binoffset"
7test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
7 8
8IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54" 9IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
9IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44" 10IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
@@ -20,7 +21,7 @@ function dump_config {
20 let start="$start + 8" 21 let start="$start + 8"
21 let size="$end - $start" 22 let size="$end - $start"
22 23
23 head --bytes="$end" "$file" | tail --bytes="$size" | zcat 24 dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
24 25
25 clean_up 26 clean_up
26 exit 0 27 exit 0
@@ -45,7 +46,7 @@ then
45 exit 1 46 exit 1
46fi 47fi
47 48
48TMPFILE="/tmp/ikconfig-$$" 49TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1
49image="$1" 50image="$1"
50 51
51# vmlinux: Attempt to dump the configuration from the file directly 52# vmlinux: Attempt to dump the configuration from the file directly
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 416a694b0998..5b0344e20d61 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -29,481 +29,421 @@
29#include <stdarg.h> 29#include <stdarg.h>
30#ifdef __GNU_LIBRARY__ 30#ifdef __GNU_LIBRARY__
31#include <getopt.h> 31#include <getopt.h>
32#endif /* __GNU_LIBRARY__ */ 32#endif /* __GNU_LIBRARY__ */
33 33
34#include "genksyms.h" 34#include "genksyms.h"
35
36/*----------------------------------------------------------------------*/ 35/*----------------------------------------------------------------------*/
37 36
38#define HASH_BUCKETS 4096 37#define HASH_BUCKETS 4096
39 38
40static struct symbol *symtab[HASH_BUCKETS]; 39static struct symbol *symtab[HASH_BUCKETS];
41FILE *debugfile; 40static FILE *debugfile;
42 41
43int cur_line = 1; 42int cur_line = 1;
44char *cur_filename, *output_directory; 43char *cur_filename;
45 44
46int flag_debug, flag_dump_defs, flag_warnings; 45static int flag_debug, flag_dump_defs, flag_warnings;
46static const char *arch = "";
47static const char *mod_prefix = "";
47 48
48static int errors; 49static int errors;
49static int nsyms; 50static int nsyms;
50 51
51static struct symbol *expansion_trail; 52static struct symbol *expansion_trail;
52 53
53static const char * const symbol_type_name[] = { 54static const char *const symbol_type_name[] = {
54 "normal", "typedef", "enum", "struct", "union" 55 "normal", "typedef", "enum", "struct", "union"
55}; 56};
56 57
58static int equal_list(struct string_list *a, struct string_list *b);
59static void print_list(FILE * f, struct string_list *list);
60
57/*----------------------------------------------------------------------*/ 61/*----------------------------------------------------------------------*/
58 62
59static const unsigned int crctab32[] = 63static const unsigned int crctab32[] = {
60{ 64 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
61 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, 65 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
62 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, 66 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
63 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, 67 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU,
64 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, 68 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U,
65 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, 69 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U,
66 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, 70 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U,
67 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, 71 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU,
68 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, 72 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U,
69 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, 73 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU,
70 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, 74 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U,
71 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, 75 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U,
72 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, 76 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U,
73 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, 77 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU,
74 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, 78 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU,
75 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, 79 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U,
76 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, 80 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU,
77 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, 81 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U,
78 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, 82 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U,
79 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, 83 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U,
80 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, 84 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU,
81 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, 85 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U,
82 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, 86 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U,
83 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, 87 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU,
84 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, 88 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U,
85 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, 89 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U,
86 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, 90 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U,
87 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, 91 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U,
88 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, 92 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U,
89 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, 93 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU,
90 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, 94 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU,
91 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, 95 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U,
92 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, 96 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U,
93 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, 97 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU,
94 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, 98 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU,
95 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, 99 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U,
96 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, 100 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU,
97 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, 101 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U,
98 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, 102 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU,
99 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, 103 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U,
100 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, 104 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU,
101 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, 105 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U,
102 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, 106 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U,
103 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, 107 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU,
104 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, 108 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U,
105 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, 109 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U,
106 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, 110 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U,
107 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, 111 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U,
108 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, 112 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U,
109 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, 113 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U,
110 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, 114 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU,
111 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, 115 0x2d02ef8dU
112 0x2d02ef8dU
113}; 116};
114 117
115static inline unsigned long 118static unsigned long partial_crc32_one(unsigned char c, unsigned long crc)
116partial_crc32_one(unsigned char c, unsigned long crc)
117{ 119{
118 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); 120 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
119} 121}
120 122
121static inline unsigned long 123static unsigned long partial_crc32(const char *s, unsigned long crc)
122partial_crc32(const char *s, unsigned long crc)
123{ 124{
124 while (*s) 125 while (*s)
125 crc = partial_crc32_one(*s++, crc); 126 crc = partial_crc32_one(*s++, crc);
126 return crc; 127 return crc;
127} 128}
128 129
129static inline unsigned long 130static unsigned long crc32(const char *s)
130crc32(const char *s)
131{ 131{
132 return partial_crc32(s, 0xffffffff) ^ 0xffffffff; 132 return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
133} 133}
134 134
135
136/*----------------------------------------------------------------------*/ 135/*----------------------------------------------------------------------*/
137 136
138static inline enum symbol_type 137static enum symbol_type map_to_ns(enum symbol_type t)
139map_to_ns(enum symbol_type t)
140{ 138{
141 if (t == SYM_TYPEDEF) 139 if (t == SYM_TYPEDEF)
142 t = SYM_NORMAL; 140 t = SYM_NORMAL;
143 else if (t == SYM_UNION) 141 else if (t == SYM_UNION)
144 t = SYM_STRUCT; 142 t = SYM_STRUCT;
145 return t; 143 return t;
146} 144}
147 145
148struct symbol * 146struct symbol *find_symbol(const char *name, enum symbol_type ns)
149find_symbol(const char *name, enum symbol_type ns)
150{ 147{
151 unsigned long h = crc32(name) % HASH_BUCKETS; 148 unsigned long h = crc32(name) % HASH_BUCKETS;
152 struct symbol *sym; 149 struct symbol *sym;
153 150
154 for (sym = symtab[h]; sym ; sym = sym->hash_next) 151 for (sym = symtab[h]; sym; sym = sym->hash_next)
155 if (map_to_ns(sym->type) == map_to_ns(ns) && strcmp(name, sym->name) == 0) 152 if (map_to_ns(sym->type) == map_to_ns(ns) &&
156 break; 153 strcmp(name, sym->name) == 0)
154 break;
157 155
158 return sym; 156 return sym;
159} 157}
160 158
161struct symbol * 159struct symbol *add_symbol(const char *name, enum symbol_type type,
162add_symbol(const char *name, enum symbol_type type, struct string_list *defn, int is_extern) 160 struct string_list *defn, int is_extern)
163{ 161{
164 unsigned long h = crc32(name) % HASH_BUCKETS; 162 unsigned long h = crc32(name) % HASH_BUCKETS;
165 struct symbol *sym; 163 struct symbol *sym;
166 164
167 for (sym = symtab[h]; sym ; sym = sym->hash_next) 165 for (sym = symtab[h]; sym; sym = sym->hash_next) {
168 if (map_to_ns(sym->type) == map_to_ns(type) 166 if (map_to_ns(sym->type) == map_to_ns(type)
169 && strcmp(name, sym->name) == 0) 167 && strcmp(name, sym->name) == 0) {
170 { 168 if (!equal_list(sym->defn, defn))
171 if (!equal_list(sym->defn, defn)) 169 error_with_pos("redefinition of %s", name);
172 error_with_pos("redefinition of %s", name); 170 return sym;
171 }
172 }
173
174 sym = xmalloc(sizeof(*sym));
175 sym->name = name;
176 sym->type = type;
177 sym->defn = defn;
178 sym->expansion_trail = NULL;
179 sym->is_extern = is_extern;
180
181 sym->hash_next = symtab[h];
182 symtab[h] = sym;
183
184 if (flag_debug) {
185 fprintf(debugfile, "Defn for %s %s == <",
186 symbol_type_name[type], name);
187 if (is_extern)
188 fputs("extern ", debugfile);
189 print_list(debugfile, defn);
190 fputs(">\n", debugfile);
191 }
192
193 ++nsyms;
173 return sym; 194 return sym;
174 }
175
176 sym = xmalloc(sizeof(*sym));
177 sym->name = name;
178 sym->type = type;
179 sym->defn = defn;
180 sym->expansion_trail = NULL;
181 sym->is_extern = is_extern;
182
183 sym->hash_next = symtab[h];
184 symtab[h] = sym;
185
186 if (flag_debug)
187 {
188 fprintf(debugfile, "Defn for %s %s == <", symbol_type_name[type], name);
189 if (is_extern)
190 fputs("extern ", debugfile);
191 print_list(debugfile, defn);
192 fputs(">\n", debugfile);
193 }
194
195 ++nsyms;
196 return sym;
197} 195}
198 196
199
200/*----------------------------------------------------------------------*/ 197/*----------------------------------------------------------------------*/
201 198
202inline void 199void free_node(struct string_list *node)
203free_node(struct string_list *node)
204{ 200{
205 free(node->string); 201 free(node->string);
206 free(node); 202 free(node);
207} 203}
208 204
209void 205void free_list(struct string_list *s, struct string_list *e)
210free_list(struct string_list *s, struct string_list *e)
211{ 206{
212 while (s != e) 207 while (s != e) {
213 { 208 struct string_list *next = s->next;
214 struct string_list *next = s->next; 209 free_node(s);
215 free_node(s); 210 s = next;
216 s = next; 211 }
217 }
218} 212}
219 213
220inline struct string_list * 214struct string_list *copy_node(struct string_list *node)
221copy_node(struct string_list *node)
222{ 215{
223 struct string_list *newnode; 216 struct string_list *newnode;
224 217
225 newnode = xmalloc(sizeof(*newnode)); 218 newnode = xmalloc(sizeof(*newnode));
226 newnode->string = xstrdup(node->string); 219 newnode->string = xstrdup(node->string);
227 newnode->tag = node->tag; 220 newnode->tag = node->tag;
228 221
229 return newnode; 222 return newnode;
230} 223}
231 224
232struct string_list * 225static int equal_list(struct string_list *a, struct string_list *b)
233copy_list(struct string_list *s, struct string_list *e)
234{ 226{
235 struct string_list *h, *p; 227 while (a && b) {
236 228 if (a->tag != b->tag || strcmp(a->string, b->string))
237 if (s == e) 229 return 0;
238 return NULL; 230 a = a->next;
239 231 b = b->next;
240 p = h = copy_node(s); 232 }
241 while ((s = s->next) != e)
242 p = p->next = copy_node(s);
243 p->next = NULL;
244
245 return h;
246}
247 233
248int 234 return !a && !b;
249equal_list(struct string_list *a, struct string_list *b)
250{
251 while (a && b)
252 {
253 if (a->tag != b->tag || strcmp(a->string, b->string))
254 return 0;
255 a = a->next;
256 b = b->next;
257 }
258
259 return !a && !b;
260} 235}
261 236
262static inline void 237static void print_node(FILE * f, struct string_list *list)
263print_node(FILE *f, struct string_list *list)
264{ 238{
265 switch (list->tag) 239 switch (list->tag) {
266 { 240 case SYM_STRUCT:
267 case SYM_STRUCT: 241 putc('s', f);
268 putc('s', f); 242 goto printit;
269 goto printit; 243 case SYM_UNION:
270 case SYM_UNION: 244 putc('u', f);
271 putc('u', f); 245 goto printit;
272 goto printit; 246 case SYM_ENUM:
273 case SYM_ENUM: 247 putc('e', f);
274 putc('e', f); 248 goto printit;
275 goto printit; 249 case SYM_TYPEDEF:
276 case SYM_TYPEDEF: 250 putc('t', f);
277 putc('t', f); 251 goto printit;
278 goto printit;
279
280 printit:
281 putc('#', f);
282 case SYM_NORMAL:
283 fputs(list->string, f);
284 break;
285 }
286}
287 252
288void 253 printit:
289print_list(FILE *f, struct string_list *list) 254 putc('#', f);
290{ 255 case SYM_NORMAL:
291 struct string_list **e, **b; 256 fputs(list->string, f);
292 struct string_list *tmp, **tmp2; 257 break;
293 int elem = 1; 258 }
294
295 if (list == NULL)
296 {
297 fputs("(nil)", f);
298 return;
299 }
300
301 tmp = list;
302 while((tmp = tmp->next) != NULL)
303 elem++;
304
305 b = alloca(elem * sizeof(*e));
306 e = b + elem;
307 tmp2 = e - 1;
308
309 (*tmp2--) = list;
310 while((list = list->next) != NULL)
311 *(tmp2--) = list;
312
313 while (b != e)
314 {
315 print_node(f, *b++);
316 putc(' ', f);
317 }
318} 259}
319 260
320static unsigned long 261static void print_list(FILE * f, struct string_list *list)
321expand_and_crc_list(struct string_list *list, unsigned long crc)
322{ 262{
323 struct string_list **e, **b; 263 struct string_list **e, **b;
324 struct string_list *tmp, **tmp2; 264 struct string_list *tmp, **tmp2;
325 int elem = 1; 265 int elem = 1;
326
327 if (!list)
328 return crc;
329 266
330 tmp = list; 267 if (list == NULL) {
331 while((tmp = tmp->next) != NULL) 268 fputs("(nil)", f);
332 elem++; 269 return;
333 270 }
334 b = alloca(elem * sizeof(*e));
335 e = b + elem;
336 tmp2 = e - 1;
337 271
338 *(tmp2--) = list; 272 tmp = list;
339 while ((list = list->next) != NULL) 273 while ((tmp = tmp->next) != NULL)
340 *(tmp2--) = list; 274 elem++;
341 275
342 while (b != e) 276 b = alloca(elem * sizeof(*e));
343 { 277 e = b + elem;
344 struct string_list *cur; 278 tmp2 = e - 1;
345 struct symbol *subsym;
346 279
347 cur = *(b++); 280 (*tmp2--) = list;
348 switch (cur->tag) 281 while ((list = list->next) != NULL)
349 { 282 *(tmp2--) = list;
350 case SYM_NORMAL:
351 if (flag_dump_defs)
352 fprintf(debugfile, "%s ", cur->string);
353 crc = partial_crc32(cur->string, crc);
354 crc = partial_crc32_one(' ', crc);
355 break;
356 283
357 case SYM_TYPEDEF: 284 while (b != e) {
358 subsym = find_symbol(cur->string, cur->tag); 285 print_node(f, *b++);
359 if (subsym->expansion_trail) 286 putc(' ', f);
360 { 287 }
361 if (flag_dump_defs) 288}
362 fprintf(debugfile, "%s ", cur->string);
363 crc = partial_crc32(cur->string, crc);
364 crc = partial_crc32_one(' ', crc);
365 }
366 else
367 {
368 subsym->expansion_trail = expansion_trail;
369 expansion_trail = subsym;
370 crc = expand_and_crc_list(subsym->defn, crc);
371 }
372 break;
373 289
374 case SYM_STRUCT: 290static unsigned long expand_and_crc_list(struct string_list *list,
375 case SYM_UNION: 291 unsigned long crc)
376 case SYM_ENUM: 292{
377 subsym = find_symbol(cur->string, cur->tag); 293 struct string_list **e, **b;
378 if (!subsym) 294 struct string_list *tmp, **tmp2;
379 { 295 int elem = 1;
380 struct string_list *n, *t = NULL; 296
381 297 if (!list)
382 error_with_pos("expand undefined %s %s", 298 return crc;
383 symbol_type_name[cur->tag], cur->string); 299
384 300 tmp = list;
385 n = xmalloc(sizeof(*n)); 301 while ((tmp = tmp->next) != NULL)
386 n->string = xstrdup(symbol_type_name[cur->tag]); 302 elem++;
387 n->tag = SYM_NORMAL; 303
388 n->next = t; 304 b = alloca(elem * sizeof(*e));
389 t = n; 305 e = b + elem;
390 306 tmp2 = e - 1;
391 n = xmalloc(sizeof(*n)); 307
392 n->string = xstrdup(cur->string); 308 *(tmp2--) = list;
393 n->tag = SYM_NORMAL; 309 while ((list = list->next) != NULL)
394 n->next = t; 310 *(tmp2--) = list;
395 t = n; 311
396 312 while (b != e) {
397 n = xmalloc(sizeof(*n)); 313 struct string_list *cur;
398 n->string = xstrdup("{ UNKNOWN }"); 314 struct symbol *subsym;
399 n->tag = SYM_NORMAL; 315
400 n->next = t; 316 cur = *(b++);
401 317 switch (cur->tag) {
402 subsym = add_symbol(cur->string, cur->tag, n, 0); 318 case SYM_NORMAL:
403 } 319 if (flag_dump_defs)
404 if (subsym->expansion_trail) 320 fprintf(debugfile, "%s ", cur->string);
405 { 321 crc = partial_crc32(cur->string, crc);
406 if (flag_dump_defs) 322 crc = partial_crc32_one(' ', crc);
407 { 323 break;
408 fprintf(debugfile, "%s %s ", symbol_type_name[cur->tag], 324
409 cur->string); 325 case SYM_TYPEDEF:
326 subsym = find_symbol(cur->string, cur->tag);
327 if (subsym->expansion_trail) {
328 if (flag_dump_defs)
329 fprintf(debugfile, "%s ", cur->string);
330 crc = partial_crc32(cur->string, crc);
331 crc = partial_crc32_one(' ', crc);
332 } else {
333 subsym->expansion_trail = expansion_trail;
334 expansion_trail = subsym;
335 crc = expand_and_crc_list(subsym->defn, crc);
336 }
337 break;
338
339 case SYM_STRUCT:
340 case SYM_UNION:
341 case SYM_ENUM:
342 subsym = find_symbol(cur->string, cur->tag);
343 if (!subsym) {
344 struct string_list *n, *t = NULL;
345
346 error_with_pos("expand undefined %s %s",
347 symbol_type_name[cur->tag],
348 cur->string);
349
350 n = xmalloc(sizeof(*n));
351 n->string = xstrdup(symbol_type_name[cur->tag]);
352 n->tag = SYM_NORMAL;
353 n->next = t;
354 t = n;
355
356 n = xmalloc(sizeof(*n));
357 n->string = xstrdup(cur->string);
358 n->tag = SYM_NORMAL;
359 n->next = t;
360 t = n;
361
362 n = xmalloc(sizeof(*n));
363 n->string = xstrdup("{ UNKNOWN }");
364 n->tag = SYM_NORMAL;
365 n->next = t;
366
367 subsym =
368 add_symbol(cur->string, cur->tag, n, 0);
369 }
370 if (subsym->expansion_trail) {
371 if (flag_dump_defs) {
372 fprintf(debugfile, "%s %s ",
373 symbol_type_name[cur->tag],
374 cur->string);
375 }
376
377 crc = partial_crc32(symbol_type_name[cur->tag],
378 crc);
379 crc = partial_crc32_one(' ', crc);
380 crc = partial_crc32(cur->string, crc);
381 crc = partial_crc32_one(' ', crc);
382 } else {
383 subsym->expansion_trail = expansion_trail;
384 expansion_trail = subsym;
385 crc = expand_and_crc_list(subsym->defn, crc);
386 }
387 break;
410 } 388 }
411
412 crc = partial_crc32(symbol_type_name[cur->tag], crc);
413 crc = partial_crc32_one(' ', crc);
414 crc = partial_crc32(cur->string, crc);
415 crc = partial_crc32_one(' ', crc);
416 }
417 else
418 {
419 subsym->expansion_trail = expansion_trail;
420 expansion_trail = subsym;
421 crc = expand_and_crc_list(subsym->defn, crc);
422 }
423 break;
424 } 389 }
425 }
426 390
427 return crc; 391 return crc;
428} 392}
429 393
430void 394void export_symbol(const char *name)
431export_symbol(const char *name)
432{ 395{
433 struct symbol *sym; 396 struct symbol *sym;
434 397
435 sym = find_symbol(name, SYM_NORMAL); 398 sym = find_symbol(name, SYM_NORMAL);
436 if (!sym) 399 if (!sym)
437 error_with_pos("export undefined symbol %s", name); 400 error_with_pos("export undefined symbol %s", name);
438 else 401 else {
439 { 402 unsigned long crc;
440 unsigned long crc;
441 403
442 if (flag_dump_defs) 404 if (flag_dump_defs)
443 fprintf(debugfile, "Export %s == <", name); 405 fprintf(debugfile, "Export %s == <", name);
444 406
445 expansion_trail = (struct symbol *)-1L; 407 expansion_trail = (struct symbol *)-1L;
446 408
447 crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff; 409 crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff;
448 410
449 sym = expansion_trail; 411 sym = expansion_trail;
450 while (sym != (struct symbol *)-1L) 412 while (sym != (struct symbol *)-1L) {
451 { 413 struct symbol *n = sym->expansion_trail;
452 struct symbol *n = sym->expansion_trail; 414 sym->expansion_trail = 0;
453 sym->expansion_trail = 0; 415 sym = n;
454 sym = n; 416 }
455 }
456 417
457 if (flag_dump_defs) 418 if (flag_dump_defs)
458 fputs(">\n", debugfile); 419 fputs(">\n", debugfile);
459 420
460 /* Used as a linker script. */ 421 /* Used as a linker script. */
461 printf("__crc_%s = 0x%08lx ;\n", name, crc); 422 printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc);
462 } 423 }
463} 424}
464 425
465/*----------------------------------------------------------------------*/ 426/*----------------------------------------------------------------------*/
466 427void error_with_pos(const char *fmt, ...)
467void
468error(const char *fmt, ...)
469{
470 va_list args;
471
472 if (flag_warnings)
473 {
474 va_start(args, fmt);
475 vfprintf(stderr, fmt, args);
476 va_end(args);
477 putc('\n', stderr);
478
479 errors++;
480 }
481}
482
483void
484error_with_pos(const char *fmt, ...)
485{ 428{
486 va_list args; 429 va_list args;
487 430
488 if (flag_warnings) 431 if (flag_warnings) {
489 { 432 fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>",
490 fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", cur_line); 433 cur_line);
491 434
492 va_start(args, fmt); 435 va_start(args, fmt);
493 vfprintf(stderr, fmt, args); 436 vfprintf(stderr, fmt, args);
494 va_end(args); 437 va_end(args);
495 putc('\n', stderr); 438 putc('\n', stderr);
496 439
497 errors++; 440 errors++;
498 } 441 }
499} 442}
500 443
501 444static void genksyms_usage(void)
502void genksyms_usage(void)
503{ 445{
504 fputs("Usage:\n" 446 fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
505 "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n"
506 "\n"
507#ifdef __GNU_LIBRARY__ 447#ifdef __GNU_LIBRARY__
508 " -d, --debug Increment the debug level (repeatable)\n" 448 " -d, --debug Increment the debug level (repeatable)\n"
509 " -D, --dump Dump expanded symbol defs (for debugging only)\n" 449 " -D, --dump Dump expanded symbol defs (for debugging only)\n"
@@ -511,81 +451,84 @@ void genksyms_usage(void)
511 " -q, --quiet Disable warnings (default)\n" 451 " -q, --quiet Disable warnings (default)\n"
512 " -h, --help Print this message\n" 452 " -h, --help Print this message\n"
513 " -V, --version Print the release version\n" 453 " -V, --version Print the release version\n"
514#else /* __GNU_LIBRARY__ */ 454#else /* __GNU_LIBRARY__ */
515 " -d Increment the debug level (repeatable)\n" 455 " -d Increment the debug level (repeatable)\n"
516 " -D Dump expanded symbol defs (for debugging only)\n" 456 " -D Dump expanded symbol defs (for debugging only)\n"
517 " -w Enable warnings\n" 457 " -w Enable warnings\n"
518 " -q Disable warnings (default)\n" 458 " -q Disable warnings (default)\n"
519 " -h Print this message\n" 459 " -h Print this message\n"
520 " -V Print the release version\n" 460 " -V Print the release version\n"
521#endif /* __GNU_LIBRARY__ */ 461#endif /* __GNU_LIBRARY__ */
522 , stderr); 462 , stderr);
523} 463}
524 464
525int 465int main(int argc, char **argv)
526main(int argc, char **argv)
527{ 466{
528 int o; 467 int o;
529 468
530#ifdef __GNU_LIBRARY__ 469#ifdef __GNU_LIBRARY__
531 struct option long_opts[] = { 470 struct option long_opts[] = {
532 {"debug", 0, 0, 'd'}, 471 {"arch", 1, 0, 'a'},
533 {"warnings", 0, 0, 'w'}, 472 {"debug", 0, 0, 'd'},
534 {"quiet", 0, 0, 'q'}, 473 {"warnings", 0, 0, 'w'},
535 {"dump", 0, 0, 'D'}, 474 {"quiet", 0, 0, 'q'},
536 {"version", 0, 0, 'V'}, 475 {"dump", 0, 0, 'D'},
537 {"help", 0, 0, 'h'}, 476 {"version", 0, 0, 'V'},
538 {0, 0, 0, 0} 477 {"help", 0, 0, 'h'},
539 }; 478 {0, 0, 0, 0}
540 479 };
541 while ((o = getopt_long(argc, argv, "dwqVDk:p:", 480
542 &long_opts[0], NULL)) != EOF) 481 while ((o = getopt_long(argc, argv, "a:dwqVDk:p:",
543#else /* __GNU_LIBRARY__ */ 482 &long_opts[0], NULL)) != EOF)
544 while ((o = getopt(argc, argv, "dwqVDk:p:")) != EOF) 483#else /* __GNU_LIBRARY__ */
545#endif /* __GNU_LIBRARY__ */ 484 while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF)
546 switch (o) 485#endif /* __GNU_LIBRARY__ */
547 { 486 switch (o) {
548 case 'd': 487 case 'a':
549 flag_debug++; 488 arch = optarg;
550 break; 489 break;
551 case 'w': 490 case 'd':
552 flag_warnings = 1; 491 flag_debug++;
553 break; 492 break;
554 case 'q': 493 case 'w':
555 flag_warnings = 0; 494 flag_warnings = 1;
556 break; 495 break;
557 case 'V': 496 case 'q':
558 fputs("genksyms version 2.5.60\n", stderr); 497 flag_warnings = 0;
559 break; 498 break;
560 case 'D': 499 case 'V':
561 flag_dump_defs = 1; 500 fputs("genksyms version 2.5.60\n", stderr);
562 break; 501 break;
563 case 'h': 502 case 'D':
564 genksyms_usage(); 503 flag_dump_defs = 1;
565 return 0; 504 break;
566 default: 505 case 'h':
567 genksyms_usage(); 506 genksyms_usage();
568 return 1; 507 return 0;
569 } 508 default:
570 509 genksyms_usage();
571 { 510 return 1;
572 extern int yydebug; 511 }
573 extern int yy_flex_debug; 512 if ((strcmp(arch, "v850") == 0) || (strcmp(arch, "h8300") == 0))
574 513 mod_prefix = "_";
575 yydebug = (flag_debug > 1); 514 {
576 yy_flex_debug = (flag_debug > 2); 515 extern int yydebug;
577 516 extern int yy_flex_debug;
578 debugfile = stderr; 517
579 /* setlinebuf(debugfile); */ 518 yydebug = (flag_debug > 1);
580 } 519 yy_flex_debug = (flag_debug > 2);
581 520
582 yyparse(); 521 debugfile = stderr;
583 522 /* setlinebuf(debugfile); */
584 if (flag_debug) 523 }
585 { 524
586 fprintf(debugfile, "Hash table occupancy %d/%d = %g\n", 525 yyparse();
587 nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS); 526
588 } 527 if (flag_debug) {
589 528 fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
590 return errors != 0; 529 nsyms, HASH_BUCKETS,
530 (double)nsyms / (double)HASH_BUCKETS);
531 }
532
533 return errors != 0;
591} 534}
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
index f09af47ab281..ab6f34f38735 100644
--- a/scripts/genksyms/genksyms.h
+++ b/scripts/genksyms/genksyms.h
@@ -20,74 +20,51 @@
20 along with this program; if not, write to the Free Software Foundation, 20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 22
23
24#ifndef MODUTILS_GENKSYMS_H 23#ifndef MODUTILS_GENKSYMS_H
25#define MODUTILS_GENKSYMS_H 1 24#define MODUTILS_GENKSYMS_H 1
26 25
27#include <stdio.h> 26#include <stdio.h>
28 27
29 28enum symbol_type {
30enum symbol_type 29 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
31{
32 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
33}; 30};
34 31
35struct string_list 32struct string_list {
36{ 33 struct string_list *next;
37 struct string_list *next; 34 enum symbol_type tag;
38 enum symbol_type tag; 35 char *string;
39 char *string;
40}; 36};
41 37
42struct symbol 38struct symbol {
43{ 39 struct symbol *hash_next;
44 struct symbol *hash_next; 40 const char *name;
45 const char *name; 41 enum symbol_type type;
46 enum symbol_type type; 42 struct string_list *defn;
47 struct string_list *defn; 43 struct symbol *expansion_trail;
48 struct symbol *expansion_trail; 44 int is_extern;
49 int is_extern;
50}; 45};
51 46
52typedef struct string_list **yystype; 47typedef struct string_list **yystype;
53#define YYSTYPE yystype 48#define YYSTYPE yystype
54 49
55extern FILE *outfile, *debugfile;
56
57extern int cur_line; 50extern int cur_line;
58extern char *cur_filename, *output_directory; 51extern char *cur_filename;
59
60extern int flag_debug, flag_dump_defs, flag_warnings;
61extern int checksum_version, kernel_version;
62
63extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
64extern struct string_list *current_list, *next_list;
65
66 52
67struct symbol *find_symbol(const char *name, enum symbol_type ns); 53struct symbol *find_symbol(const char *name, enum symbol_type ns);
68struct symbol *add_symbol(const char *name, enum symbol_type type, 54struct symbol *add_symbol(const char *name, enum symbol_type type,
69 struct string_list *defn, int is_extern); 55 struct string_list *defn, int is_extern);
70void export_symbol(const char *); 56void export_symbol(const char *);
71 57
72struct string_list *reset_list(void);
73void free_list(struct string_list *s, struct string_list *e);
74void free_node(struct string_list *list); 58void free_node(struct string_list *list);
59void free_list(struct string_list *s, struct string_list *e);
75struct string_list *copy_node(struct string_list *); 60struct string_list *copy_node(struct string_list *);
76struct string_list *copy_list(struct string_list *s, struct string_list *e);
77int equal_list(struct string_list *a, struct string_list *b);
78void print_list(FILE *, struct string_list *list);
79 61
80int yylex(void); 62int yylex(void);
81int yyparse(void); 63int yyparse(void);
82 64
83void error_with_pos(const char *, ...); 65void error_with_pos(const char *, ...);
84 66
85#define version(a,b,c) ((a << 16) | (b << 8) | (c))
86
87/*----------------------------------------------------------------------*/ 67/*----------------------------------------------------------------------*/
88
89#define MODUTILS_VERSION "<in-kernel>"
90
91#define xmalloc(size) ({ void *__ptr = malloc(size); \ 68#define xmalloc(size) ({ void *__ptr = malloc(size); \
92 if(!__ptr && size != 0) { \ 69 if(!__ptr && size != 0) { \
93 fprintf(stderr, "out of memory\n"); \ 70 fprintf(stderr, "out of memory\n"); \
@@ -101,4 +78,4 @@ void error_with_pos(const char *, ...);
101 } \ 78 } \
102 __str; }) 79 __str; })
103 80
104#endif /* genksyms.h */ 81#endif /* genksyms.h */
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index d591578bd3b2..22d281c6ec24 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct sym_entry *s)
124 * compressed together */ 124 * compressed together */
125 s->len = strlen(str) + 1; 125 s->len = strlen(str) + 1;
126 s->sym = malloc(s->len + 1); 126 s->sym = malloc(s->len + 1);
127 if (!s->sym) {
128 fprintf(stderr, "kallsyms failure: "
129 "unable to allocate required amount of memory\n");
130 exit(EXIT_FAILURE);
131 }
127 strcpy((char *)s->sym + 1, str); 132 strcpy((char *)s->sym + 1, str);
128 s->sym[0] = stype; 133 s->sym[0] = stype;
129 134
@@ -272,7 +277,12 @@ static void write_src(void)
272 277
273 /* table of offset markers, that give the offset in the compressed stream 278 /* table of offset markers, that give the offset in the compressed stream
274 * every 256 symbols */ 279 * every 256 symbols */
275 markers = (unsigned int *) malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256)); 280 markers = malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256));
281 if (!markers) {
282 fprintf(stderr, "kallsyms failure: "
283 "unable to allocate required memory\n");
284 exit(EXIT_FAILURE);
285 }
276 286
277 output_label("kallsyms_names"); 287 output_label("kallsyms_names");
278 off = 0; 288 off = 0;
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5760e057ecba..e6499db4c8cc 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,7 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config 5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6 6
7xconfig: $(obj)/qconf 7xconfig: $(obj)/qconf
8 $< arch/$(ARCH)/Kconfig 8 $< arch/$(ARCH)/Kconfig
@@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext
42 $(Q)rm -f arch/um/Kconfig_arch 42 $(Q)rm -f arch/um/Kconfig_arch
43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot 43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
44 44
45.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig 45PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
46 46
47randconfig: $(obj)/conf 47randconfig: $(obj)/conf
48 $< -r arch/$(ARCH)/Kconfig 48 $< -r arch/$(ARCH)/Kconfig
@@ -78,7 +78,7 @@ help:
78 @echo ' defconfig - New config with default answer to all options' 78 @echo ' defconfig - New config with default answer to all options'
79 @echo ' allmodconfig - New config selecting modules when possible' 79 @echo ' allmodconfig - New config selecting modules when possible'
80 @echo ' allyesconfig - New config where all options are accepted with yes' 80 @echo ' allyesconfig - New config where all options are accepted with yes'
81 @echo ' allnoconfig - New minimal config' 81 @echo ' allnoconfig - New config where all options are answered with no'
82 82
83# =========================================================================== 83# ===========================================================================
84# Shared Makefile for the various kconfig executables: 84# Shared Makefile for the various kconfig executables:
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b0cbbe2e41bb..1b8882ddbc74 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -374,6 +374,7 @@ int conf_write(const char *name)
374 out_h = fopen(".tmpconfig.h", "w"); 374 out_h = fopen(".tmpconfig.h", "w");
375 if (!out_h) 375 if (!out_h)
376 return 1; 376 return 1;
377 file_write_dep(NULL);
377 } 378 }
378 sym = sym_lookup("KERNELVERSION", 0); 379 sym = sym_lookup("KERNELVERSION", 0);
379 sym_calc_value(sym); 380 sym_calc_value(sym);
@@ -512,7 +513,6 @@ int conf_write(const char *name)
512 if (out_h) { 513 if (out_h) {
513 fclose(out_h); 514 fclose(out_h);
514 rename(".tmpconfig.h", "include/linux/autoconf.h"); 515 rename(".tmpconfig.h", "include/linux/autoconf.h");
515 file_write_dep(NULL);
516 } 516 }
517 if (!name || basename != conf_def_filename) { 517 if (!name || basename != conf_def_filename) {
518 if (!name) 518 if (!name)
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile
index bbf4887cff74..a8b026326247 100644
--- a/scripts/kconfig/lxdialog/Makefile
+++ b/scripts/kconfig/lxdialog/Makefile
@@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
7# we really need to do so. (Do not call gcc as part of make mrproper) 7# we really need to do so. (Do not call gcc as part of make mrproper)
8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) 8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
10
11HOST_EXTRACFLAGS += -DLOCALE
12 10
13.PHONY: dochecklxdialog 11HOST_EXTRACFLAGS += -DLOCALE
12
13PHONY += dochecklxdialog
14$(obj)/dochecklxdialog: 14$(obj)/dochecklxdialog:
15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) 15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
16 16
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index c4d621b30d0d..a22cbedd3b3e 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -21,11 +21,13 @@ KERNELOUTPUT := $2
21 21
22MAKEFLAGS += --no-print-directory 22MAKEFLAGS += --no-print-directory
23 23
24.PHONY: all \$(MAKECMDGOALS)
25
24all: 26all:
25 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) 27 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
26 28
27%:: 29Makefile:;
28 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
29 30
31\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/:
32 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
30EOF 33EOF
31
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index c164b230ad6f..84e21201f3c0 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -34,7 +34,7 @@ typedef uint16_t __u16;
34typedef unsigned char __u8; 34typedef unsigned char __u8;
35 35
36/* Big exception to the "don't include kernel headers into userspace, which 36/* Big exception to the "don't include kernel headers into userspace, which
37 * even potentially has different endianness and word sizes, since 37 * even potentially has different endianness and word sizes, since
38 * we handle those differences explicitly below */ 38 * we handle those differences explicitly below */
39#include "../../include/linux/mod_devicetable.h" 39#include "../../include/linux/mod_devicetable.h"
40#include "../../include/linux/input.h" 40#include "../../include/linux/input.h"
@@ -153,8 +153,8 @@ static void do_usb_table(void *symval, unsigned long size,
153 const unsigned long id_size = sizeof(struct usb_device_id); 153 const unsigned long id_size = sizeof(struct usb_device_id);
154 154
155 if (size % id_size || size < id_size) { 155 if (size % id_size || size < id_size) {
156 fprintf(stderr, "*** Warning: %s ids %lu bad size " 156 warn("%s ids %lu bad size "
157 "(each on %lu)\n", mod->name, size, id_size); 157 "(each on %lu)\n", mod->name, size, id_size);
158 } 158 }
159 /* Leave last one: it's the terminator. */ 159 /* Leave last one: it's the terminator. */
160 size -= id_size; 160 size -= id_size;
@@ -217,9 +217,8 @@ static int do_pci_entry(const char *filename,
217 if ((baseclass_mask != 0 && baseclass_mask != 0xFF) 217 if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
218 || (subclass_mask != 0 && subclass_mask != 0xFF) 218 || (subclass_mask != 0 && subclass_mask != 0xFF)
219 || (interface_mask != 0 && interface_mask != 0xFF)) { 219 || (interface_mask != 0 && interface_mask != 0xFF)) {
220 fprintf(stderr, 220 warn("Can't handle masks in %s:%04X\n",
221 "*** Warning: Can't handle masks in %s:%04X\n", 221 filename, id->class_mask);
222 filename, id->class_mask);
223 return 0; 222 return 0;
224 } 223 }
225 224
@@ -229,7 +228,7 @@ static int do_pci_entry(const char *filename,
229 return 1; 228 return 1;
230} 229}
231 230
232/* looks like: "ccw:tNmNdtNdmN" */ 231/* looks like: "ccw:tNmNdtNdmN" */
233static int do_ccw_entry(const char *filename, 232static int do_ccw_entry(const char *filename,
234 struct ccw_device_id *id, char *alias) 233 struct ccw_device_id *id, char *alias)
235{ 234{
@@ -445,8 +444,8 @@ static void do_table(void *symval, unsigned long size,
445 int (*do_entry)(const char *, void *entry, char *alias) = function; 444 int (*do_entry)(const char *, void *entry, char *alias) = function;
446 445
447 if (size % id_size || size < id_size) { 446 if (size % id_size || size < id_size) {
448 fprintf(stderr, "*** Warning: %s ids %lu bad size " 447 warn("%s ids %lu bad size "
449 "(each on %lu)\n", mod->name, size, id_size); 448 "(each on %lu)\n", mod->name, size, id_size);
450 } 449 }
451 /* Leave last one: it's the terminator. */ 450 /* Leave last one: it's the terminator. */
452 size -= id_size; 451 size -= id_size;
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
index de2aabf89fb3..3c92c83733f4 100644
--- a/scripts/mod/mk_elfconfig.c
+++ b/scripts/mod/mk_elfconfig.c
@@ -6,7 +6,7 @@
6int 6int
7main(int argc, char **argv) 7main(int argc, char **argv)
8{ 8{
9 unsigned char ei[EI_NIDENT]; 9 unsigned char ei[EI_NIDENT];
10 union { short s; char c[2]; } endian_test; 10 union { short s; char c[2]; } endian_test;
11 11
12 if (argc != 2) { 12 if (argc != 2) {
@@ -57,7 +57,7 @@ main(int argc, char **argv)
57 57
58 if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0)) 58 if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
59 printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); 59 printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
60 else 60 else
61 printf("#define MODULE_SYMBOL_PREFIX \"\"\n"); 61 printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
62 62
63 return 0; 63 return 0;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index b8b2a560b26b..0b92ddff26fd 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright 2003 Kai Germaschewski 3 * Copyright 2003 Kai Germaschewski
4 * Copyright 2002-2004 Rusty Russell, IBM Corporation 4 * Copyright 2002-2004 Rusty Russell, IBM Corporation
5 * 5 * Copyright 2006 Sam Ravnborg
6 * Based in part on module-init-tools/depmod.c,file2alias 6 * Based in part on module-init-tools/depmod.c,file2alias
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
@@ -20,9 +20,10 @@ int modversions = 0;
20int have_vmlinux = 0; 20int have_vmlinux = 0;
21/* Is CONFIG_MODULE_SRCVERSION_ALL set? */ 21/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
22static int all_versions = 0; 22static int all_versions = 0;
23/* If we are modposting external module set to 1 */
24static int external_module = 0;
23 25
24void 26void fatal(const char *fmt, ...)
25fatal(const char *fmt, ...)
26{ 27{
27 va_list arglist; 28 va_list arglist;
28 29
@@ -35,8 +36,7 @@ fatal(const char *fmt, ...)
35 exit(1); 36 exit(1);
36} 37}
37 38
38void 39void warn(const char *fmt, ...)
39warn(const char *fmt, ...)
40{ 40{
41 va_list arglist; 41 va_list arglist;
42 42
@@ -47,6 +47,18 @@ warn(const char *fmt, ...)
47 va_end(arglist); 47 va_end(arglist);
48} 48}
49 49
50static int is_vmlinux(const char *modname)
51{
52 const char *myname;
53
54 if ((myname = strrchr(modname, '/')))
55 myname++;
56 else
57 myname = modname;
58
59 return strcmp(myname, "vmlinux") == 0;
60}
61
50void *do_nofail(void *ptr, const char *expr) 62void *do_nofail(void *ptr, const char *expr)
51{ 63{
52 if (!ptr) { 64 if (!ptr) {
@@ -59,8 +71,7 @@ void *do_nofail(void *ptr, const char *expr)
59 71
60static struct module *modules; 72static struct module *modules;
61 73
62struct module * 74static struct module *find_module(char *modname)
63find_module(char *modname)
64{ 75{
65 struct module *mod; 76 struct module *mod;
66 77
@@ -70,12 +81,11 @@ find_module(char *modname)
70 return mod; 81 return mod;
71} 82}
72 83
73struct module * 84static struct module *new_module(char *modname)
74new_module(char *modname)
75{ 85{
76 struct module *mod; 86 struct module *mod;
77 char *p, *s; 87 char *p, *s;
78 88
79 mod = NOFAIL(malloc(sizeof(*mod))); 89 mod = NOFAIL(malloc(sizeof(*mod)));
80 memset(mod, 0, sizeof(*mod)); 90 memset(mod, 0, sizeof(*mod));
81 p = NOFAIL(strdup(modname)); 91 p = NOFAIL(strdup(modname));
@@ -104,6 +114,10 @@ struct symbol {
104 unsigned int crc; 114 unsigned int crc;
105 int crc_valid; 115 int crc_valid;
106 unsigned int weak:1; 116 unsigned int weak:1;
117 unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */
118 unsigned int kernel:1; /* 1 if symbol is from kernel
119 * (only for external modules) **/
120 unsigned int preloaded:1; /* 1 if symbol from Module.symvers */
107 char name[0]; 121 char name[0];
108}; 122};
109 123
@@ -122,11 +136,12 @@ static inline unsigned int tdb_hash(const char *name)
122 return (1103515243 * value + 12345); 136 return (1103515243 * value + 12345);
123} 137}
124 138
125/* Allocate a new symbols for use in the hash of exported symbols or 139/**
126 * the list of unresolved symbols per module */ 140 * Allocate a new symbols for use in the hash of exported symbols or
127 141 * the list of unresolved symbols per module
128struct symbol * 142 **/
129alloc_symbol(const char *name, unsigned int weak, struct symbol *next) 143static struct symbol *alloc_symbol(const char *name, unsigned int weak,
144 struct symbol *next)
130{ 145{
131 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); 146 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
132 147
@@ -138,9 +153,7 @@ alloc_symbol(const char *name, unsigned int weak, struct symbol *next)
138} 153}
139 154
140/* For the hash of exported symbols */ 155/* For the hash of exported symbols */
141 156static struct symbol *new_symbol(const char *name, struct module *module)
142void
143new_symbol(const char *name, struct module *module, unsigned int *crc)
144{ 157{
145 unsigned int hash; 158 unsigned int hash;
146 struct symbol *new; 159 struct symbol *new;
@@ -148,14 +161,10 @@ new_symbol(const char *name, struct module *module, unsigned int *crc)
148 hash = tdb_hash(name) % SYMBOL_HASH_SIZE; 161 hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
149 new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); 162 new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]);
150 new->module = module; 163 new->module = module;
151 if (crc) { 164 return new;
152 new->crc = *crc;
153 new->crc_valid = 1;
154 }
155} 165}
156 166
157struct symbol * 167static struct symbol *find_symbol(const char *name)
158find_symbol(const char *name)
159{ 168{
160 struct symbol *s; 169 struct symbol *s;
161 170
@@ -170,25 +179,42 @@ find_symbol(const char *name)
170 return NULL; 179 return NULL;
171} 180}
172 181
173/* Add an exported symbol - it may have already been added without a 182/**
174 * CRC, in this case just update the CRC */ 183 * Add an exported symbol - it may have already been added without a
175void 184 * CRC, in this case just update the CRC
176add_exported_symbol(const char *name, struct module *module, unsigned int *crc) 185 **/
186static struct symbol *sym_add_exported(const char *name, struct module *mod)
177{ 187{
178 struct symbol *s = find_symbol(name); 188 struct symbol *s = find_symbol(name);
179 189
180 if (!s) { 190 if (!s) {
181 new_symbol(name, module, crc); 191 s = new_symbol(name, mod);
182 return; 192 } else {
183 } 193 if (!s->preloaded) {
184 if (crc) { 194 warn("%s: '%s' exported twice. Previous export "
185 s->crc = *crc; 195 "was in %s%s\n", mod->name, name,
186 s->crc_valid = 1; 196 s->module->name,
197 is_vmlinux(s->module->name) ?"":".ko");
198 }
187 } 199 }
200 s->preloaded = 0;
201 s->vmlinux = is_vmlinux(mod->name);
202 s->kernel = 0;
203 return s;
204}
205
206static void sym_update_crc(const char *name, struct module *mod,
207 unsigned int crc)
208{
209 struct symbol *s = find_symbol(name);
210
211 if (!s)
212 s = new_symbol(name, mod);
213 s->crc = crc;
214 s->crc_valid = 1;
188} 215}
189 216
190void * 217void *grab_file(const char *filename, unsigned long *size)
191grab_file(const char *filename, unsigned long *size)
192{ 218{
193 struct stat st; 219 struct stat st;
194 void *map; 220 void *map;
@@ -207,13 +233,12 @@ grab_file(const char *filename, unsigned long *size)
207 return map; 233 return map;
208} 234}
209 235
210/* 236/**
211 Return a copy of the next line in a mmap'ed file. 237 * Return a copy of the next line in a mmap'ed file.
212 spaces in the beginning of the line is trimmed away. 238 * spaces in the beginning of the line is trimmed away.
213 Return a pointer to a static buffer. 239 * Return a pointer to a static buffer.
214*/ 240 **/
215char* 241char* get_next_line(unsigned long *pos, void *file, unsigned long size)
216get_next_line(unsigned long *pos, void *file, unsigned long size)
217{ 242{
218 static char line[4096]; 243 static char line[4096];
219 int skip = 1; 244 int skip = 1;
@@ -243,14 +268,12 @@ get_next_line(unsigned long *pos, void *file, unsigned long size)
243 return NULL; 268 return NULL;
244} 269}
245 270
246void 271void release_file(void *file, unsigned long size)
247release_file(void *file, unsigned long size)
248{ 272{
249 munmap(file, size); 273 munmap(file, size);
250} 274}
251 275
252void 276static void parse_elf(struct elf_info *info, const char *filename)
253parse_elf(struct elf_info *info, const char *filename)
254{ 277{
255 unsigned int i; 278 unsigned int i;
256 Elf_Ehdr *hdr = info->hdr; 279 Elf_Ehdr *hdr = info->hdr;
@@ -297,14 +320,13 @@ parse_elf(struct elf_info *info, const char *filename)
297 continue; 320 continue;
298 321
299 info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; 322 info->symtab_start = (void *)hdr + sechdrs[i].sh_offset;
300 info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset 323 info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset
301 + sechdrs[i].sh_size; 324 + sechdrs[i].sh_size;
302 info->strtab = (void *)hdr + 325 info->strtab = (void *)hdr +
303 sechdrs[sechdrs[i].sh_link].sh_offset; 326 sechdrs[sechdrs[i].sh_link].sh_offset;
304 } 327 }
305 if (!info->symtab_start) { 328 if (!info->symtab_start) {
306 fprintf(stderr, "modpost: %s no symtab?\n", filename); 329 fatal("%s has no symtab?\n", filename);
307 abort();
308 } 330 }
309 /* Fix endianness in symbols */ 331 /* Fix endianness in symbols */
310 for (sym = info->symtab_start; sym < info->symtab_stop; sym++) { 332 for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
@@ -316,36 +338,31 @@ parse_elf(struct elf_info *info, const char *filename)
316 return; 338 return;
317 339
318 truncated: 340 truncated:
319 fprintf(stderr, "modpost: %s is truncated.\n", filename); 341 fatal("%s is truncated.\n", filename);
320 abort();
321} 342}
322 343
323void 344static void parse_elf_finish(struct elf_info *info)
324parse_elf_finish(struct elf_info *info)
325{ 345{
326 release_file(info->hdr, info->size); 346 release_file(info->hdr, info->size);
327} 347}
328 348
329#define CRC_PFX "__crc_" 349#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_"
330#define KSYMTAB_PFX "__ksymtab_" 350#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
331 351
332void 352static void handle_modversions(struct module *mod, struct elf_info *info,
333handle_modversions(struct module *mod, struct elf_info *info, 353 Elf_Sym *sym, const char *symname)
334 Elf_Sym *sym, const char *symname)
335{ 354{
336 unsigned int crc; 355 unsigned int crc;
337 356
338 switch (sym->st_shndx) { 357 switch (sym->st_shndx) {
339 case SHN_COMMON: 358 case SHN_COMMON:
340 fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n", 359 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
341 symname, mod->name);
342 break; 360 break;
343 case SHN_ABS: 361 case SHN_ABS:
344 /* CRC'd symbol */ 362 /* CRC'd symbol */
345 if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { 363 if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
346 crc = (unsigned int) sym->st_value; 364 crc = (unsigned int) sym->st_value;
347 add_exported_symbol(symname + strlen(CRC_PFX), 365 sym_update_crc(symname + strlen(CRC_PFX), mod, crc);
348 mod, &crc);
349 } 366 }
350 break; 367 break;
351 case SHN_UNDEF: 368 case SHN_UNDEF:
@@ -370,15 +387,15 @@ handle_modversions(struct module *mod, struct elf_info *info,
370 /* Ignore register directives. */ 387 /* Ignore register directives. */
371 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) 388 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
372 break; 389 break;
373 if (symname[0] == '.') { 390 if (symname[0] == '.') {
374 char *munged = strdup(symname); 391 char *munged = strdup(symname);
375 munged[0] = '_'; 392 munged[0] = '_';
376 munged[1] = toupper(munged[1]); 393 munged[1] = toupper(munged[1]);
377 symname = munged; 394 symname = munged;
378 } 395 }
379 } 396 }
380#endif 397#endif
381 398
382 if (memcmp(symname, MODULE_SYMBOL_PREFIX, 399 if (memcmp(symname, MODULE_SYMBOL_PREFIX,
383 strlen(MODULE_SYMBOL_PREFIX)) == 0) 400 strlen(MODULE_SYMBOL_PREFIX)) == 0)
384 mod->unres = alloc_symbol(symname + 401 mod->unres = alloc_symbol(symname +
@@ -389,8 +406,7 @@ handle_modversions(struct module *mod, struct elf_info *info,
389 default: 406 default:
390 /* All exported symbols */ 407 /* All exported symbols */
391 if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { 408 if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
392 add_exported_symbol(symname + strlen(KSYMTAB_PFX), 409 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod);
393 mod, NULL);
394 } 410 }
395 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) 411 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0)
396 mod->has_init = 1; 412 mod->has_init = 1;
@@ -400,20 +416,9 @@ handle_modversions(struct module *mod, struct elf_info *info,
400 } 416 }
401} 417}
402 418
403int 419/**
404is_vmlinux(const char *modname) 420 * Parse tag=value strings from .modinfo section
405{ 421 **/
406 const char *myname;
407
408 if ((myname = strrchr(modname, '/')))
409 myname++;
410 else
411 myname = modname;
412
413 return strcmp(myname, "vmlinux") == 0;
414}
415
416/* Parse tag=value strings from .modinfo section */
417static char *next_string(char *string, unsigned long *secsize) 422static char *next_string(char *string, unsigned long *secsize)
418{ 423{
419 /* Skip non-zero chars */ 424 /* Skip non-zero chars */
@@ -446,8 +451,418 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
446 return NULL; 451 return NULL;
447} 452}
448 453
449void 454/**
450read_symbols(char *modname) 455 * Test if string s ends in string sub
456 * return 0 if match
457 **/
458static int strrcmp(const char *s, const char *sub)
459{
460 int slen, sublen;
461
462 if (!s || !sub)
463 return 1;
464
465 slen = strlen(s);
466 sublen = strlen(sub);
467
468 if ((slen == 0) || (sublen == 0))
469 return 1;
470
471 if (sublen > slen)
472 return 1;
473
474 return memcmp(s + slen - sublen, sub, sublen);
475}
476
477/**
478 * Whitelist to allow certain references to pass with no warning.
479 * Pattern 1:
480 * If a module parameter is declared __initdata and permissions=0
481 * then this is legal despite the warning generated.
482 * We cannot see value of permissions here, so just ignore
483 * this pattern.
484 * The pattern is identified by:
485 * tosec = .init.data
486 * fromsec = .data*
487 * atsym =__param*
488 *
489 * Pattern 2:
490 * Many drivers utilise a *_driver container with references to
491 * add, remove, probe functions etc.
492 * These functions may often be marked __init and we do not want to
493 * warn here.
494 * the pattern is identified by:
495 * tosec = .init.text | .exit.text
496 * fromsec = .data
497 * atsym = *_driver, *_ops, *_probe, *probe_one
498 **/
499static int secref_whitelist(const char *tosec, const char *fromsec,
500 const char *atsym)
501{
502 int f1 = 1, f2 = 1;
503 const char **s;
504 const char *pat2sym[] = {
505 "_driver",
506 "_ops",
507 "_probe",
508 "_probe_one",
509 NULL
510 };
511
512 /* Check for pattern 1 */
513 if (strcmp(tosec, ".init.data") != 0)
514 f1 = 0;
515 if (strncmp(fromsec, ".data", strlen(".data")) != 0)
516 f1 = 0;
517 if (strncmp(atsym, "__param", strlen("__param")) != 0)
518 f1 = 0;
519
520 if (f1)
521 return f1;
522
523 /* Check for pattern 2 */
524 if ((strcmp(tosec, ".init.text") != 0) &&
525 (strcmp(tosec, ".exit.text") != 0))
526 f2 = 0;
527 if (strcmp(fromsec, ".data") != 0)
528 f2 = 0;
529
530 for (s = pat2sym; *s; s++)
531 if (strrcmp(atsym, *s) == 0)
532 f1 = 1;
533
534 return f1 && f2;
535}
536
537/**
538 * Find symbol based on relocation record info.
539 * In some cases the symbol supplied is a valid symbol so
540 * return refsym. If st_name != 0 we assume this is a valid symbol.
541 * In other cases the symbol needs to be looked up in the symbol table
542 * based on section and address.
543 * **/
544static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
545 Elf_Sym *relsym)
546{
547 Elf_Sym *sym;
548
549 if (relsym->st_name != 0)
550 return relsym;
551 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
552 if (sym->st_shndx != relsym->st_shndx)
553 continue;
554 if (sym->st_value == addr)
555 return sym;
556 }
557 return NULL;
558}
559
560/*
561 * Find symbols before or equal addr and after addr - in the section sec.
562 * If we find two symbols with equal offset prefer one with a valid name.
563 * The ELF format may have a better way to detect what type of symbol
564 * it is, but this works for now.
565 **/
566static void find_symbols_between(struct elf_info *elf, Elf_Addr addr,
567 const char *sec,
568 Elf_Sym **before, Elf_Sym **after)
569{
570 Elf_Sym *sym;
571 Elf_Ehdr *hdr = elf->hdr;
572 Elf_Addr beforediff = ~0;
573 Elf_Addr afterdiff = ~0;
574 const char *secstrings = (void *)hdr +
575 elf->sechdrs[hdr->e_shstrndx].sh_offset;
576
577 *before = NULL;
578 *after = NULL;
579
580 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
581 const char *symsec;
582
583 if (sym->st_shndx >= SHN_LORESERVE)
584 continue;
585 symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name;
586 if (strcmp(symsec, sec) != 0)
587 continue;
588 if (sym->st_value <= addr) {
589 if ((addr - sym->st_value) < beforediff) {
590 beforediff = addr - sym->st_value;
591 *before = sym;
592 }
593 else if ((addr - sym->st_value) == beforediff) {
594 /* equal offset, valid name? */
595 const char *name = elf->strtab + sym->st_name;
596 if (name && strlen(name))
597 *before = sym;
598 }
599 }
600 else
601 {
602 if ((sym->st_value - addr) < afterdiff) {
603 afterdiff = sym->st_value - addr;
604 *after = sym;
605 }
606 else if ((sym->st_value - addr) == afterdiff) {
607 /* equal offset, valid name? */
608 const char *name = elf->strtab + sym->st_name;
609 if (name && strlen(name))
610 *after = sym;
611 }
612 }
613 }
614}
615
616/**
617 * Print a warning about a section mismatch.
618 * Try to find symbols near it so user can find it.
619 * Check whitelist before warning - it may be a false positive.
620 **/
621static void warn_sec_mismatch(const char *modname, const char *fromsec,
622 struct elf_info *elf, Elf_Sym *sym, Elf_Rela r)
623{
624 const char *refsymname = "";
625 Elf_Sym *before, *after;
626 Elf_Sym *refsym;
627 Elf_Ehdr *hdr = elf->hdr;
628 Elf_Shdr *sechdrs = elf->sechdrs;
629 const char *secstrings = (void *)hdr +
630 sechdrs[hdr->e_shstrndx].sh_offset;
631 const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name;
632
633 find_symbols_between(elf, r.r_offset, fromsec, &before, &after);
634
635 refsym = find_elf_symbol(elf, r.r_addend, sym);
636 if (refsym && strlen(elf->strtab + refsym->st_name))
637 refsymname = elf->strtab + refsym->st_name;
638
639 /* check whitelist - we may ignore it */
640 if (before &&
641 secref_whitelist(secname, fromsec, elf->strtab + before->st_name))
642 return;
643
644 if (before && after) {
645 warn("%s - Section mismatch: reference to %s:%s from %s "
646 "between '%s' (at offset 0x%llx) and '%s'\n",
647 modname, secname, refsymname, fromsec,
648 elf->strtab + before->st_name,
649 (long long)r.r_offset,
650 elf->strtab + after->st_name);
651 } else if (before) {
652 warn("%s - Section mismatch: reference to %s:%s from %s "
653 "after '%s' (at offset 0x%llx)\n",
654 modname, secname, refsymname, fromsec,
655 elf->strtab + before->st_name,
656 (long long)r.r_offset);
657 } else if (after) {
658 warn("%s - Section mismatch: reference to %s:%s from %s "
659 "before '%s' (at offset -0x%llx)\n",
660 modname, secname, refsymname, fromsec,
661 elf->strtab + before->st_name,
662 (long long)r.r_offset);
663 } else {
664 warn("%s - Section mismatch: reference to %s:%s from %s "
665 "(offset 0x%llx)\n",
666 modname, secname, fromsec, refsymname,
667 (long long)r.r_offset);
668 }
669}
670
671/**
672 * A module includes a number of sections that are discarded
673 * either when loaded or when used as built-in.
674 * For loaded modules all functions marked __init and all data
675 * marked __initdata will be discarded when the module has been intialized.
676 * Likewise for modules used built-in the sections marked __exit
677 * are discarded because __exit marked function are supposed to be called
678 * only when a moduel is unloaded which never happes for built-in modules.
679 * The check_sec_ref() function traverses all relocation records
680 * to find all references to a section that reference a section that will
681 * be discarded and warns about it.
682 **/
683static void check_sec_ref(struct module *mod, const char *modname,
684 struct elf_info *elf,
685 int section(const char*),
686 int section_ref_ok(const char *))
687{
688 int i;
689 Elf_Sym *sym;
690 Elf_Ehdr *hdr = elf->hdr;
691 Elf_Shdr *sechdrs = elf->sechdrs;
692 const char *secstrings = (void *)hdr +
693 sechdrs[hdr->e_shstrndx].sh_offset;
694
695 /* Walk through all sections */
696 for (i = 0; i < hdr->e_shnum; i++) {
697 Elf_Rela *rela;
698 Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
699 Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
700 const char *name = secstrings + sechdrs[i].sh_name +
701 strlen(".rela");
702 /* We want to process only relocation sections and not .init */
703 if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA))
704 continue;
705
706 for (rela = start; rela < stop; rela++) {
707 Elf_Rela r;
708 const char *secname;
709 r.r_offset = TO_NATIVE(rela->r_offset);
710 r.r_info = TO_NATIVE(rela->r_info);
711 r.r_addend = TO_NATIVE(rela->r_addend);
712 sym = elf->symtab_start + ELF_R_SYM(r.r_info);
713 /* Skip special sections */
714 if (sym->st_shndx >= SHN_LORESERVE)
715 continue;
716
717 secname = secstrings + sechdrs[sym->st_shndx].sh_name;
718 if (section(secname))
719 warn_sec_mismatch(modname, name, elf, sym, r);
720 }
721 }
722}
723
724/**
725 * Functions used only during module init is marked __init and is stored in
726 * a .init.text section. Likewise data is marked __initdata and stored in
727 * a .init.data section.
728 * If this section is one of these sections return 1
729 * See include/linux/init.h for the details
730 **/
731static int init_section(const char *name)
732{
733 if (strcmp(name, ".init") == 0)
734 return 1;
735 if (strncmp(name, ".init.", strlen(".init.")) == 0)
736 return 1;
737 return 0;
738}
739
740/**
741 * Identify sections from which references to a .init section is OK.
742 *
743 * Unfortunately references to read only data that referenced .init
744 * sections had to be excluded. Almost all of these are false
745 * positives, they are created by gcc. The downside of excluding rodata
746 * is that there really are some user references from rodata to
747 * init code, e.g. drivers/video/vgacon.c:
748 *
749 * const struct consw vga_con = {
750 * con_startup: vgacon_startup,
751 *
752 * where vgacon_startup is __init. If you want to wade through the false
753 * positives, take out the check for rodata.
754 **/
755static int init_section_ref_ok(const char *name)
756{
757 const char **s;
758 /* Absolute section names */
759 const char *namelist1[] = {
760 ".init",
761 ".opd", /* see comment [OPD] at exit_section_ref_ok() */
762 ".toc1", /* used by ppc64 */
763 ".stab",
764 ".rodata",
765 ".text.lock",
766 "__bug_table", /* used by powerpc for BUG() */
767 ".pci_fixup_header",
768 ".pci_fixup_final",
769 ".pdr",
770 "__param",
771 NULL
772 };
773 /* Start of section names */
774 const char *namelist2[] = {
775 ".init.",
776 ".altinstructions",
777 ".eh_frame",
778 ".debug",
779 NULL
780 };
781 /* part of section name */
782 const char *namelist3 [] = {
783 ".unwind", /* sample: IA_64.unwind.init.text */
784 NULL
785 };
786
787 for (s = namelist1; *s; s++)
788 if (strcmp(*s, name) == 0)
789 return 1;
790 for (s = namelist2; *s; s++)
791 if (strncmp(*s, name, strlen(*s)) == 0)
792 return 1;
793 for (s = namelist3; *s; s++)
794 if (strstr(name, *s) != NULL)
795 return 1;
796 return 0;
797}
798
799/*
800 * Functions used only during module exit is marked __exit and is stored in
801 * a .exit.text section. Likewise data is marked __exitdata and stored in
802 * a .exit.data section.
803 * If this section is one of these sections return 1
804 * See include/linux/init.h for the details
805 **/
806static int exit_section(const char *name)
807{
808 if (strcmp(name, ".exit.text") == 0)
809 return 1;
810 if (strcmp(name, ".exit.data") == 0)
811 return 1;
812 return 0;
813
814}
815
816/*
817 * Identify sections from which references to a .exit section is OK.
818 *
819 * [OPD] Keith Ownes <kaos@sgi.com> commented:
820 * For our future {in}sanity, add a comment that this is the ppc .opd
821 * section, not the ia64 .opd section.
822 * ia64 .opd should not point to discarded sections.
823 **/
824static int exit_section_ref_ok(const char *name)
825{
826 const char **s;
827 /* Absolute section names */
828 const char *namelist1[] = {
829 ".exit.text",
830 ".exit.data",
831 ".init.text",
832 ".opd", /* See comment [OPD] */
833 ".toc1", /* used by ppc64 */
834 ".altinstructions",
835 ".pdr",
836 "__bug_table", /* used by powerpc for BUG() */
837 ".exitcall.exit",
838 ".eh_frame",
839 ".stab",
840 NULL
841 };
842 /* Start of section names */
843 const char *namelist2[] = {
844 ".debug",
845 NULL
846 };
847 /* part of section name */
848 const char *namelist3 [] = {
849 ".unwind", /* Sample: IA_64.unwind.exit.text */
850 NULL
851 };
852
853 for (s = namelist1; *s; s++)
854 if (strcmp(*s, name) == 0)
855 return 1;
856 for (s = namelist2; *s; s++)
857 if (strncmp(*s, name, strlen(*s)) == 0)
858 return 1;
859 for (s = namelist3; *s; s++)
860 if (strstr(name, *s) != NULL)
861 return 1;
862 return 0;
863}
864
865static void read_symbols(char *modname)
451{ 866{
452 const char *symname; 867 const char *symname;
453 char *version; 868 char *version;
@@ -462,9 +877,7 @@ read_symbols(char *modname)
462 /* When there's no vmlinux, don't print warnings about 877 /* When there's no vmlinux, don't print warnings about
463 * unresolved symbols (since there'll be too many ;) */ 878 * unresolved symbols (since there'll be too many ;) */
464 if (is_vmlinux(modname)) { 879 if (is_vmlinux(modname)) {
465 unsigned int fake_crc = 0;
466 have_vmlinux = 1; 880 have_vmlinux = 1;
467 add_exported_symbol("struct_module", mod, &fake_crc);
468 mod->skip = 1; 881 mod->skip = 1;
469 } 882 }
470 883
@@ -474,6 +887,8 @@ read_symbols(char *modname)
474 handle_modversions(mod, &info, sym, symname); 887 handle_modversions(mod, &info, sym, symname);
475 handle_moddevtable(mod, &info, sym, symname); 888 handle_moddevtable(mod, &info, sym, symname);
476 } 889 }
890 check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
891 check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);
477 892
478 version = get_modinfo(info.modinfo, info.modinfo_len, "version"); 893 version = get_modinfo(info.modinfo, info.modinfo_len, "version");
479 if (version) 894 if (version)
@@ -499,21 +914,20 @@ read_symbols(char *modname)
499 * following helper, then compare to the file on disk and 914 * following helper, then compare to the file on disk and
500 * only update the later if anything changed */ 915 * only update the later if anything changed */
501 916
502void __attribute__((format(printf, 2, 3))) 917void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
503buf_printf(struct buffer *buf, const char *fmt, ...) 918 const char *fmt, ...)
504{ 919{
505 char tmp[SZ]; 920 char tmp[SZ];
506 int len; 921 int len;
507 va_list ap; 922 va_list ap;
508 923
509 va_start(ap, fmt); 924 va_start(ap, fmt);
510 len = vsnprintf(tmp, SZ, fmt, ap); 925 len = vsnprintf(tmp, SZ, fmt, ap);
511 buf_write(buf, tmp, len); 926 buf_write(buf, tmp, len);
512 va_end(ap); 927 va_end(ap);
513} 928}
514 929
515void 930void buf_write(struct buffer *buf, const char *s, int len)
516buf_write(struct buffer *buf, const char *s, int len)
517{ 931{
518 if (buf->size - buf->pos < len) { 932 if (buf->size - buf->pos < len) {
519 buf->size += len + SZ; 933 buf->size += len + SZ;
@@ -523,10 +937,10 @@ buf_write(struct buffer *buf, const char *s, int len)
523 buf->pos += len; 937 buf->pos += len;
524} 938}
525 939
526/* Header for the generated file */ 940/**
527 941 * Header for the generated file
528void 942 **/
529add_header(struct buffer *b, struct module *mod) 943static void add_header(struct buffer *b, struct module *mod)
530{ 944{
531 buf_printf(b, "#include <linux/module.h>\n"); 945 buf_printf(b, "#include <linux/module.h>\n");
532 buf_printf(b, "#include <linux/vermagic.h>\n"); 946 buf_printf(b, "#include <linux/vermagic.h>\n");
@@ -546,10 +960,10 @@ add_header(struct buffer *b, struct module *mod)
546 buf_printf(b, "};\n"); 960 buf_printf(b, "};\n");
547} 961}
548 962
549/* Record CRCs for unresolved symbols */ 963/**
550 964 * Record CRCs for unresolved symbols
551void 965 **/
552add_versions(struct buffer *b, struct module *mod) 966static void add_versions(struct buffer *b, struct module *mod)
553{ 967{
554 struct symbol *s, *exp; 968 struct symbol *s, *exp;
555 969
@@ -557,8 +971,8 @@ add_versions(struct buffer *b, struct module *mod)
557 exp = find_symbol(s->name); 971 exp = find_symbol(s->name);
558 if (!exp || exp->module == mod) { 972 if (!exp || exp->module == mod) {
559 if (have_vmlinux && !s->weak) 973 if (have_vmlinux && !s->weak)
560 fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " 974 warn("\"%s\" [%s.ko] undefined!\n",
561 "undefined!\n", s->name, mod->name); 975 s->name, mod->name);
562 continue; 976 continue;
563 } 977 }
564 s->module = exp->module; 978 s->module = exp->module;
@@ -579,8 +993,7 @@ add_versions(struct buffer *b, struct module *mod)
579 continue; 993 continue;
580 } 994 }
581 if (!s->crc_valid) { 995 if (!s->crc_valid) {
582 fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " 996 warn("\"%s\" [%s.ko] has no CRC!\n",
583 "has no CRC!\n",
584 s->name, mod->name); 997 s->name, mod->name);
585 continue; 998 continue;
586 } 999 }
@@ -590,8 +1003,8 @@ add_versions(struct buffer *b, struct module *mod)
590 buf_printf(b, "};\n"); 1003 buf_printf(b, "};\n");
591} 1004}
592 1005
593void 1006static void add_depends(struct buffer *b, struct module *mod,
594add_depends(struct buffer *b, struct module *mod, struct module *modules) 1007 struct module *modules)
595{ 1008{
596 struct symbol *s; 1009 struct symbol *s;
597 struct module *m; 1010 struct module *m;
@@ -621,8 +1034,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules)
621 buf_printf(b, "\";\n"); 1034 buf_printf(b, "\";\n");
622} 1035}
623 1036
624void 1037static void add_srcversion(struct buffer *b, struct module *mod)
625add_srcversion(struct buffer *b, struct module *mod)
626{ 1038{
627 if (mod->srcversion[0]) { 1039 if (mod->srcversion[0]) {
628 buf_printf(b, "\n"); 1040 buf_printf(b, "\n");
@@ -631,8 +1043,7 @@ add_srcversion(struct buffer *b, struct module *mod)
631 } 1043 }
632} 1044}
633 1045
634void 1046static void write_if_changed(struct buffer *b, const char *fname)
635write_if_changed(struct buffer *b, const char *fname)
636{ 1047{
637 char *tmp; 1048 char *tmp;
638 FILE *file; 1049 FILE *file;
@@ -676,8 +1087,7 @@ write_if_changed(struct buffer *b, const char *fname)
676 fclose(file); 1087 fclose(file);
677} 1088}
678 1089
679void 1090static void read_dump(const char *fname, unsigned int kernel)
680read_dump(const char *fname)
681{ 1091{
682 unsigned long size, pos = 0; 1092 unsigned long size, pos = 0;
683 void *file = grab_file(fname, &size); 1093 void *file = grab_file(fname, &size);
@@ -691,6 +1101,7 @@ read_dump(const char *fname)
691 char *symname, *modname, *d; 1101 char *symname, *modname, *d;
692 unsigned int crc; 1102 unsigned int crc;
693 struct module *mod; 1103 struct module *mod;
1104 struct symbol *s;
694 1105
695 if (!(symname = strchr(line, '\t'))) 1106 if (!(symname = strchr(line, '\t')))
696 goto fail; 1107 goto fail;
@@ -711,15 +1122,30 @@ read_dump(const char *fname)
711 mod = new_module(NOFAIL(strdup(modname))); 1122 mod = new_module(NOFAIL(strdup(modname)));
712 mod->skip = 1; 1123 mod->skip = 1;
713 } 1124 }
714 add_exported_symbol(symname, mod, &crc); 1125 s = sym_add_exported(symname, mod);
1126 s->kernel = kernel;
1127 s->preloaded = 1;
1128 sym_update_crc(symname, mod, crc);
715 } 1129 }
716 return; 1130 return;
717fail: 1131fail:
718 fatal("parse error in symbol dump file\n"); 1132 fatal("parse error in symbol dump file\n");
719} 1133}
720 1134
721void 1135/* For normal builds always dump all symbols.
722write_dump(const char *fname) 1136 * For external modules only dump symbols
1137 * that are not read from kernel Module.symvers.
1138 **/
1139static int dump_sym(struct symbol *sym)
1140{
1141 if (!external_module)
1142 return 1;
1143 if (sym->vmlinux || sym->kernel)
1144 return 0;
1145 return 1;
1146}
1147
1148static void write_dump(const char *fname)
723{ 1149{
724 struct buffer buf = { }; 1150 struct buffer buf = { };
725 struct symbol *symbol; 1151 struct symbol *symbol;
@@ -728,34 +1154,33 @@ write_dump(const char *fname)
728 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { 1154 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
729 symbol = symbolhash[n]; 1155 symbol = symbolhash[n];
730 while (symbol) { 1156 while (symbol) {
731 symbol = symbol->next; 1157 if (dump_sym(symbol))
732 } 1158 buf_printf(&buf, "0x%08x\t%s\t%s\n",
733 } 1159 symbol->crc, symbol->name,
734 1160 symbol->module->name);
735 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
736 symbol = symbolhash[n];
737 while (symbol) {
738 buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc,
739 symbol->name, symbol->module->name);
740 symbol = symbol->next; 1161 symbol = symbol->next;
741 } 1162 }
742 } 1163 }
743 write_if_changed(&buf, fname); 1164 write_if_changed(&buf, fname);
744} 1165}
745 1166
746int 1167int main(int argc, char **argv)
747main(int argc, char **argv)
748{ 1168{
749 struct module *mod; 1169 struct module *mod;
750 struct buffer buf = { }; 1170 struct buffer buf = { };
751 char fname[SZ]; 1171 char fname[SZ];
752 char *dump_read = NULL, *dump_write = NULL; 1172 char *kernel_read = NULL, *module_read = NULL;
1173 char *dump_write = NULL;
753 int opt; 1174 int opt;
754 1175
755 while ((opt = getopt(argc, argv, "i:mo:a")) != -1) { 1176 while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) {
756 switch(opt) { 1177 switch(opt) {
757 case 'i': 1178 case 'i':
758 dump_read = optarg; 1179 kernel_read = optarg;
1180 break;
1181 case 'I':
1182 module_read = optarg;
1183 external_module = 1;
759 break; 1184 break;
760 case 'm': 1185 case 'm':
761 modversions = 1; 1186 modversions = 1;
@@ -771,8 +1196,10 @@ main(int argc, char **argv)
771 } 1196 }
772 } 1197 }
773 1198
774 if (dump_read) 1199 if (kernel_read)
775 read_dump(dump_read); 1200 read_dump(kernel_read, 1);
1201 if (module_read)
1202 read_dump(module_read, 0);
776 1203
777 while (optind < argc) { 1204 while (optind < argc) {
778 read_symbols(argv[optind++]); 1205 read_symbols(argv[optind++]);
@@ -799,4 +1226,3 @@ main(int argc, char **argv)
799 1226
800 return 0; 1227 return 0;
801} 1228}
802
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 7334d839145d..b14255c72a37 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -13,20 +13,30 @@
13 13
14#if KERNEL_ELFCLASS == ELFCLASS32 14#if KERNEL_ELFCLASS == ELFCLASS32
15 15
16#define Elf_Ehdr Elf32_Ehdr 16#define Elf_Ehdr Elf32_Ehdr
17#define Elf_Shdr Elf32_Shdr 17#define Elf_Shdr Elf32_Shdr
18#define Elf_Sym Elf32_Sym 18#define Elf_Sym Elf32_Sym
19#define Elf_Addr Elf32_Addr
20#define Elf_Section Elf32_Section
19#define ELF_ST_BIND ELF32_ST_BIND 21#define ELF_ST_BIND ELF32_ST_BIND
20#define ELF_ST_TYPE ELF32_ST_TYPE 22#define ELF_ST_TYPE ELF32_ST_TYPE
21 23
24#define Elf_Rela Elf32_Rela
25#define ELF_R_SYM ELF32_R_SYM
26#define ELF_R_TYPE ELF32_R_TYPE
22#else 27#else
23 28
24#define Elf_Ehdr Elf64_Ehdr 29#define Elf_Ehdr Elf64_Ehdr
25#define Elf_Shdr Elf64_Shdr 30#define Elf_Shdr Elf64_Shdr
26#define Elf_Sym Elf64_Sym 31#define Elf_Sym Elf64_Sym
32#define Elf_Addr Elf64_Addr
33#define Elf_Section Elf64_Section
27#define ELF_ST_BIND ELF64_ST_BIND 34#define ELF_ST_BIND ELF64_ST_BIND
28#define ELF_ST_TYPE ELF64_ST_TYPE 35#define ELF_ST_TYPE ELF64_ST_TYPE
29 36
37#define Elf_Rela Elf64_Rela
38#define ELF_R_SYM ELF64_R_SYM
39#define ELF_R_TYPE ELF64_R_TYPE
30#endif 40#endif
31 41
32#if KERNEL_ELFDATA != HOST_ELFDATA 42#if KERNEL_ELFDATA != HOST_ELFDATA
@@ -91,17 +101,22 @@ struct elf_info {
91 unsigned int modinfo_len; 101 unsigned int modinfo_len;
92}; 102};
93 103
104/* file2alias.c */
94void handle_moddevtable(struct module *mod, struct elf_info *info, 105void handle_moddevtable(struct module *mod, struct elf_info *info,
95 Elf_Sym *sym, const char *symname); 106 Elf_Sym *sym, const char *symname);
96
97void add_moddevtable(struct buffer *buf, struct module *mod); 107void add_moddevtable(struct buffer *buf, struct module *mod);
98 108
109/* sumversion.c */
99void maybe_frob_rcs_version(const char *modfilename, 110void maybe_frob_rcs_version(const char *modfilename,
100 char *version, 111 char *version,
101 void *modinfo, 112 void *modinfo,
102 unsigned long modinfo_offset); 113 unsigned long modinfo_offset);
103void get_src_version(const char *modname, char sum[], unsigned sumlen); 114void get_src_version(const char *modname, char sum[], unsigned sumlen);
104 115
116/* from modpost.c */
105void *grab_file(const char *filename, unsigned long *size); 117void *grab_file(const char *filename, unsigned long *size);
106char* get_next_line(unsigned long *pos, void *file, unsigned long size); 118char* get_next_line(unsigned long *pos, void *file, unsigned long size);
107void release_file(void *file, unsigned long size); 119void release_file(void *file, unsigned long size);
120
121void fatal(const char *fmt, ...);
122void warn(const char *fmt, ...);
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 43271a1ca01e..8a2875689e4d 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)
316 316
317 file = grab_file(cmd, &flen); 317 file = grab_file(cmd, &flen);
318 if (!file) { 318 if (!file) {
319 fprintf(stderr, "Warning: could not find %s for %s\n", 319 warn("could not find %s for %s\n", cmd, objfile);
320 cmd, objfile);
321 goto out; 320 goto out;
322 } 321 }
323 322
@@ -355,9 +354,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
355 /* Check if this file is in same dir as objfile */ 354 /* Check if this file is in same dir as objfile */
356 if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) { 355 if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
357 if (!parse_file(line, md)) { 356 if (!parse_file(line, md)) {
358 fprintf(stderr, 357 warn("could not open %s: %s\n",
359 "Warning: could not open %s: %s\n", 358 line, strerror(errno));
360 line, strerror(errno));
361 goto out_file; 359 goto out_file;
362 } 360 }
363 361
@@ -383,8 +381,11 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
383 struct md4_ctx md; 381 struct md4_ctx md;
384 char *sources, *end, *fname; 382 char *sources, *end, *fname;
385 const char *basename; 383 const char *basename;
386 char filelist[strlen(getenv("MODVERDIR")) + strlen("/") + 384 char filelist[PATH_MAX + 1];
387 strlen(modname) - strlen(".o") + strlen(".mod") + 1 ]; 385 char *modverdir = getenv("MODVERDIR");
386
387 if (!modverdir)
388 modverdir = ".";
388 389
389 /* Source files for module are in .tmp_versions/modname.mod, 390 /* Source files for module are in .tmp_versions/modname.mod,
390 after the first line. */ 391 after the first line. */
@@ -392,28 +393,25 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
392 basename = strrchr(modname, '/') + 1; 393 basename = strrchr(modname, '/') + 1;
393 else 394 else
394 basename = modname; 395 basename = modname;
395 sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"), 396 sprintf(filelist, "%s/%.*s.mod", modverdir,
396 (int) strlen(basename) - 2, basename); 397 (int) strlen(basename) - 2, basename);
397 398
398 file = grab_file(filelist, &len); 399 file = grab_file(filelist, &len);
399 if (!file) { 400 if (!file) {
400 fprintf(stderr, "Warning: could not find versions for %s\n", 401 warn("could not find versions for %s\n", filelist);
401 filelist);
402 return; 402 return;
403 } 403 }
404 404
405 sources = strchr(file, '\n'); 405 sources = strchr(file, '\n');
406 if (!sources) { 406 if (!sources) {
407 fprintf(stderr, "Warning: malformed versions file for %s\n", 407 warn("malformed versions file for %s\n", modname);
408 modname);
409 goto release; 408 goto release;
410 } 409 }
411 410
412 sources++; 411 sources++;
413 end = strchr(sources, '\n'); 412 end = strchr(sources, '\n');
414 if (!end) { 413 if (!end) {
415 fprintf(stderr, "Warning: bad ending versions file for %s\n", 414 warn("bad ending versions file for %s\n", modname);
416 modname);
417 goto release; 415 goto release;
418 } 416 }
419 *end = '\0'; 417 *end = '\0';
@@ -438,19 +436,19 @@ static void write_version(const char *filename, const char *sum,
438 436
439 fd = open(filename, O_RDWR); 437 fd = open(filename, O_RDWR);
440 if (fd < 0) { 438 if (fd < 0) {
441 fprintf(stderr, "Warning: changing sum in %s failed: %s\n", 439 warn("changing sum in %s failed: %s\n",
442 filename, strerror(errno)); 440 filename, strerror(errno));
443 return; 441 return;
444 } 442 }
445 443
446 if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { 444 if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
447 fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n", 445 warn("changing sum in %s:%lu failed: %s\n",
448 filename, offset, strerror(errno)); 446 filename, offset, strerror(errno));
449 goto out; 447 goto out;
450 } 448 }
451 449
452 if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { 450 if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
453 fprintf(stderr, "Warning: writing sum in %s failed: %s\n", 451 warn("writing sum in %s failed: %s\n",
454 filename, strerror(errno)); 452 filename, strerror(errno));
455 goto out; 453 goto out;
456 } 454 }
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index 88e30e82f1ca..f34373853ef8 100644
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
@@ -66,8 +66,8 @@ require 5; # at least perl 5
66use strict; 66use strict;
67use File::Find; 67use File::Find;
68 68
69my $nm = "/usr/bin/nm -p"; 69my $nm = ($ENV{'NM'} || "nm") . " -p";
70my $objdump = "/usr/bin/objdump -s -j .comment"; 70my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment";
71my $srctree = ""; 71my $srctree = "";
72my $objtree = ""; 72my $objtree = "";
73$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); 73$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'}));
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index c201ef001f09..7c434e037e7f 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -32,12 +32,11 @@ MKSPEC := $(srctree)/scripts/package/mkspec
32PREV := set -e; cd ..; 32PREV := set -e; cd ..;
33 33
34# rpm-pkg 34# rpm-pkg
35.PHONY: rpm-pkg rpm 35# ---------------------------------------------------------------------------
36
37$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile 36$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
38 $(CONFIG_SHELL) $(MKSPEC) > $@ 37 $(CONFIG_SHELL) $(MKSPEC) > $@
39 38
40rpm-pkg rpm: $(objtree)/kernel.spec 39rpm-pkg rpm: $(objtree)/kernel.spec FORCE
41 $(MAKE) clean 40 $(MAKE) clean
42 $(PREV) ln -sf $(srctree) $(KERNELPATH) 41 $(PREV) ln -sf $(srctree) $(KERNELPATH)
43 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. 42 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
@@ -54,11 +53,11 @@ rpm-pkg rpm: $(objtree)/kernel.spec
54clean-files := $(objtree)/kernel.spec 53clean-files := $(objtree)/kernel.spec
55 54
56# binrpm-pkg 55# binrpm-pkg
57.PHONY: binrpm-pkg 56# ---------------------------------------------------------------------------
58$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile 57$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
59 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ 58 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
60 59
61binrpm-pkg: $(objtree)/binkernel.spec 60binrpm-pkg: $(objtree)/binkernel.spec FORCE
62 $(MAKE) KBUILD_SRC= 61 $(MAKE) KBUILD_SRC=
63 set -e; \ 62 set -e; \
64 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version 63 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
@@ -71,9 +70,7 @@ clean-files += $(objtree)/binkernel.spec
71 70
72# Deb target 71# Deb target
73# --------------------------------------------------------------------------- 72# ---------------------------------------------------------------------------
74# 73deb-pkg: FORCE
75.PHONY: deb-pkg
76deb-pkg:
77 $(MAKE) KBUILD_SRC= 74 $(MAKE) KBUILD_SRC=
78 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 75 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
79 76
@@ -82,8 +79,7 @@ clean-dirs += $(objtree)/debian/
82 79
83# tarball targets 80# tarball targets
84# --------------------------------------------------------------------------- 81# ---------------------------------------------------------------------------
85.PHONY: tar%pkg 82tar%pkg: FORCE
86tar%pkg:
87 $(MAKE) KBUILD_SRC= 83 $(MAKE) KBUILD_SRC=
88 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ 84 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
89 85
@@ -92,7 +88,7 @@ clean-dirs += $(objtree)/tar-install/
92 88
93# Help text displayed when executing 'make help' 89# Help text displayed when executing 'make help'
94# --------------------------------------------------------------------------- 90# ---------------------------------------------------------------------------
95help: 91help: FORCE
96 @echo ' rpm-pkg - Build the kernel as an RPM package' 92 @echo ' rpm-pkg - Build the kernel as an RPM package'
97 @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel' 93 @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel'
98 @echo ' and modules' 94 @echo ' and modules'
diff --git a/scripts/profile2linkerlist.pl b/scripts/profile2linkerlist.pl
new file mode 100644
index 000000000000..cb4260ebdb91
--- /dev/null
+++ b/scripts/profile2linkerlist.pl
@@ -0,0 +1,21 @@
1#!/usr/bin/perl
2
3#
4# Takes a (sorted) output of readprofile and turns it into a list suitable for
5# linker scripts
6#
7# usage:
8# readprofile | sort -rn | perl profile2linkerlist.pl > functionlist
9#
10
11while (<>) {
12 my $line = $_;
13
14 $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
15
16 if ( ($line =~ /unknown/) || ($line =~ /total/)) {
17
18 } else {
19 print "*(.text.$1)\n";
20 }
21}
diff --git a/scripts/reference_discarded.pl b/scripts/reference_discarded.pl
deleted file mode 100644
index 4ee6ab2135b3..000000000000
--- a/scripts/reference_discarded.pl
+++ /dev/null
@@ -1,112 +0,0 @@
1#!/usr/bin/perl -w
2#
3# reference_discarded.pl (C) Keith Owens 2001 <kaos@ocs.com.au>
4#
5# Released under GPL V2.
6#
7# List dangling references to vmlinux discarded sections.
8
9use strict;
10die($0 . " takes no arguments\n") if($#ARGV >= 0);
11
12my %object;
13my $object;
14my $line;
15my $ignore;
16my $errorcount;
17
18$| = 1;
19
20# printf("Finding objects, ");
21open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
22while (defined($line = <OBJDUMP_LIST>)) {
23 chomp($line);
24 if ($line =~ /:\s+file format/) {
25 ($object = $line) =~ s/:.*//;
26 $object{$object}->{'module'} = 0;
27 $object{$object}->{'size'} = 0;
28 $object{$object}->{'off'} = 0;
29 }
30 if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
31 $object{$object}->{'module'} = 1;
32 }
33 if ($line =~ /^\s*\d+\s+\.comment\s+/) {
34 ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
35 }
36}
37close(OBJDUMP_LIST);
38# printf("%d objects, ", scalar keys(%object));
39$ignore = 0;
40foreach $object (keys(%object)) {
41 if ($object{$object}->{'module'}) {
42 ++$ignore;
43 delete($object{$object});
44 }
45}
46# printf("ignoring %d module(s)\n", $ignore);
47
48# Ignore conglomerate objects, they have been built from multiple objects and we
49# only care about the individual objects. If an object has more than one GCC:
50# string in the comment section then it is conglomerate. This does not filter
51# out conglomerates that consist of exactly one object, can't be helped.
52
53# printf("Finding conglomerates, ");
54$ignore = 0;
55foreach $object (keys(%object)) {
56 if (exists($object{$object}->{'off'})) {
57 my ($off, $size, $comment, $l);
58 $off = hex($object{$object}->{'off'});
59 $size = hex($object{$object}->{'size'});
60 open(OBJECT, "<$object") || die "cannot read $object";
61 seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
62 $l = read(OBJECT, $comment, $size);
63 die "read $size bytes from $object .comment failed" if ($l != $size);
64 close(OBJECT);
65 if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) {
66 ++$ignore;
67 delete($object{$object});
68 }
69 }
70}
71# printf("ignoring %d conglomerate(s)\n", $ignore);
72
73# printf("Scanning objects\n");
74
75# Keith Ownes <kaos@sgi.com> commented:
76# For our future {in}sanity, add a comment that this is the ppc .opd
77# section, not the ia64 .opd section.
78# ia64 .opd should not point to discarded sections.
79$errorcount = 0;
80foreach $object (keys(%object)) {
81 my $from;
82 open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
83 while (defined($line = <OBJDUMP>)) {
84 chomp($line);
85 if ($line =~ /RELOCATION RECORDS FOR /) {
86 ($from = $line) =~ s/.*\[([^]]*).*/$1/;
87 }
88 if (($line =~ /\.text\.exit$/ ||
89 $line =~ /\.exit\.text$/ ||
90 $line =~ /\.data\.exit$/ ||
91 $line =~ /\.exit\.data$/ ||
92 $line =~ /\.exitcall\.exit$/) &&
93 ($from !~ /\.text\.exit$/ &&
94 $from !~ /\.exit\.text$/ &&
95 $from !~ /\.data\.exit$/ &&
96 $from !~ /\.opd$/ &&
97 $from !~ /\.exit\.data$/ &&
98 $from !~ /\.altinstructions$/ &&
99 $from !~ /\.pdr$/ &&
100 $from !~ /\.debug_.*$/ &&
101 $from !~ /\.exitcall\.exit$/ &&
102 $from !~ /\.eh_frame$/ &&
103 $from !~ /\.stab$/)) {
104 printf("Error: %s %s refers to %s\n", $object, $from, $line);
105 $errorcount = $errorcount + 1;
106 }
107 }
108 close(OBJDUMP);
109}
110# printf("Done\n");
111
112exit(0);
diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl
deleted file mode 100644
index 7f6960b175a2..000000000000
--- a/scripts/reference_init.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/bin/perl -w
2#
3# reference_init.pl (C) Keith Owens 2002 <kaos@ocs.com.au>
4#
5# List references to vmlinux init sections from non-init sections.
6
7# Unfortunately I had to exclude references from read only data to .init
8# sections, almost all of these are false positives, they are created by
9# gcc. The downside of excluding rodata is that there really are some
10# user references from rodata to init code, e.g. drivers/video/vgacon.c
11#
12# const struct consw vga_con = {
13# con_startup: vgacon_startup,
14#
15# where vgacon_startup is __init. If you want to wade through the false
16# positives, take out the check for rodata.
17
18use strict;
19die($0 . " takes no arguments\n") if($#ARGV >= 0);
20
21my %object;
22my $object;
23my $line;
24my $ignore;
25
26$| = 1;
27
28printf("Finding objects, ");
29open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
30while (defined($line = <OBJDUMP_LIST>)) {
31 chomp($line);
32 if ($line =~ /:\s+file format/) {
33 ($object = $line) =~ s/:.*//;
34 $object{$object}->{'module'} = 0;
35 $object{$object}->{'size'} = 0;
36 $object{$object}->{'off'} = 0;
37 }
38 if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
39 $object{$object}->{'module'} = 1;
40 }
41 if ($line =~ /^\s*\d+\s+\.comment\s+/) {
42 ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
43 }
44}
45close(OBJDUMP_LIST);
46printf("%d objects, ", scalar keys(%object));
47$ignore = 0;
48foreach $object (keys(%object)) {
49 if ($object{$object}->{'module'}) {
50 ++$ignore;
51 delete($object{$object});
52 }
53}
54printf("ignoring %d module(s)\n", $ignore);
55
56# Ignore conglomerate objects, they have been built from multiple objects and we
57# only care about the individual objects. If an object has more than one GCC:
58# string in the comment section then it is conglomerate. This does not filter
59# out conglomerates that consist of exactly one object, can't be helped.
60
61printf("Finding conglomerates, ");
62$ignore = 0;
63foreach $object (keys(%object)) {
64 if (exists($object{$object}->{'off'})) {
65 my ($off, $size, $comment, $l);
66 $off = hex($object{$object}->{'off'});
67 $size = hex($object{$object}->{'size'});
68 open(OBJECT, "<$object") || die "cannot read $object";
69 seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
70 $l = read(OBJECT, $comment, $size);
71 die "read $size bytes from $object .comment failed" if ($l != $size);
72 close(OBJECT);
73 if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) {
74 ++$ignore;
75 delete($object{$object});
76 }
77 }
78}
79printf("ignoring %d conglomerate(s)\n", $ignore);
80
81printf("Scanning objects\n");
82foreach $object (sort(keys(%object))) {
83 my $from;
84 open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
85 while (defined($line = <OBJDUMP>)) {
86 chomp($line);
87 if ($line =~ /RELOCATION RECORDS FOR /) {
88 ($from = $line) =~ s/.*\[([^]]*).*/$1/;
89 }
90 if (($line =~ /\.init$/ || $line =~ /\.init\./) &&
91 ($from !~ /\.init$/ &&
92 $from !~ /\.init\./ &&
93 $from !~ /\.stab$/ &&
94 $from !~ /\.rodata$/ &&
95 $from !~ /\.text\.lock$/ &&
96 $from !~ /\.pci_fixup_header$/ &&
97 $from !~ /\.pci_fixup_final$/ &&
98 $from !~ /\.pdr$/ &&
99 $from !~ /\__param$/ &&
100 $from !~ /\.altinstructions/ &&
101 $from !~ /\.eh_frame/ &&
102 $from !~ /\.debug_/)) {
103 printf("Error: %s %s refers to %s\n", $object, $from, $line);
104 }
105 }
106 close(OBJDUMP);
107}
108printf("Done\n");
diff --git a/security/commoncap.c b/security/commoncap.c
index 8a6e097f99ea..841eb4e5c62b 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -60,8 +60,8 @@ int cap_settime(struct timespec *ts, struct timezone *tz)
60int cap_ptrace (struct task_struct *parent, struct task_struct *child) 60int cap_ptrace (struct task_struct *parent, struct task_struct *child)
61{ 61{
62 /* Derived from arch/i386/kernel/ptrace.c:sys_ptrace. */ 62 /* Derived from arch/i386/kernel/ptrace.c:sys_ptrace. */
63 if (!cap_issubset (child->cap_permitted, current->cap_permitted) && 63 if (!cap_issubset(child->cap_permitted, parent->cap_permitted) &&
64 !capable(CAP_SYS_PTRACE)) 64 !__capable(parent, CAP_SYS_PTRACE))
65 return -EPERM; 65 return -EPERM;
66 return 0; 66 return 0;
67} 67}
diff --git a/security/keys/key.c b/security/keys/key.c
index 99781b798312..a057e3311aad 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -1,6 +1,6 @@
1/* key.c: basic authentication token and access key management 1/* key.c: basic authentication token and access key management
2 * 2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2004-6 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -271,7 +271,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
271 * its description */ 271 * its description */
272 if (!not_in_quota) { 272 if (!not_in_quota) {
273 spin_lock(&user->lock); 273 spin_lock(&user->lock);
274 if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS && 274 if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS ||
275 user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES 275 user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES
276 ) 276 )
277 goto no_quota; 277 goto no_quota;
@@ -795,12 +795,16 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
795 goto error_3; 795 goto error_3;
796 } 796 }
797 797
798 /* search for an existing key of the same type and description in the 798 /* if it's possible to update this type of key, search for an existing
799 * destination keyring 799 * key of the same type and description in the destination keyring and
800 * update that instead if possible
800 */ 801 */
801 key_ref = __keyring_search_one(keyring_ref, ktype, description, 0); 802 if (ktype->update) {
802 if (!IS_ERR(key_ref)) 803 key_ref = __keyring_search_one(keyring_ref, ktype, description,
803 goto found_matching_key; 804 0);
805 if (!IS_ERR(key_ref))
806 goto found_matching_key;
807 }
804 808
805 /* decide on the permissions we want */ 809 /* decide on the permissions we want */
806 perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; 810 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 0c62798ac7d8..ed71d86d2ce2 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -17,10 +17,33 @@
17#include <linux/keyctl.h> 17#include <linux/keyctl.h>
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/capability.h> 19#include <linux/capability.h>
20#include <linux/string.h>
20#include <linux/err.h> 21#include <linux/err.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include "internal.h" 23#include "internal.h"
23 24
25static int key_get_type_from_user(char *type,
26 const char __user *_type,
27 unsigned len)
28{
29 int ret;
30
31 ret = strncpy_from_user(type, _type, len);
32
33 if (ret < 0)
34 return -EFAULT;
35
36 if (ret == 0 || ret >= len)
37 return -EINVAL;
38
39 if (type[0] == '.')
40 return -EPERM;
41
42 type[len - 1] = '\0';
43
44 return 0;
45}
46
24/*****************************************************************************/ 47/*****************************************************************************/
25/* 48/*
26 * extract the description of a new key from userspace and either add it as a 49 * 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,
38 key_ref_t keyring_ref, key_ref; 61 key_ref_t keyring_ref, key_ref;
39 char type[32], *description; 62 char type[32], *description;
40 void *payload; 63 void *payload;
41 long dlen, ret; 64 long ret;
42 65
43 ret = -EINVAL; 66 ret = -EINVAL;
44 if (plen > 32767) 67 if (plen > 32767)
45 goto error; 68 goto error;
46 69
47 /* draw all the data into kernel space */ 70 /* draw all the data into kernel space */
48 ret = strncpy_from_user(type, _type, sizeof(type) - 1); 71 ret = key_get_type_from_user(type, _type, sizeof(type));
49 if (ret < 0) 72 if (ret < 0)
50 goto error; 73 goto error;
51 type[31] = '\0';
52
53 ret = -EPERM;
54 if (type[0] == '.')
55 goto error;
56
57 ret = -EFAULT;
58 dlen = strnlen_user(_description, PAGE_SIZE - 1);
59 if (dlen <= 0)
60 goto error;
61 74
62 ret = -EINVAL; 75 description = strndup_user(_description, PAGE_SIZE);
63 if (dlen > PAGE_SIZE - 1) 76 if (IS_ERR(description)) {
64 goto error; 77 ret = PTR_ERR(description);
65
66 ret = -ENOMEM;
67 description = kmalloc(dlen + 1, GFP_KERNEL);
68 if (!description)
69 goto error; 78 goto error;
70 description[dlen] = '\0'; 79 }
71
72 ret = -EFAULT;
73 if (copy_from_user(description, _description, dlen) != 0)
74 goto error2;
75 80
76 /* pull the payload in if one was supplied */ 81 /* pull the payload in if one was supplied */
77 payload = NULL; 82 payload = NULL;
@@ -136,59 +141,28 @@ asmlinkage long sys_request_key(const char __user *_type,
136 struct key *key; 141 struct key *key;
137 key_ref_t dest_ref; 142 key_ref_t dest_ref;
138 char type[32], *description, *callout_info; 143 char type[32], *description, *callout_info;
139 long dlen, ret; 144 long ret;
140 145
141 /* pull the type into kernel space */ 146 /* pull the type into kernel space */
142 ret = strncpy_from_user(type, _type, sizeof(type) - 1); 147 ret = key_get_type_from_user(type, _type, sizeof(type));
143 if (ret < 0) 148 if (ret < 0)
144 goto error; 149 goto error;
145 type[31] = '\0';
146
147 ret = -EPERM;
148 if (type[0] == '.')
149 goto error;
150 150
151 /* pull the description into kernel space */ 151 /* pull the description into kernel space */
152 ret = -EFAULT; 152 description = strndup_user(_description, PAGE_SIZE);
153 dlen = strnlen_user(_description, PAGE_SIZE - 1); 153 if (IS_ERR(description)) {
154 if (dlen <= 0) 154 ret = PTR_ERR(description);
155 goto error;
156
157 ret = -EINVAL;
158 if (dlen > PAGE_SIZE - 1)
159 goto error;
160
161 ret = -ENOMEM;
162 description = kmalloc(dlen + 1, GFP_KERNEL);
163 if (!description)
164 goto error; 155 goto error;
165 description[dlen] = '\0'; 156 }
166
167 ret = -EFAULT;
168 if (copy_from_user(description, _description, dlen) != 0)
169 goto error2;
170 157
171 /* pull the callout info into kernel space */ 158 /* pull the callout info into kernel space */
172 callout_info = NULL; 159 callout_info = NULL;
173 if (_callout_info) { 160 if (_callout_info) {
174 ret = -EFAULT; 161 callout_info = strndup_user(_callout_info, PAGE_SIZE);
175 dlen = strnlen_user(_callout_info, PAGE_SIZE - 1); 162 if (IS_ERR(callout_info)) {
176 if (dlen <= 0) 163 ret = PTR_ERR(callout_info);
177 goto error2;
178
179 ret = -EINVAL;
180 if (dlen > PAGE_SIZE - 1)
181 goto error2;
182
183 ret = -ENOMEM;
184 callout_info = kmalloc(dlen + 1, GFP_KERNEL);
185 if (!callout_info)
186 goto error2; 164 goto error2;
187 callout_info[dlen] = '\0'; 165 }
188
189 ret = -EFAULT;
190 if (copy_from_user(callout_info, _callout_info, dlen) != 0)
191 goto error3;
192 } 166 }
193 167
194 /* get the destination keyring if specified */ 168 /* get the destination keyring if specified */
@@ -264,36 +238,21 @@ long keyctl_get_keyring_ID(key_serial_t id, int create)
264long keyctl_join_session_keyring(const char __user *_name) 238long keyctl_join_session_keyring(const char __user *_name)
265{ 239{
266 char *name; 240 char *name;
267 long nlen, ret; 241 long ret;
268 242
269 /* fetch the name from userspace */ 243 /* fetch the name from userspace */
270 name = NULL; 244 name = NULL;
271 if (_name) { 245 if (_name) {
272 ret = -EFAULT; 246 name = strndup_user(_name, PAGE_SIZE);
273 nlen = strnlen_user(_name, PAGE_SIZE - 1); 247 if (IS_ERR(name)) {
274 if (nlen <= 0) 248 ret = PTR_ERR(name);
275 goto error;
276
277 ret = -EINVAL;
278 if (nlen > PAGE_SIZE - 1)
279 goto error; 249 goto error;
280 250 }
281 ret = -ENOMEM;
282 name = kmalloc(nlen + 1, GFP_KERNEL);
283 if (!name)
284 goto error;
285 name[nlen] = '\0';
286
287 ret = -EFAULT;
288 if (copy_from_user(name, _name, nlen) != 0)
289 goto error2;
290 } 251 }
291 252
292 /* join the session */ 253 /* join the session */
293 ret = join_session_keyring(name); 254 ret = join_session_keyring(name);
294 255
295 error2:
296 kfree(name);
297 error: 256 error:
298 return ret; 257 return ret;
299 258
@@ -566,32 +525,18 @@ long keyctl_keyring_search(key_serial_t ringid,
566 struct key_type *ktype; 525 struct key_type *ktype;
567 key_ref_t keyring_ref, key_ref, dest_ref; 526 key_ref_t keyring_ref, key_ref, dest_ref;
568 char type[32], *description; 527 char type[32], *description;
569 long dlen, ret; 528 long ret;
570 529
571 /* pull the type and description into kernel space */ 530 /* pull the type and description into kernel space */
572 ret = strncpy_from_user(type, _type, sizeof(type) - 1); 531 ret = key_get_type_from_user(type, _type, sizeof(type));
573 if (ret < 0) 532 if (ret < 0)
574 goto error; 533 goto error;
575 type[31] = '\0';
576 534
577 ret = -EFAULT; 535 description = strndup_user(_description, PAGE_SIZE);
578 dlen = strnlen_user(_description, PAGE_SIZE - 1); 536 if (IS_ERR(description)) {
579 if (dlen <= 0) 537 ret = PTR_ERR(description);
580 goto error; 538 goto error;
581 539 }
582 ret = -EINVAL;
583 if (dlen > PAGE_SIZE - 1)
584 goto error;
585
586 ret = -ENOMEM;
587 description = kmalloc(dlen + 1, GFP_KERNEL);
588 if (!description)
589 goto error;
590 description[dlen] = '\0';
591
592 ret = -EFAULT;
593 if (copy_from_user(description, _description, dlen) != 0)
594 goto error2;
595 540
596 /* get the keyring at which to begin the search */ 541 /* get the keyring at which to begin the search */
597 keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH); 542 keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH);
diff --git a/security/security.c b/security/security.c
index f693e1f66b98..51ef509710b9 100644
--- a/security/security.c
+++ b/security/security.c
@@ -174,31 +174,8 @@ int mod_unreg_security(const char *name, struct security_operations *ops)
174 return security_ops->unregister_security(name, ops); 174 return security_ops->unregister_security(name, ops);
175} 175}
176 176
177/**
178 * capable - calls the currently loaded security module's capable() function with the specified capability
179 * @cap: the requested capability level.
180 *
181 * This function calls the currently loaded security module's capable()
182 * function with a pointer to the current task and the specified @cap value.
183 *
184 * This allows the security module to implement the capable function call
185 * however it chooses to.
186 */
187int capable(int cap)
188{
189 if (security_ops->capable(current, cap)) {
190 /* capability denied */
191 return 0;
192 }
193
194 /* capability granted */
195 current->flags |= PF_SUPERPRIV;
196 return 1;
197}
198
199EXPORT_SYMBOL_GPL(register_security); 177EXPORT_SYMBOL_GPL(register_security);
200EXPORT_SYMBOL_GPL(unregister_security); 178EXPORT_SYMBOL_GPL(unregister_security);
201EXPORT_SYMBOL_GPL(mod_reg_security); 179EXPORT_SYMBOL_GPL(mod_reg_security);
202EXPORT_SYMBOL_GPL(mod_unreg_security); 180EXPORT_SYMBOL_GPL(mod_unreg_security);
203EXPORT_SYMBOL(capable);
204EXPORT_SYMBOL(security_ops); 181EXPORT_SYMBOL(security_ops);
diff --git a/sound/oss/.gitignore b/sound/oss/.gitignore
new file mode 100644
index 000000000000..7efb12b45502
--- /dev/null
+++ b/sound/oss/.gitignore
@@ -0,0 +1,4 @@
1#Ignore generated files
2maui_boot.h
3pss_boot.h
4trix_boot.h
diff --git a/sound/oss/au1000.c b/sound/oss/au1000.c
index fe54de25aafc..eacb0aef21e1 100644
--- a/sound/oss/au1000.c
+++ b/sound/oss/au1000.c
@@ -100,7 +100,7 @@
100 100
101/* Boot options */ 101/* Boot options */
102static int vra = 0; // 0 = no VRA, 1 = use VRA if codec supports it 102static int vra = 0; // 0 = no VRA, 1 = use VRA if codec supports it
103MODULE_PARM(vra, "i"); 103module_param(vra, bool, 0);
104MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it"); 104MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it");
105 105
106 106
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index 6a4956b8025d..c1168fae6be6 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -79,7 +79,7 @@
79 * 0 = no VRA, 1 = use VRA if codec supports it 79 * 0 = no VRA, 1 = use VRA if codec supports it
80 */ 80 */
81static int vra = 1; 81static int vra = 1;
82MODULE_PARM(vra, "i"); 82module_param(vra, bool, 0);
83MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it"); 83MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it");
84 84
85static struct au1550_state { 85static struct au1550_state {
diff --git a/sound/oss/awe_wave.c b/sound/oss/awe_wave.c
index b3ea719d33db..d1a0eb294d6f 100644
--- a/sound/oss/awe_wave.c
+++ b/sound/oss/awe_wave.c
@@ -2944,7 +2944,7 @@ alloc_new_info(void)
2944{ 2944{
2945 awe_voice_list *newlist; 2945 awe_voice_list *newlist;
2946 2946
2947 newlist = (awe_voice_list *)kmalloc(sizeof(*newlist), GFP_KERNEL); 2947 newlist = kmalloc(sizeof(*newlist), GFP_KERNEL);
2948 if (newlist == NULL) { 2948 if (newlist == NULL) {
2949 printk(KERN_ERR "AWE32: can't alloc info table\n"); 2949 printk(KERN_ERR "AWE32: can't alloc info table\n");
2950 return NULL; 2950 return NULL;
@@ -3547,8 +3547,10 @@ awe_load_guspatch(const char __user *addr, int offs, int size, int pmgr_flag)
3547 smp->checksum_flag = 0; 3547 smp->checksum_flag = 0;
3548 smp->checksum = 0; 3548 smp->checksum = 0;
3549 3549
3550 if ((rc = awe_write_wave_data(addr, sizeof_patch, smprec, -1)) < 0) 3550 if ((rc = awe_write_wave_data(addr, sizeof_patch, smprec, -1)) < 0) {
3551 kfree(vrec);
3551 return rc; 3552 return rc;
3553 }
3552 sf->mem_ptr += rc; 3554 sf->mem_ptr += rc;
3553 add_sf_sample(sf, smprec); 3555 add_sf_sample(sf, smprec);
3554 3556
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index c9302a1e515b..87bd3100aef3 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -195,18 +195,18 @@
195 */ 195 */
196 196
197int dmasound_catchRadius = 0; 197int dmasound_catchRadius = 0;
198MODULE_PARM(dmasound_catchRadius, "i"); 198module_param(dmasound_catchRadius, int, 0);
199 199
200static unsigned int numWriteBufs = DEFAULT_N_BUFFERS; 200static unsigned int numWriteBufs = DEFAULT_N_BUFFERS;
201MODULE_PARM(numWriteBufs, "i"); 201module_param(numWriteBufs, int, 0);
202static unsigned int writeBufSize = DEFAULT_BUFF_SIZE ; /* in bytes */ 202static unsigned int writeBufSize = DEFAULT_BUFF_SIZE ; /* in bytes */
203MODULE_PARM(writeBufSize, "i"); 203module_param(writeBufSize, int, 0);
204 204
205#ifdef HAS_RECORD 205#ifdef HAS_RECORD
206static unsigned int numReadBufs = DEFAULT_N_BUFFERS; 206static unsigned int numReadBufs = DEFAULT_N_BUFFERS;
207MODULE_PARM(numReadBufs, "i"); 207module_param(numReadBufs, int, 0);
208static unsigned int readBufSize = DEFAULT_BUFF_SIZE; /* in bytes */ 208static unsigned int readBufSize = DEFAULT_BUFF_SIZE; /* in bytes */
209MODULE_PARM(readBufSize, "i"); 209module_param(readBufSize, int, 0);
210#endif 210#endif
211 211
212MODULE_LICENSE("GPL"); 212MODULE_LICENSE("GPL");
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c
index ffcb910f5c3e..00ac1c95a429 100644
--- a/sound/oss/ite8172.c
+++ b/sound/oss/ite8172.c
@@ -1968,9 +1968,9 @@ static int i2s_fmt[NR_DEVICE];
1968 1968
1969static unsigned int devindex; 1969static unsigned int devindex;
1970 1970
1971MODULE_PARM(spdif, "1-" __MODULE_STRING(NR_DEVICE) "i"); 1971module_param_array(spdif, int, NULL, 0);
1972MODULE_PARM_DESC(spdif, "if 1 the S/PDIF digital output is enabled"); 1972MODULE_PARM_DESC(spdif, "if 1 the S/PDIF digital output is enabled");
1973MODULE_PARM(i2s_fmt, "1-" __MODULE_STRING(NR_DEVICE) "i"); 1973module_param_array(i2s_fmt, int, NULL, 0);
1974MODULE_PARM_DESC(i2s_fmt, "the format of I2S"); 1974MODULE_PARM_DESC(i2s_fmt, "the format of I2S");
1975 1975
1976MODULE_AUTHOR("Monta Vista Software, stevel@mvista.com"); 1976MODULE_AUTHOR("Monta Vista Software, stevel@mvista.com");
diff --git a/sound/oss/sb_mixer.c b/sound/oss/sb_mixer.c
index f56898c3981e..ccb21d48d42c 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)
273 int regoffs; 273 int regoffs;
274 unsigned char val; 274 unsigned char val;
275 275
276 if ((dev < 0) || (dev >= devc->iomap_sz))
277 return -EINVAL;
278
276 regoffs = (*devc->iomap)[dev][LEFT_CHN].regno; 279 regoffs = (*devc->iomap)[dev][LEFT_CHN].regno;
277 280
278 if (regoffs == 0) 281 if (regoffs == 0)
279 return -EINVAL; 282 return -EINVAL;
280 283
281 if ((dev < 0) || (dev >= devc->iomap_sz))
282 return -EINVAL;
283
284 val = sb_getmixer(devc, regoffs); 284 val = sb_getmixer(devc, regoffs);
285 change_bits(devc, &val, dev, LEFT_CHN, left); 285 change_bits(devc, &val, dev, LEFT_CHN, left);
286 286
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index 698614226c9a..347cd79c2502 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -709,11 +709,11 @@ static void seq_local_event(unsigned char *event_rec)
709 709
710static void seq_sysex_message(unsigned char *event_rec) 710static void seq_sysex_message(unsigned char *event_rec)
711{ 711{
712 int dev = event_rec[1]; 712 unsigned int dev = event_rec[1];
713 int i, l = 0; 713 int i, l = 0;
714 unsigned char *buf = &event_rec[2]; 714 unsigned char *buf = &event_rec[2];
715 715
716 if ((int) dev > max_synthdev) 716 if (dev > max_synthdev)
717 return; 717 return;
718 if (!(synth_open_mask & (1 << dev))) 718 if (!(synth_open_mask & (1 << dev)))
719 return; 719 return;
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index dce9016cbcfd..eb5ea32fd1b0 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -154,8 +154,8 @@ static void start_adc(struct cs4297a_state *s);
154#if CSDEBUG 154#if CSDEBUG
155static unsigned long cs_debuglevel = 4; // levels range from 1-9 155static unsigned long cs_debuglevel = 4; // levels range from 1-9
156static unsigned long cs_debugmask = CS_INIT /*| CS_IOCTL*/; 156static unsigned long cs_debugmask = CS_INIT /*| CS_IOCTL*/;
157MODULE_PARM(cs_debuglevel, "i"); 157module_param(cs_debuglevel, int, 0);
158MODULE_PARM(cs_debugmask, "i"); 158module_param(cs_debugmask, int, 0);
159#endif 159#endif
160#define CS_TRUE 1 160#define CS_TRUE 1
161#define CS_FALSE 0 161#define CS_FALSE 0
diff --git a/sound/oss/waveartist.c b/sound/oss/waveartist.c
index 99d04ad3ca13..afcb524a40eb 100644
--- a/sound/oss/waveartist.c
+++ b/sound/oss/waveartist.c
@@ -2028,8 +2028,8 @@ __setup("waveartist=", setup_waveartist);
2028#endif 2028#endif
2029 2029
2030MODULE_DESCRIPTION("Rockwell WaveArtist RWA-010 sound driver"); 2030MODULE_DESCRIPTION("Rockwell WaveArtist RWA-010 sound driver");
2031MODULE_PARM(io, "i"); /* IO base */ 2031module_param(io, int, 0); /* IO base */
2032MODULE_PARM(irq, "i"); /* IRQ */ 2032module_param(irq, int, 0); /* IRQ */
2033MODULE_PARM(dma, "i"); /* DMA */ 2033module_param(dma, int, 0); /* DMA */
2034MODULE_PARM(dma2, "i"); /* DMA2 */ 2034module_param(dma2, int, 0); /* DMA2 */
2035MODULE_LICENSE("GPL"); 2035MODULE_LICENSE("GPL");
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c
index 210be20dc27e..4e595172e423 100644
--- a/sound/ppc/toonie.c
+++ b/sound/ppc/toonie.c
@@ -117,7 +117,7 @@ static int toonie_get_mute_switch(struct snd_kcontrol *kcontrol,
117 gp = &mix->amp_mute_gpio; 117 gp = &mix->amp_mute_gpio;
118 break; 118 break;
119 default: 119 default:
120 return -EINVAL;; 120 return -EINVAL;
121 } 121 }
122 ucontrol->value.integer.value[0] = !check_audio_gpio(gp); 122 ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
123 return 0; 123 return 0;
@@ -145,7 +145,7 @@ static int toonie_put_mute_switch(struct snd_kcontrol *kcontrol,
145 gp = &mix->amp_mute_gpio; 145 gp = &mix->amp_mute_gpio;
146 break; 146 break;
147 default: 147 default:
148 return -EINVAL;; 148 return -EINVAL;
149 } 149 }
150 val = ! check_audio_gpio(gp); 150 val = ! check_audio_gpio(gp);
151 if (val != ucontrol->value.integer.value[0]) { 151 if (val != ucontrol->value.integer.value[0]) {
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 53a148b01b6b..8804f26ddb3a 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,
611 unsigned int period_size = snd_pcm_lib_period_bytes(substream); 611 unsigned int period_size = snd_pcm_lib_period_bytes(substream);
612 unsigned int offset = period_size * (*periods_sent); 612 unsigned int offset = period_size * (*periods_sent);
613 613
614 if (period_size >= (1 << 24)) 614 BUG_ON(period_size >= (1 << 24));
615 BUG();
616 615
617 if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size)) 616 if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size))
618 return; 617 return;
@@ -1079,8 +1078,7 @@ static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream)
1079 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | 1078 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE |
1080 CS4231_PLAYBACK_PIO); 1079 CS4231_PLAYBACK_PIO);
1081 1080
1082 if (runtime->period_size > 0xffff + 1) 1081 BUG_ON(runtime->period_size > 0xffff + 1);
1083 BUG();
1084 1082
1085 chip->p_periods_sent = 0; 1083 chip->p_periods_sent = 0;
1086 spin_unlock_irqrestore(&chip->lock, flags); 1084 spin_unlock_irqrestore(&chip->lock, flags);